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,YAAcN,IACrDyhC,EAAkBt5B,MAAAA,OAAQ,EAARA,EAAUV,MAAK6L,GAAWA,EAAQlP,WAAapE,IACvE,IAAI0hC,GAAgB,EACE,IAAD,EAArB,GAAID,EACAC,IAA0C,QAAzB,EAACD,EAAgBE,gBAAQ,QAAxB,EAA0BC,kBAEhD,MAAMC,IACF16B,MAAAA,IAAAA,EAAUI,cAA0C,KAA1BJ,EAASI,eAAsBJ,EAASI,eAAiBs5B,GACrDa,GAAiBG,IAM9CvG,MAAAA,IAAAA,EAAqBc,oBAAuBoF,GAAqBD,EAAcC,KAChFR,EAAoBvhC,KAAKO,GACzB+gC,GAAU,IAItB,MAAO,CACHA,QAAAA,EACAC,oBAAAA","sources":["webpack://msdyn365.commerce.online/../../src/add-address.ts?fb17","webpack://msdyn365.commerce.online/../../src/add-item-to-product-list.ts?580e","webpack://msdyn365.commerce.online/../../src/add-organization-user.ts?ed86","webpack://msdyn365.commerce.online/../../src/checkout.ts?57e0","webpack://msdyn365.commerce.online/../../src/create-product-list.ts?7367","webpack://msdyn365.commerce.online/../../src/delete-address.ts?f9a3","webpack://msdyn365.commerce.online/../../src/delete-organization-user.ts?7f5d","webpack://msdyn365.commerce.online/../../src/edit-organization-user.ts?d2ac","webpack://msdyn365.commerce.online/../../src/generic-data-action.ts?f887","webpack://msdyn365.commerce.online/../../src/get-address.ts?20a3","webpack://msdyn365.commerce.online/../../src/get-attribute-definitions.ts?cc6b","webpack://msdyn365.commerce.online/../../src/get-attributes-for-selected-variant.ts?af00","webpack://msdyn365.commerce.online/../../src/get-availabilities-cartlines.ts?b8e8","webpack://msdyn365.commerce.online/../../src/get-catalogs.ts?7332","webpack://msdyn365.commerce.online/../../src/get-categories-hierarchy.ts?acde","webpack://msdyn365.commerce.online/../../src/get-categories.ts?8dc6","webpack://msdyn365.commerce.online/../../src/get-category-paths.ts?b007","webpack://msdyn365.commerce.online/../../src/get-channel-delivery-option-configuration.ts?a716","webpack://msdyn365.commerce.online/../../src/get-checkout-cart.ts?79bc","webpack://msdyn365.commerce.online/../../src/get-current-category-hierarchy.ts?d48e","webpack://msdyn365.commerce.online/../../src/get-current-category.ts?354d","webpack://msdyn365.commerce.online/../../src/get-customer-balance.ts?d165","webpack://msdyn365.commerce.online/../../src/get-customer-loyalty-cards.ts?2466","webpack://msdyn365.commerce.online/../../src/get-delivery-options-for-cartlines.ts?4dfe","webpack://msdyn365.commerce.online/../../src/get-delivery-options-for-selected-variant.ts?3f6c","webpack://msdyn365.commerce.online/../../src/get-dimension-availabilities-for-product-search-result.ts?5259","webpack://msdyn365.commerce.online/../../src/get-dimension-availabilities-for-products.ts?f656","webpack://msdyn365.commerce.online/../../src/get-dimensions-for-selected-variant.ts?6bf4","webpack://msdyn365.commerce.online/../../src/get-feature-state.ts?1a1d","webpack://msdyn365.commerce.online/../../src/get-full-available-inventory-nearby.ts?20be","webpack://msdyn365.commerce.online/../../../src/utilities/quick-order-templates.ts?0ea6","webpack://msdyn365.commerce.online/../../src/get-full-product-list.ts?ccfb","webpack://msdyn365.commerce.online/../../src/get-full-products-by-refine-search-category.ts?30ab","webpack://msdyn365.commerce.online/../../src/get-full-products-by-refine-search-text.ts?2ad7","webpack://msdyn365.commerce.online/../../../src/utilities/refiner-utils.ts?1e61","webpack://msdyn365.commerce.online/../../src/get-full-products.ts?ba9a","webpack://msdyn365.commerce.online/../../src/get-items-in-wishlist.ts?0d27","webpack://msdyn365.commerce.online/../../src/get-list.ts?4fd5","webpack://msdyn365.commerce.online/../../src/get-loyalty-card.ts?7213","webpack://msdyn365.commerce.online/../../src/get-loyalty-transaction-estimation.ts?e254","webpack://msdyn365.commerce.online/../../src/get-media-locations-by-id.ts?8462","webpack://msdyn365.commerce.online/../../src/get-media-locations-for-selected-variant.ts?fd54","webpack://msdyn365.commerce.online/../../src/get-order-history.ts?76fd","webpack://msdyn365.commerce.online/../../src/get-org-unit-configuration.ts?4793","webpack://msdyn365.commerce.online/../../src/get-organization-users-count.ts?b5f7","webpack://msdyn365.commerce.online/../../src/get-organization-users.ts?b72e","webpack://msdyn365.commerce.online/../../src/get-organization-wide-order-history.ts?92b8","webpack://msdyn365.commerce.online/../../src/get-pickup-options-for-cartlines.ts?843b","webpack://msdyn365.commerce.online/../../src/get-price-for-product-search-result.ts?36f8","webpack://msdyn365.commerce.online/../../src/get-price-for-selected-variant.ts?9e79","webpack://msdyn365.commerce.online/../../src/get-product-availabilities-for-selected-variant.ts?0abd","webpack://msdyn365.commerce.online/../../src/get-product-dimensions-with-availabilities.ts?347b","webpack://msdyn365.commerce.online/../../../src/utilities/quick-order-template-line.ts?56d5","webpack://msdyn365.commerce.online/../../src/get-product-list-lines.ts?ae74","webpack://msdyn365.commerce.online/../../src/get-product-list.ts?ef13","webpack://msdyn365.commerce.online/../../src/get-products-by-category.ts?accf","webpack://msdyn365.commerce.online/../../src/get-products-in-active-cart.ts?3376","webpack://msdyn365.commerce.online/../../src/get-promotion-options-for-cartlines.ts?1a35","webpack://msdyn365.commerce.online/../../src/get-ratings-summary-input.ts?3ccb","webpack://msdyn365.commerce.online/../../src/get-ratings-summary.ts?49bc","webpack://msdyn365.commerce.online/../../src/get-refiners-by-category.ts?6d4e","webpack://msdyn365.commerce.online/../../src/get-refiners-by-text.ts?c52a","webpack://msdyn365.commerce.online/../../src/get-related-products.ts?6f93","webpack://msdyn365.commerce.online/../../src/get-scan-results.ts?6b44","webpack://msdyn365.commerce.online/../../src/get-search-configuration.ts?acd1","webpack://msdyn365.commerce.online/../../src/get-selected-variant.ts?f0c0","webpack://msdyn365.commerce.online/../../src/get-simple-products.ts?fed7","webpack://msdyn365.commerce.online/../../src/get-store-location-information.ts?1df0","webpack://msdyn365.commerce.online/../../src/get-wishlist-by-customer-id.ts?e873","webpack://msdyn365.commerce.online/../../../src/invoices/get-invoice-details.ts?66a9","webpack://msdyn365.commerce.online/../../../src/invoices/get-invoices.ts?22cb","webpack://msdyn365.commerce.online/../../src/issue-loyalty.ts?f8fa","webpack://msdyn365.commerce.online/../../../src/order-templates/add-item-to-order-template.ts?fff3","webpack://msdyn365.commerce.online/../../../src/order-templates/add-order-template-to-cart.ts?6ee4","webpack://msdyn365.commerce.online/../../../src/order-templates/create-order-template.ts?03c1","webpack://msdyn365.commerce.online/../../../src/order-templates/get-full-order-template.ts?72c6","webpack://msdyn365.commerce.online/../../../src/order-templates/get-full-order-templates.ts?b553","webpack://msdyn365.commerce.online/../../../src/order-templates/get-order-templates-preview.ts?b8c3","webpack://msdyn365.commerce.online/../../../src/order-templates/get-order-templates.ts?a3b1","webpack://msdyn365.commerce.online/../../../src/order-templates/get-paginated-order-template-lines.ts?9b12","webpack://msdyn365.commerce.online/../../../src/order-templates/update-order-template-header.ts?1f77","webpack://msdyn365.commerce.online/../../../src/order-templates/update-order-template-line.ts?527b","webpack://msdyn365.commerce.online/../../src/refine-search-by-category.ts?3e65","webpack://msdyn365.commerce.online/../../src/search-by-text.ts?ebe1","webpack://msdyn365.commerce.online/../../src/update-address.ts?3e4d","webpack://msdyn365.commerce.online/../../src/update-customer-attributes.ts?8d49","webpack://msdyn365.commerce.online/../../src/update-customer-personalization.ts?4aa9","webpack://msdyn365.commerce.online/../../src/update-primary-address.ts?83fa","webpack://msdyn365.commerce.online/../../../../src/utilities/Url-builder/parameterize.ts?f5a5","webpack://msdyn365.commerce.online/../../../../src/utilities/Url-builder/category-url-builder.ts?e564","webpack://msdyn365.commerce.online/../../../../src/utilities/Url-builder/invoice-url-builder.ts?d542","webpack://msdyn365.commerce.online/../../../../src/utilities/Url-builder/product-url-builder.ts?baf1","webpack://msdyn365.commerce.online/../../../../src/utilities/data-structures/dictionary.ts?bab3","webpack://msdyn365.commerce.online/../../../../src/utilities/events/event.ts?15a9","webpack://msdyn365.commerce.online/../../../src/utilities/getRnrKeys.ts?700f","webpack://msdyn365.commerce.online/../../../src/utilities/order-templates.ts?d593","webpack://msdyn365.commerce.online/../../../src/utilities/product-inventory-information.ts?0ec6","webpack://msdyn365.commerce.online/../../../src/utilities/product-inventory-utils.ts?58b5","webpack://msdyn365.commerce.online/../../../../src/utilities/promise-queue/finite-promise-queue.ts?77bf","webpack://msdyn365.commerce.online/../../../../src/utilities/promise-queue/promise-queue.ts?e362","webpack://msdyn365.commerce.online/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/rng.js?b47d","webpack://msdyn365.commerce.online/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/regex.js?08ba","webpack://msdyn365.commerce.online/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/validate.js?acea","webpack://msdyn365.commerce.online/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/stringify.js?6cb1","webpack://msdyn365.commerce.online/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/v4.js?0101","webpack://msdyn365.commerce.online/../../../../src/utilities/random/guid.ts?1947","webpack://msdyn365.commerce.online/../../../../src/utilities/random/index.ts?1f9d","webpack://msdyn365.commerce.online/../../../../src/utilities/regex/email-regex.ts?6a6a","webpack://msdyn365.commerce.online/../../../../src/utilities/regex/password-regex.ts?456d","webpack://msdyn365.commerce.online/../../../../src/utilities/regex/phone-regex.ts?9ada","webpack://msdyn365.commerce.online/../../../src/utilities/validate-cartlines-inventory.ts?8b82"],"sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { Address, Customer } from '@msdyn365-commerce/retail-proxy';\nimport { createReadAsync, updateAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g';\n\nimport getCustomer, { GetCustomerInput } from './get-customer';\n\nexport interface IAddressManagementData {\n address: Address;\n}\nexport interface IAddressManagementInput extends IActionInput {\n address: Address;\n userAccountNumber?: string;\n}\n\n/**\n * The input class for the addAddress data action.\n */\nexport class AddressManagementInput implements IAddressManagementInput {\n public address: Address;\n\n public userAccountNumber?: string;\n\n constructor(address: Address, userAccountNumber?: string) {\n this.userAccountNumber = userAccountNumber;\n this.address = address;\n }\n\n public getCacheKey = () => 'AddAddress';\n\n public getCacheObjectType = () => 'AddAddress';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * The createInput method for the addAddress data action.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createAddressManagementInput = (\n inputData: ICreateActionContext, IAddressManagementData>\n): IAddressManagementInput => {\n if (inputData.requestContext.user.isAuthenticated) {\n throw new Error('User is not authenticated. Cannot call UpdateAddress API');\n }\n\n const { address } = inputData.data || { address: undefined };\n\n if (!address) {\n throw new Error('address is not provided. Cannot call UpdateAddress API');\n }\n\n return new AddressManagementInput(address);\n};\n\nexport async function doAddressManagementOperation(\n input: IAddressManagementInput,\n ctx: IActionContext,\n operationHandler: (customer: Customer, address: Address) => Customer\n): Promise {\n const { userAccountNumber, address } = input;\n const customerInput = new GetCustomerInput(ctx.requestContext.apiSettings, userAccountNumber, 'none');\n const customer = await getCustomer(customerInput, ctx);\n\n if (!customer) {\n throw new Error('Not able to create customer');\n }\n\n const newCustomer = operationHandler({ ...customer }, address);\n const updatedCustomer = await updateAsync({ callerContext: ctx }, newCustomer);\n\n if (!updatedCustomer) {\n throw new Error('Not able to update customer');\n }\n\n ctx.update(createReadAsync(updatedCustomer.AccountNumber), updatedCustomer);\n\n return updatedCustomer.Addresses || [];\n}\n\nexport function addAddressHandler(customer: Customer, address: Address): Customer {\n customer.Addresses = [...(customer.Addresses || [])];\n customer.Addresses.push(address);\n return customer;\n}\n\nexport async function addAddressAction(input: IAddressManagementInput, ctx: IActionContext): Promise {\n return doAddressManagementOperation(input, ctx, addAddressHandler);\n}\n\n/**\n * The addAddress data action\n * Calls the read RetailServer API to get information about a customer\n * Adds the passed address information to the retireved customer, and\n * then updates that customer via the update RetailServer API.\n */\nexport const addAddressActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/add-address',\n action: >addAddressAction,\n input: <(args: ICreateActionContext) => IActionInput>(createAddressManagementInput),\n isBatched: false\n});\n\nexport default addAddressActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { ProductListLine, ProductListsDataActions } from '@msdyn365-commerce/retail-proxy';\n\nimport { ArrayExtensions } from './utilities';\n\n/**\n * Input class for the AddItemToProductList data action.\n */\nexport class AddItemToProductListInput implements IActionInput {\n public readonly productListId: string;\n\n public readonly productId: number;\n\n public readonly quantity: number;\n\n public readonly unitOfMeasure: string;\n\n public constructor(productListId: string, productId: number, quantity: number, unitOfMeasure: string) {\n this.productListId = productListId;\n this.productId = productId;\n this.quantity = quantity;\n this.unitOfMeasure = unitOfMeasure || 'ea';\n }\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n public getCacheKey = (): string => 'AddItemToProductListInput';\n\n /**\n * Get Cachetype Name.\n * @returns - Cache name string.\n */\n public getCacheObjectType = (): string => 'AddItemToProductListInput';\n\n /**\n * Get Cachetype.\n * @returns - CacheType enum.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the AddItemToProductList method.\n * @param inputData - The input data passed to the createInput method.\n * @param productListId - The id of product list to update.\n * @param productId - The id of a product to add.\n * @param quantity - How many items of this product to add.\n * @param unitOfMeasure - Product measuring unit.\n * @returns - Input data for productlist add api.\n */\nexport const addItemToProductListInput = (\n inputData: ICreateActionContext,\n productListId: string,\n productId: number,\n quantity: number,\n unitOfMeasure: string\n): AddItemToProductListInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create product list. User is not authenticated.');\n }\n return new AddItemToProductListInput(productListId, productId, quantity, unitOfMeasure);\n};\n\n/**\n * The action method for the AddItemToProductList data action.\n * @param input - The action input.\n * @param context - The action context.\n * @returns - ProductList.\n */\nexport async function addItemToProductListAction(input: AddItemToProductListInput, context: IActionContext): Promise {\n try {\n const productListLineToAdd: ProductListLine = {\n ProductListId: input.productListId,\n ProductId: input.productId,\n Quantity: input.quantity,\n UnitOfMeasure: input.unitOfMeasure\n };\n\n const productListLine: ProductListLine[] = await ProductListsDataActions.addProductListLinesAsync(\n {\n callerContext: context\n },\n input.productListId,\n [productListLineToAdd]\n );\n\n if (ArrayExtensions.hasElements(productListLine) && productListLine[0].ProductListId) {\n return productListLine[0];\n }\n context.telemetry.error('Product list line was not returned when adding it to quick order bag');\n throw new Error('Product list line was not returned when adding it to quick order bag');\n } catch (error) {\n context.telemetry.error('Not able to add an item to quick order bag', error);\n throw error;\n }\n}\n\n/**\n * The AddItemToOrderTemplate Data Action.\n * Returns product list line that was added to the order template.\n */\nexport const addItemToProductListActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/add-item-to-product-list',\n action: addItemToProductListAction as IAction,\n input: addItemToProductListInput\n});\n\nexport default addItemToProductListActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { BusinessPartner, BusinessPartnerUser } from '@msdyn365-commerce/retail-proxy';\nimport { getCurrentAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/BusinessPartnersDataActions.g';\nimport { createBusinessPartnerUserAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/BusinessPartnerUsersDataActions.g';\n\n/**\n * Input class for addOrganizationUser data action.\n */\nexport class AddOrganizationUserInput implements IActionInput {\n public user: BusinessPartnerUser;\n\n constructor(newUser: BusinessPartnerUser) {\n this.user = newUser;\n }\n\n public getCacheKey = () => 'AddOrganizationUser';\n\n public getCacheObjectType = () => 'AddOrganizationUser';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Input class for addOrganizationUser data action.\n * @param inputData\n * @param newUser\n */\nexport const createAddOrganizationUserInput = (\n inputData: ICreateActionContext>,\n newUser: BusinessPartnerUser\n): IActionInput => {\n const { requestContext } = inputData;\n\n // Check if the user is authenticated.\n if (!requestContext.user.isAuthenticated) {\n throw new Error('User is not logged in.');\n }\n\n return new AddOrganizationUserInput(newUser);\n};\n\n/**\n * The addOrganizationUser data action\n * Calls getCurrent() to get a businessPartnerId from the user requesting the action.\n * It then maps the newUsers' businessPartnerId to the same as the above user.\n * Calls the createBusinessPartner to then create a new entitiy in the database with the\n * information passed into through newUser.\n * @param input\n * @param ctx\n */\nexport async function addOrganizationUser(input: AddOrganizationUserInput, ctx: IActionContext): Promise {\n const { user } = input;\n\n return getCurrentAsync({ callerContext: ctx })\n .then((businessPartner: BusinessPartner) => {\n // Set the new accounts businessPartnerId from the admin account\n user.BusinessPartnerId = businessPartner.BusinessPartnerId;\n\n return createBusinessPartnerUserAsync({ callerContext: ctx }, user)\n .then(newUser => {\n return newUser;\n })\n .catch(() => {\n ctx.telemetry.debug('[add-organization-user] Unable to create BusinessPartnerUser account');\n throw new Error('[add-organization-user] Unable to create BusinessPartnerUser account');\n });\n })\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[add-organization-user] Unable to get BusinessPartner Admin account');\n throw new Error('[add-organization-user] Unable to get BusinessPartner Admin account');\n });\n}\n\n/**\n * The addOrganizationUser data action\n * Calls the read RetailServer API to get the BusinessPartnerId from the admin\n * account and adds that businessPartner to the recieved input (new User)/\n * We then send this new User through the RetailServer API so that the database\n * is updated.\n */\nexport const addOrganizationUserDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/add-organization-user',\n action: >addOrganizationUser,\n input: <(args: ICreateActionContext) => IActionInput>(createAddOrganizationUserInput)\n});\n\nexport default addOrganizationUserDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IHTTPRequestOptions,\n IHTTPResponse,\n sendCommerceRequest\n} from '@msdyn365-commerce/core';\nimport { Address, CartTenderLine, SalesOrder } from '@msdyn365-commerce/retail-proxy';\n\n/**\n * Check Out action Input.\n */\nexport class CheckOutInput implements IActionInput {\n public cartId: string;\n\n public cartVersion: number;\n\n public receiptEmail?: string;\n\n public cartTenderLines?: CartTenderLine[];\n\n public billingAddress?: Address;\n\n constructor(cartId: string, cartVersion: number, receiptEmail?: string, cartTenderLines?: CartTenderLine[], billingAddress?: Address) {\n this.cartId = cartId;\n this.cartVersion = cartVersion;\n this.receiptEmail = receiptEmail;\n this.cartTenderLines = cartTenderLines;\n this.billingAddress = billingAddress;\n }\n\n public getCacheKey = () => `${this.cartId}-${this.cartVersion}`;\n\n public getCacheObjectType = () => 'CheckOut';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Calls the Retail API to check out and returns sales order.\n * @param input\n * @param ctx\n */\nexport async function checkOutAction(input: CheckOutInput, ctx: IActionContext): Promise {\n const { apiSettings } = ctx.requestContext;\n const requestUrl = `${apiSettings.baseUrl}Commerce/Carts('${input.cartId}')/Checkout?api-version=7.3`;\n const requestOptions: IHTTPRequestOptions = {\n headers: {\n oun: apiSettings.oun,\n 'Content-Type': 'application/json'\n }\n };\n\n if (requestOptions.headers && ctx.requestContext.user.token) {\n requestOptions.headers.Authorization = `id_token ${ctx.requestContext.user.token}`;\n }\n\n if (input.cartTenderLines && input.cartTenderLines.length > 0) {\n input.cartTenderLines = input.cartTenderLines.map((cartTenderLineItem: CartTenderLine) => {\n // @ts-expect-error\n cartTenderLineItem['@odata.type'] = '#Microsoft.Dynamics.Commerce.Runtime.DataModel.CartTenderLine';\n\n // @ts-expect-error\n cartTenderLineItem['Amount@odata.type'] = '#Decimal';\n\n if (cartTenderLineItem.TokenizedPaymentCard) {\n // @ts-expect-error\n cartTenderLineItem.TokenizedPaymentCard['@odata.type'] =\n '#Microsoft.Dynamics.Commerce.Runtime.DataModel.TokenizedPaymentCard';\n\n // Force the House prop to be set, so that call succeeds\n if (!cartTenderLineItem.TokenizedPaymentCard.House) {\n cartTenderLineItem.TokenizedPaymentCard.House = 'N/A';\n }\n\n if (cartTenderLineItem.TokenizedPaymentCard.CardTokenInfo) {\n // @ts-expect-error\n cartTenderLineItem.TokenizedPaymentCard.CardTokenInfo['@odata.type'] =\n '#Microsoft.Dynamics.Commerce.Runtime.DataModel.CardTokenInfo';\n }\n\n if (input.billingAddress) {\n const { Phone, ThreeLetterISORegionName = '', Street, City, State, ZipCode } = input.billingAddress;\n cartTenderLineItem.TokenizedPaymentCard = {\n ...cartTenderLineItem.TokenizedPaymentCard,\n Phone,\n Country: ThreeLetterISORegionName.toUpperCase(),\n Address1: Street,\n City,\n State,\n Zip: ZipCode\n };\n }\n }\n\n return cartTenderLineItem;\n });\n }\n\n const requestBody = {\n receiptEmail: input.receiptEmail,\n cartVersion: input.cartVersion || null,\n ...(input.cartTenderLines && { cartTenderLines: input.cartTenderLines })\n };\n\n // Perform check-out operation\n return sendCommerceRequest(requestUrl, 'post', requestBody, requestOptions).then((response: IHTTPResponse) => {\n if (response.status >= 200 && response.status < 300 && response.data) {\n return response.data;\n } else if (response.data) {\n throw response.data;\n }\n throw new Error('[checkOutAction] Invalid response recieved from RetailServer');\n });\n}\n\nexport const checkOutActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/checkout',\n action: >checkOutAction\n});\nexport default checkOutActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { ProductList, ProductListsDataActions } from '@msdyn365-commerce/retail-proxy';\n\n/**\n * Input class for the CreateProductList data action.\n */\nexport class CreateProductListInput implements IActionInput {\n public readonly templateName: string;\n\n public readonly templateType: number;\n\n public constructor(templateName: string, templateType: number) {\n this.templateName = templateName;\n this.templateType = templateType;\n }\n\n /**\n * GetCacheObjectType.\n * @returns - Returns string.\n */\n public getCacheKey = (): string => 'CreateProductListInput';\n\n /**\n * GetCacheKey.\n * @returns - Returns string.\n */\n public getCacheObjectType = (): string => 'CreateProductListInput';\n\n /**\n * DataCacheType.\n * @returns - CacheType string.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the CreateProductList method.\n * @param inputData - The input data passed to the createInput method.\n * @param templateName - The name of template.\n * @param templateType - The type of template.\n * @returns - The Action input.\n */\nexport const createProductListInput = (\n inputData: ICreateActionContext,\n templateName: string,\n templateType: number\n): CreateProductListInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create product list. User is not authenticated.');\n }\n return new CreateProductListInput(templateName, templateType);\n};\n\n/**\n * The action method for the CreateProductList data action.\n * @param input - The action input.\n * @param context - The action context.\n * @returns - ProductList object.\n */\nexport async function createProductListAction(input: CreateProductListInput, context: IActionContext): Promise {\n try {\n const orderTemplate: ProductList = {\n Id: '',\n Name: input.templateName,\n ProductListTypeValue: input.templateType\n };\n const createdProductList = await ProductListsDataActions.createProductListAsync(\n {\n callerContext: context\n },\n orderTemplate\n );\n if (createdProductList.Id !== '') {\n return createdProductList;\n }\n context.telemetry.error('Created product list was null');\n throw new Error('Created product list was null');\n } catch (error) {\n context.telemetry.error('Not able to create product list', error);\n throw error;\n }\n}\n\n/**\n * The CreateProductList Data Action.\n * Returns created Product List.\n */\nexport const createProductListActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/create-product-list',\n action: createProductListAction as IAction,\n input: createProductListInput\n});\n\nexport default createProductListActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext } from '@msdyn365-commerce/core';\nimport { Address, Customer } from '@msdyn365-commerce/retail-proxy';\n\nimport { createAddressManagementInput, doAddressManagementOperation, IAddressManagementInput } from './add-address';\n\nexport function deleteAddressHandler(customer: Customer, address: Address): Customer {\n customer.Addresses = customer.Addresses || [];\n customer.Addresses = [...customer.Addresses.filter(cur => cur.RecordId !== address.RecordId)];\n return customer;\n}\n\nexport async function deleteAddressAction(input: IAddressManagementInput, ctx: IActionContext): Promise {\n return doAddressManagementOperation(input, ctx, deleteAddressHandler);\n}\n\n/**\n * The deleteAddress data action\n * Calls the read RetailServer API to get information about a customer\n * Removes all address information from the retireved customer, and\n * then updates that customer via the update RetailServer API.\n */\nexport const deleteAddressActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/delete-address',\n action: >deleteAddressAction,\n input: <(args: ICreateActionContext) => IActionInput>(createAddressManagementInput),\n isBatched: false\n});\n\nexport default deleteAddressActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { BusinessPartnerUser, NullResult } from '@msdyn365-commerce/retail-proxy';\nimport { deleteAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/BusinessPartnerUsersDataActions.g';\n\n/**\n * Input class for DeleteOrganizationUser data action.\n */\nexport class DeleteOrganizationUserInput implements IActionInput {\n public user: BusinessPartnerUser;\n\n constructor(newUser: BusinessPartnerUser) {\n this.user = newUser;\n }\n\n public getCacheKey = () => 'DeleteOrganizationUser';\n\n public getCacheObjectType = () => 'DeleteOrganizationUser';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Input class for DeleteOrganizationUser data action.\n * @param inputData\n * @param newUser\n */\nexport const createDeleteOrganizationUserInput = (\n inputData: ICreateActionContext>,\n newUser: BusinessPartnerUser\n): IActionInput => {\n const { requestContext } = inputData;\n\n // Check if the user is authenticated.\n if (!requestContext.user.isAuthenticated) {\n throw new Error('User is not logged in.');\n }\n\n return new DeleteOrganizationUserInput(newUser);\n};\n\n/**\n * The DeleteOrganizationUser data action\n * Calls getCurrent() to get a businessPartnerId from the user requesting the action.\n * It then maps the newUsers' businessPartnerId to the same as the above user.\n * Calls the createBusinessPartner to then create a new entitiy in the database with the\n * information passed into through newUser.\n * @param input\n * @param ctx\n */\nexport async function deleteOrganizationUser(input: DeleteOrganizationUserInput, ctx: IActionContext): Promise {\n const { user } = input;\n\n return deleteAsync({ callerContext: ctx }, user).catch(error => {\n console.log(error);\n ctx.telemetry.debug('[Delete-organization-user] Unable to delete BusinessPartnerUser account');\n throw new Error('[Delete-organization-user] Unable to delete BusinessPartnerUser account');\n });\n}\n\n/**\n * The DeleteOrganizationUser data action\n * Calls the read RetailServer API to get the BusinessPartnerId from the admin\n * account and Deletes that businessPartner to the recieved input (new User)/\n * We then send this new User through the RetailServer API so that the database\n * is updated.\n */\nexport const deleteOrganizationUserDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/delete-organization-user',\n action: >deleteOrganizationUser,\n input: <(args: ICreateActionContext) => IActionInput>(createDeleteOrganizationUserInput)\n});\n\nexport default deleteOrganizationUserDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { BusinessPartnerUser } from '@msdyn365-commerce/retail-proxy';\nimport { updateAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/BusinessPartnerUsersDataActions.g';\n\n/**\n * Input class for edit organization user data action.\n */\nexport class EditOrganizationUserInput implements IActionInput {\n public user: BusinessPartnerUser;\n\n constructor(newUser: BusinessPartnerUser) {\n this.user = newUser;\n }\n\n public getCacheKey = () => 'EditOrganizationUser';\n\n public getCacheObjectType = () => 'EditOrganizationUser';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Input class for edit organization user data action.\n * @param inputData\n * @param newUser\n */\nexport const createEditOrganizationUserInput = (\n inputData: ICreateActionContext>,\n newUser: BusinessPartnerUser\n): IActionInput => {\n const { requestContext } = inputData;\n\n // Check if the user is authenticated.\n if (!requestContext.user.isAuthenticated) {\n throw new Error('User is not logged in.');\n }\n\n return new EditOrganizationUserInput(newUser);\n};\n\nexport async function editOrganizationUser(input: EditOrganizationUserInput, ctx: IActionContext): Promise {\n const { user } = input;\n\n return updateAsync({ callerContext: ctx }, user)\n .then(updatedUser => {\n return updatedUser;\n })\n .catch(() => {\n ctx.telemetry.debug('[Edit-organization-user] Unable to update BusinessPartnerUser account');\n throw new Error('[Edit-organization-user] Unable to update BusinessPartnerUser account');\n });\n}\n\n/**\n * The EditOrganizationUser data action\n * Takes in an instance of a BusinessPartnerUser and updates the\n * same user with the new information.\n */\nexport const editOrganizationUserDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/Edit-organization-user',\n action: >editOrganizationUser,\n input: <(args: ICreateActionContext) => IActionInput>(createEditOrganizationUserInput)\n});\n\nexport default editOrganizationUserDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CacheType, IActionContext, IActionInput } from '@msdyn365-commerce/core';\n\n/**\n * Generic input type for use with generic data actions.\n */\nexport class GenericInput implements IActionInput {\n public result: T;\n\n public cacheKey: string;\n\n public cacheObjectType: string;\n\n constructor(cacheKey: string, result: T, cacheObjectType: string) {\n this.cacheKey = cacheKey;\n this.cacheObjectType = cacheObjectType;\n this.result = result;\n }\n\n public getCacheKey = () => `Generic-${this.cacheKey}`;\n\n public getCacheObjectType = () => `${this.cacheObjectType}`;\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Generic data action that is just used for passing data around the app.\n *\n * Note that this doesn't actually expose a data action, its just a base action\n * that others can use to create a data action with their own input.\n * @param input\n * @param ctx\n */\nexport async function getGenericAction(input: GenericInput, ctx: IActionContext): Promise {\n return input.result;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { Address } from '@msdyn365-commerce/retail-proxy';\n\nimport getCustomer, { GetCustomerInput } from './get-customer';\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input class for the getAddress data action.\n */\nexport class AddressInput implements IActionInput {\n public userAccountNumber?: string;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, userAccountNumber?: string) {\n this.userAccountNumber = userAccountNumber;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey(`GetAddress-${this.userAccountNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'GetAddress';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the getAddress method.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createGetAddressInput = (inputData: ICreateActionContext): IActionInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create address input. User is not authenticated.');\n }\n\n return new AddressInput(inputData.requestContext.apiSettings);\n};\n\n/**\n * The action method for the getAddress data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function getAddressAction(input: AddressInput, ctx: IActionContext): Promise {\n const customerInput = new GetCustomerInput(ctx.requestContext.apiSettings, input.userAccountNumber);\n const customer = await getCustomer(customerInput, ctx);\n\n if (!customer) {\n throw new Error('Not able to get customer');\n }\n\n return customer.Addresses || [];\n}\n\n/**\n * The getAddress data action\n * Gets a customers information via the read RetailServer API\n * Returns address information associated with the retrieved customer.\n */\nexport const getAddressActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-address',\n action: >getAddressAction,\n input: <(args: ICreateActionContext) => IActionInput>createGetAddressInput\n});\n\nexport default getAddressActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getAttributeDefinitionsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\nimport { AttributeDefinition, AttributeDefinitionCriteria } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input class for get attribute definitions data action.\n */\nexport class GetAttributeDefinitionsInput implements IActionInput {\n public attributeDefinitionCriteria?: AttributeDefinitionCriteria;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, attributeDefinitionCriteria?: AttributeDefinitionCriteria) {\n this.attributeDefinitionCriteria = attributeDefinitionCriteria;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('AttributeDefinitions', this.apiSettings);\n\n public getCacheObjectType = () => 'CustomerAttribute';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nconst createInput = (inputData: ICreateActionContext>): GetAttributeDefinitionsInput => {\n const { apiSettings, channel } = inputData.requestContext;\n if (!channel || !channel.CustomerAttributeGroupId) {\n throw new Error('[getAttributeDefinitions][createInput]: Customer attribute group id is not found.');\n }\n\n return new GetAttributeDefinitionsInput(apiSettings, { AttributeGroupIdentifier: channel.CustomerAttributeGroupId });\n};\n\nconst getAttributeDefinitionsAction = async (input: GetAttributeDefinitionsInput, ctx: IActionContext): Promise => {\n if (input && ctx.requestContext.channel && ctx.requestContext.channel.CustomerAttributeGroupId) {\n return getAttributeDefinitionsAsync({ callerContext: ctx }, input.attributeDefinitionCriteria || null).then(response => {\n return response;\n });\n }\n\n ctx.trace('[getAttributeDefinitions]Invalid input passed to action');\n return [];\n};\n\nexport const getAttributeDefinitionsActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-custom-attributes',\n action: >getAttributeDefinitionsAction,\n input: createInput\n});\n\nexport default getAttributeDefinitionsActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { AttributeValue, SimpleProduct } from '@msdyn365-commerce/retail-proxy';\nimport { getAttributeValuesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport { getSelectedProductIdFromActionInput, SelectedVariantInput } from '.';\nimport { getSelectedVariantActionDataAction } from './get-selected-variant';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Chains getting the SelectedVariant with GetActivePrice.\n */\nexport class AttributesForSelectedVariantInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public catalogId: number;\n\n public selectedProduct: SimpleProduct | undefined;\n\n constructor(productId: number, channelId: number, selectedProduct?: SimpleProduct, catalogId?: number) {\n this.productId = productId;\n this.channelId = channelId;\n this.selectedProduct = selectedProduct;\n this.catalogId = catalogId || 0;\n }\n\n public getCacheKey = () => 'AttributesForSelectedVariant';\n\n public getCacheObjectType = () => 'ProductAttributeValue';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\nexport const createAttributesForSelectedVariantInput = (\n inputData: ICreateActionContext>\n): AttributesForSelectedVariantInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n const catalogId = getCatalogId(inputData.requestContext);\n\n if (productId) {\n return new AttributesForSelectedVariantInput(+productId, +inputData.requestContext.apiSettings.channelId, undefined, catalogId);\n }\n throw new Error('Unable to create PriceForSelectedVariantInput, no productId found on module config or query');\n};\n\n/**\n * Calls the Retail API a get a list of dimension values for a given product.\n * @param input\n * @param ctx\n */\nexport async function getAttributesForSelectedVariantAction(\n input: AttributesForSelectedVariantInput,\n ctx: IActionContext\n): Promise {\n return Promise.resolve()\n .then(() => {\n const activeProduct: SimpleProduct | undefined = input.selectedProduct;\n\n if (!activeProduct) {\n const selectedVariantInput = new SelectedVariantInput(\n input.productId,\n input.channelId,\n undefined,\n undefined,\n ctx.requestContext\n );\n\n return getSelectedVariantActionDataAction(selectedVariantInput, ctx);\n }\n\n return activeProduct;\n })\n .then((productResult: SimpleProduct | null) => {\n const activeProduct: SimpleProduct | undefined = productResult;\n\n if (activeProduct) {\n return getAttributeValuesAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n activeProduct.RecordId,\n input.channelId,\n input.catalogId\n );\n }\n\n return null;\n })\n .then((attributeValues: AttributeValue[] | null) => {\n const resultArray = attributeValues;\n if (resultArray) {\n return resultArray;\n }\n\n return [];\n })\n .catch((error: Error) => {\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getPriceForSelectedVariantAction]Error executing action');\n throw new Error('[getPriceForSelectedVariantAction]Error executing action');\n });\n}\n\nexport const getAttributesForSelectedVariantActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-attributes-for-selected-variant',\n action: >getAttributesForSelectedVariantAction,\n input: createAttributesForSelectedVariantInput\n});\n\nexport default getAttributesForSelectedVariantActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { CartLine, ChannelDeliveryOptionConfiguration, FeatureState, ProductWarehouse } from '@msdyn365-commerce/retail-proxy';\nimport { getOrgUnitConfigurationAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/OrgUnitsDataActions.g';\nimport {\n getEstimatedAvailabilityAsync,\n getEstimatedProductWarehouseAvailabilityAsync\n} from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport { getChannelDeliveryOptionConfigurationAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\n\nimport {\n ActiveCartProductsInput,\n ArrayExtensions,\n buildCacheKey,\n createInventoryAvailabilitySearchCriteria,\n getActiveCartProductsAction,\n IProductInventoryInformation,\n mapAggregatedProductInventoryInformation,\n mapProductInventoryInformation\n} from '.';\nimport { FeatureStateInput, getFeatureStateActionDataAction } from './get-feature-state';\n\n/**\n * Input class for availabilities for items in cart.\n */\nexport class ProductAvailabilitiesForCartLineItems implements IActionInput {\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings) {\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('ActiveCartLineItemsAvailability', this.apiSettings);\n\n public getCacheObjectType = () => 'ActiveCartLineItemsAvailability';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\nconst createInput = (inputData: ICreateActionContext>) => {\n return new ProductAvailabilitiesForCartLineItems(inputData.requestContext.apiSettings);\n};\n\n/**\n * Calls the Retail Feature State API and returns a list of feature with isEnabled flag.\n * @param cartLine\n * @param featureSate\n * @param channelDeliveryOptionConfig\n * @param pickupDeliveryMode\n */\nconst getDeliveryMode = (\n cartLine: CartLine,\n featureSate: boolean = false,\n channelDeliveryOptionConfig: ChannelDeliveryOptionConfiguration,\n pickupDeliveryMode?: string\n) => {\n if (!featureSate) {\n return cartLine.DeliveryMode === pickupDeliveryMode;\n }\n return (\n cartLine.DeliveryMode ===\n channelDeliveryOptionConfig?.PickupDeliveryModeCodes?.find(deliveryMode => deliveryMode === cartLine.DeliveryMode)\n );\n};\n\n/**\n * Calls the Retail API to get the product availabilities for items in the cart.\n * @param input\n * @param ctx\n */\n// eslint-disable-next-line complexity\nexport async function getAvailabilitiesForCartLineItems(\n input: ProductAvailabilitiesForCartLineItems,\n ctx: IActionContext\n): Promise {\n // If no input is provided fail out\n if (!input) {\n throw new Error('[getAvailabilitiesForCartLineItems]No valid Input was provided, failing');\n }\n\n const shippingItems: CartLine[] = [];\n const bopisItems = [];\n let productAvailabilities: IProductInventoryInformation[] = [];\n const multiplePickupStoreSwitchName = 'Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature';\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let channelDeliveryOptionConfig: any;\n\n const cartState = await getCartState(ctx);\n const cart = cartState.cart;\n const channelConfiguration = await getOrgUnitConfigurationAsync({ callerContext: ctx });\n const products = await getActiveCartProductsAction(new ActiveCartProductsInput(), ctx);\n\n /**\n * Calls the Retail Feature State API and returns a list of feature with isEnabled flag.\n * @param context\n */\n async function getFeatureState(context: IActionContext): Promise {\n return getFeatureStateActionDataAction(new FeatureStateInput(), context);\n }\n const featureState = await getFeatureState(ctx);\n const retailMultiplePickUpOptionEnabled = featureState?.find(item => item.Name === multiplePickupStoreSwitchName)?.IsEnabled;\n if (retailMultiplePickUpOptionEnabled) {\n channelDeliveryOptionConfig = await getChannelDeliveryOptionConfigurationAsync({ callerContext: ctx });\n }\n const PickupDeliveryModeCode = channelConfiguration.PickupDeliveryModeCode;\n const EmailDeliveryModeCode = channelConfiguration.EmailDeliveryModeCode;\n\n if (!cart || !channelConfiguration || !products || products.length === 0) {\n ctx.trace('[getAvailabilitiesForCartLineItems] Not able to get cart OR channelConfiguration or no products in cart');\n return [];\n }\n\n if (cart && cart.Id && cart.CartLines && cart.CartLines.length > 0 && channelConfiguration) {\n for (const cartLine of cart.CartLines) {\n if (\n cartLine.DeliveryMode &&\n cartLine.DeliveryMode !== '' &&\n getDeliveryMode(cartLine, retailMultiplePickUpOptionEnabled, channelDeliveryOptionConfig, PickupDeliveryModeCode)\n ) {\n bopisItems.push(cartLine);\n } else if (EmailDeliveryModeCode === '' || cartLine.DeliveryMode !== EmailDeliveryModeCode) {\n shippingItems.push(cartLine);\n }\n }\n }\n\n if (shippingItems && shippingItems.length > 0) {\n let productIds = shippingItems.map(x => x.ProductId!);\n productIds = ArrayExtensions.unique(productIds);\n const searchCriteria = createInventoryAvailabilitySearchCriteria(ctx, productIds, true);\n const shippingProductAvailabilities = await getEstimatedAvailabilityAsync(\n { callerContext: ctx, bypassCache: 'get' },\n searchCriteria\n );\n\n if (\n shippingProductAvailabilities &&\n shippingProductAvailabilities.ProductWarehouseInventoryAvailabilities &&\n shippingProductAvailabilities.ProductWarehouseInventoryAvailabilities.length > 0\n ) {\n productAvailabilities = mapAggregatedProductInventoryInformation(ctx, shippingProductAvailabilities);\n }\n }\n\n if (bopisItems && bopisItems.length > 0) {\n const productWarehouses: ProductWarehouse[] = [];\n\n for (const bopisItem of bopisItems) {\n const productWarehouse: ProductWarehouse = {\n ProductId: bopisItem.ProductId,\n InventLocationId: bopisItem.WarehouseId\n };\n\n if (ctx.requestContext.channel && ctx.requestContext.channel.InventLocationDataAreaId) {\n productWarehouse.DataAreaId = ctx.requestContext.channel.InventLocationDataAreaId;\n }\n productWarehouses.push(productWarehouse);\n }\n const quantityUnitTypeSales: number = 2;\n const getProductWarehouseAvail = await getEstimatedProductWarehouseAvailabilityAsync(\n { callerContext: ctx, bypassCache: 'get', queryResultSettings: {} },\n productWarehouses,\n quantityUnitTypeSales\n );\n\n if (\n getProductWarehouseAvail &&\n getProductWarehouseAvail.ProductWarehouseInventoryAvailabilities &&\n getProductWarehouseAvail.ProductWarehouseInventoryAvailabilities.length > 0\n ) {\n const productWarehouseMapping = mapProductInventoryInformation(\n ctx,\n getProductWarehouseAvail?.ProductWarehouseInventoryAvailabilities\n );\n if (productWarehouseMapping && productWarehouseMapping.length > 0) {\n for (const item of productWarehouseMapping) {\n productAvailabilities.push(item);\n }\n }\n }\n }\n\n if (productAvailabilities && productAvailabilities.length > 0) {\n return productAvailabilities;\n }\n\n ctx.trace('[getAvailabilitiesForCartLineItems] unable to get availabilities for product');\n return [];\n}\n\nexport const getAvailabilitiesForCartLineItemsDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-availabilities-cartlines',\n action: >getAvailabilitiesForCartLineItems,\n input: createInput\n});\n\nexport default getAvailabilitiesForCartLineItemsDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport { CatalogsDataActions, ProductCatalog } from '@msdyn365-commerce/retail-proxy';\n\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input for get-catalogs data action.\n */\nexport class CatalogsInput implements IActionInput {\n public readonly channelId: number;\n\n public readonly customerAccountNumber?: string;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n private readonly locale?: string;\n\n public constructor(context: IRequestContext, customerAccountNumber?: string) {\n this.channelId = context.apiSettings.channelId ? Number(context.apiSettings.channelId) : 0;\n this.customerAccountNumber = customerAccountNumber ? customerAccountNumber : context.user.customerAccountNumber;\n this.apiSettings = context.apiSettings;\n this.locale = context.locale || '';\n }\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- customer account number can be undefined.\n public getCacheKey = (): string => buildCacheKey(`${this.channelId}|${this.customerAccountNumber}`, this.apiSettings, this.locale);\n\n /**\n * Get Cache object type.\n * @returns - Cache object type.\n */\n public getCacheObjectType = (): string => 'productCatalogs';\n\n /**\n * Get data cache type.\n * @returns - Cache type enum.\n */\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData - The input data passed to the createInput method.\n * @param customerAccountNumber - Customer account number.\n * @returns - Catalogs input.\n */\nexport const createCatalogsInput = (inputData: ICreateActionContext>, customerAccountNumber?: string): IActionInput => {\n if (!inputData.requestContext.user.isAuthenticated) {\n throw new Error('Unable to get product catalog. User is not authenticated.');\n }\n return new CatalogsInput(inputData.requestContext, customerAccountNumber);\n};\n\n/**\n * Calls the Retail API and returns the product catalog for an user.\n * @param input - Catalogs Input.\n * @param context - Current context.\n * @returns - Product catalog for the user.\n */\nexport async function getCatalogAction(input: CatalogsInput, context: IActionContext): Promise {\n const productCatalogs = await CatalogsDataActions.getCatalogsAsync(\n { callerContext: context, bypassCache: 'getAndPut' },\n input.channelId,\n true\n );\n return productCatalogs;\n}\n\n/**\n * The GetProductCatalogs Data Action\n * Returns product catalogs.\n */\nexport const getCatalogActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-catalogs',\n action: getCatalogAction as IAction,\n input: createCatalogsInput\n});\n\nexport default getCatalogActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport { Category, TextValueTranslation } from '@msdyn365-commerce/retail-proxy';\n\nimport getCategoryAction, { CategoriesInput as RawCategoriesInput } from './get-categories';\nimport { getCategoryUrl } from './utilities/Url-builder';\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input for get-categories data action.\n */\nexport class CategoriesInput implements IActionInput {\n public readonly maxItems: number;\n\n public readonly channelId: number;\n\n private readonly catalogId: number;\n\n private readonly sitePath: string;\n\n private readonly _mappedToHierarchy: boolean;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n private readonly locale?: string;\n\n public constructor(context: IRequestContext, mappedToHierarchy: boolean, maxItems?: number) {\n this._mappedToHierarchy = mappedToHierarchy;\n this.maxItems = maxItems || 250;\n this.channelId = context && context.apiSettings && context.apiSettings.channelId ? +context.apiSettings.channelId : 0;\n this.sitePath = (context && context.sitePath) || '';\n this.apiSettings = context.apiSettings;\n this.locale = context.locale || '';\n this.catalogId = getCatalogId(context);\n }\n\n public getCacheKey = () =>\n buildCacheKey(`${this.channelId}|${this.sitePath}|top-${this.maxItems || 250} | ${this.catalogId}`, this.apiSettings, this.locale);\n\n public getCacheObjectType = () => (this._mappedToHierarchy ? 'CategoryHierarchy' : 'Category');\n\n public dataCacheType = (): CacheType => 'request';\n\n public getLocale = (): string => this.locale || '';\n}\n\nconst getFriendlyName = (locale?: string, nameTranslations?: TextValueTranslation[]): string | undefined => {\n let nameTranslation: TextValueTranslation | undefined;\n if (locale && nameTranslations && nameTranslations.length > 0) {\n nameTranslation = nameTranslations.find(item => item.Language!.toLowerCase() === locale.toLowerCase());\n }\n\n return nameTranslation && nameTranslation.Text;\n};\n\nexport interface ICategoryMap {\n [RecordId: number]: CategoryHierarchy;\n}\n\n/**\n * Creates a hierarchy of categories based on the ParentCategory property.\n * @param categoryList Categories that will be converted into a hierarchy.\n * @param ctx\n * @param locale\n * @returns Hierarchy of categories in array.\n */\nexport const mapCategoryToHierarchy = (categoryList: Category[], ctx: IActionContext, locale?: string): CategoryHierarchy[] => {\n if (!categoryList || categoryList.length === 0) {\n return [];\n }\n\n const categoryMap: ICategoryMap = categoryList.reduce((memo: ICategoryMap, category: Category) => {\n const localName = getFriendlyName(locale, category.NameTranslations);\n const categoryHierarchy = { ...category };\n categoryHierarchy.NeutralizedName = category.Name;\n categoryHierarchy.Name = localName || categoryHierarchy.NeutralizedName;\n memo[category.RecordId] = categoryHierarchy;\n return memo;\n }, {});\n\n let zeroCategory = categoryMap[0];\n\n Object.keys(categoryMap).forEach((id: string) => {\n const element = categoryMap[+id];\n const parentId = element.ParentCategory;\n element.Url = getCategoryUrl(element, ctx, categoryMap);\n if (parentId === 0) {\n zeroCategory = element;\n return;\n }\n\n const parent = parentId && categoryMap[parentId];\n if (parent) {\n parent.Children = parent.Children || [];\n parent.Children.push(element);\n }\n });\n\n return (zeroCategory && zeroCategory.Children) || [];\n};\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nexport const createCategoriesHierarchyInput = (inputData: ICreateActionContext>): IActionInput => {\n const topItems = inputData.config && inputData.config.topCategories && Number.parseInt(inputData.config.topCategories, 10);\n return new CategoriesInput(inputData.requestContext, true, topItems);\n};\n\n/**\n * Calls the Retail API and returns all the categories as a hierarchy.\n * @param input\n * @param ctx\n */\nexport async function getCategoryHierarchyAction(input: CategoriesInput, ctx: IActionContext): Promise {\n const categories = await getCategoryAction(new RawCategoriesInput(ctx.requestContext, false, input.maxItems), ctx);\n return mapCategoryToHierarchy(categories, ctx, input.getLocale());\n}\n\nexport const getCategoryHierarchyActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-categories-hierarchy',\n action: >getCategoryHierarchyAction,\n input: createCategoriesHierarchyInput\n});\n\nexport default getCategoryHierarchyActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport { CategoriesDataActions } from '@msdyn365-commerce/retail-proxy';\n\n/**\n * Input for get-categories data action.\n */\nexport class CategoriesInput implements IActionInput {\n public readonly maxItems: number;\n\n public readonly channelId: number;\n\n public readonly catalogId?: number;\n\n private readonly _mappedToHierarchy: boolean;\n\n public constructor(context: IRequestContext, mappedToHierarchy: boolean, maxItems?: number) {\n this._mappedToHierarchy = mappedToHierarchy;\n this.maxItems = maxItems || 250;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Required.\n this.channelId = context?.apiSettings?.channelId ? Number(context.apiSettings.channelId) : 0;\n this.catalogId = getCatalogId(context);\n }\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n public getCacheKey = (): string => `${this.channelId}|top-${this.maxItems || 250}|${this.catalogId ?? 0}`;\n\n /**\n * Get Cache type Name.\n * @returns - Cache name string.\n */\n public getCacheObjectType = (): string => (this._mappedToHierarchy ? 'CategoryHierarchy' : 'Category');\n\n /**\n * Get Cache type.\n * @returns - CacheType enum.\n */\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData -- Input data.\n * @returns -- IActionInput.\n */\nexport const createCategoriesInput = (inputData: ICreateActionContext>): IActionInput => {\n const topItems = inputData.config?.topCategories && Number.parseInt(inputData.config.topCategories, 10);\n return new CategoriesInput(inputData.requestContext, false, topItems);\n};\n\n/**\n * Calls the Retail API and returns all the categories as a flat list.\n * @param input - Input.\n * @param ctx - Context.\n * @returns - CategoryHierarchy.\n */\nexport async function getCategoryAction(input: CategoriesInput, ctx: IActionContext): Promise {\n return ((await CategoriesDataActions.getCategoriesAsync(\n {\n callerContext: ctx\n },\n input.channelId,\n input.catalogId\n )) as unknown) as CategoryHierarchy[];\n}\n\n/**\n * The getCategory Data Action.\n */\nexport const getCategoryActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-categories',\n action: getCategoryAction as IAction,\n input: createCategoriesInput\n});\n\nexport default getCategoryActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n getCategoriesUrlSync,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport { ICategoryPath, ICategoryUrl } from '@msdyn365-commerce/core-internal/dist/types/interfaces/ICategoryPathInterfaces';\nimport { getCategoryPathsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport { CategoryPathLookup } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { buildCacheKey, getSelectedProductIdFromActionInput } from './utilities/utils';\n\n/**\n * Category path input.\n */\nexport class GetCategoryPathsInput implements IActionInput {\n public readonly ChannelId: number;\n\n public readonly CatalogId: number;\n\n public readonly categoryPathLooksups: CategoryPathLookup[];\n\n public readonly apiSettings: ICommerceApiSettings;\n\n private readonly locale: string;\n\n private constructedCacheKey: string;\n\n public constructor(context: IRequestContext, categoryPathLooksups: CategoryPathLookup[]) {\n this.ChannelId = context.apiSettings.channelId;\n this.CatalogId = getCatalogId(context);\n this.categoryPathLooksups = categoryPathLooksups;\n this.apiSettings = context.apiSettings;\n this.constructedCacheKey = '';\n categoryPathLooksups.forEach(categoryPath => {\n this.constructedCacheKey += `${categoryPath.ProductId && categoryPath.ProductId.toString()}|`;\n });\n this.constructedCacheKey += `${this.ChannelId.toString()}|`;\n this.constructedCacheKey += `${this.CatalogId.toString()}|`;\n this.locale = context.locale;\n }\n\n public getCacheKey = () => buildCacheKey(this.constructedCacheKey, this.apiSettings, this.locale);\n\n public getCacheObjectType = () => 'CategoryPath';\n\n public dataCacheType = (): CacheType => 'request';\n\n /**\n * Retrieves locale to use for the current API call.\n * @returns A string which represents locale.\n */\n public getLocale = (): string => this.locale;\n}\n\n/**\n * Creates the input required to make the getCategoryPath retail api call.\n * @param inputData\n */\nexport const createGetCategoryPathsInput = (inputData: ICreateActionContext>): IActionInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n if (productId) {\n return new GetCategoryPathsInput(inputData.requestContext, [{ ProductId: +productId }]);\n }\n throw new Error('Unable to create SelectedVariantInput, no productId found on module config or query');\n};\n\n/**\n * Calls the Retail API and returns the category path for a product.\n * @param input\n * @param ctx\n */\nexport async function getCategoryPathsAction(input: GetCategoryPathsInput, ctx: IActionContext): Promise {\n const categoryPathResults = await getCategoryPathsAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n input.ChannelId,\n input.CatalogId,\n input.categoryPathLooksups\n );\n const categoryPath = categoryPathResults[0].CategoryPath && categoryPathResults[0].CategoryPath[0];\n const categoryUrl = getCategoriesUrlSync(categoryPath, ctx);\n if (categoryUrl) {\n /* Do not return the root category of the product*/\n return categoryUrl.slice(1);\n }\n return [];\n}\n\nexport const getCategoryPathsActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-category-paths',\n action: >getCategoryPathsAction,\n input: createGetCategoryPathsInput\n});\n\nexport default getCategoryPathsActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { ChannelDeliveryOptionConfiguration } from '@msdyn365-commerce/retail-proxy';\nimport { getChannelDeliveryOptionConfigurationAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\n\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input class for get channel delivery option configuration data action.\n */\nexport class GetChannelDeliveryConfigurationInput implements IActionInput {\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, accountNumber?: string) {\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('ChannelDeliveryConfiguration', this.apiSettings);\n\n public getCacheObjectType = () => 'ChannelDeliveryConfiguration';\n\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nconst createInput = (inputData: ICreateActionContext>): GetChannelDeliveryConfigurationInput => {\n const { apiSettings } = inputData.requestContext;\n if (!apiSettings) {\n throw new Error('[getChannelDeliveryOptionConfiguration][createInput]: API setting not available.');\n }\n\n return new GetChannelDeliveryConfigurationInput(apiSettings);\n};\n\nconst getChannelDeliveryOptionConfigurationAction = async (\n input: GetChannelDeliveryConfigurationInput,\n ctx: IActionContext\n): Promise => {\n if (input) {\n return getChannelDeliveryOptionConfigurationAsync({ callerContext: ctx }).then(response => {\n return response;\n });\n }\n\n ctx.trace('[get-channel-delivery-option-configuration]Invalid input passed to action');\n return {};\n};\n\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-channel-delivery-option-configuration',\n action: >getChannelDeliveryOptionConfigurationAction,\n input: createInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings,\n ICreateActionContext,\n msdyn365Commerce\n} from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { Cart } from '@msdyn365-commerce/retail-proxy';\nimport { copyAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CartsDataActions.g';\nimport Cookie from 'js-cookie';\n\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input class for getCheckoutCart data action.\n */\nexport class GetCheckoutCartInput implements IActionInput {\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings) {\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('ActiveCheckoutCart', this.apiSettings);\n\n public getCacheObjectType = () => 'ActiveCheckoutCart';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\nconst createInput = (inputData: ICreateActionContext) => {\n return new GetCheckoutCartInput(inputData.requestContext.apiSettings);\n};\n\nconst CartCookieName: string = msdyn365Commerce.CartCookie || 'cart';\n\n/**\n * Data action to copy the cart for checkout actions.\n * @param input\n * @param ctx\n */\nexport async function getCheckoutCart(input: GetCheckoutCartInput, ctx: IActionContext): Promise {\n const cartId = Cookie.get(CartCookieName) || '';\n if (cartId) {\n const currentCartState = await getCartState(ctx);\n const activeCart = currentCartState.cart;\n\n // Check if there is an active cart and it isn't empty\n if (activeCart && Object.keys(activeCart).length > 0) {\n const checkoutCart = await copyAsync({ callerContext: ctx }, activeCart.Id, 2);\n\n if (checkoutCart) {\n return Array.isArray(checkoutCart) ? checkoutCart[0] : checkoutCart;\n }\n } else {\n ctx.trace(\"[get-checkout-cart] Can't create a checkout cart since active cart is empty\");\n }\n }\n\n return {};\n}\n\nexport const getCheckoutCartDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-checkout-cart',\n action: >getCheckoutCart,\n input: createInput\n});\n\nexport default getCheckoutCartDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport {\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\n\nimport getCategoriesHierarchy, { CategoriesInput } from './get-categories-hierarchy';\nimport { ArrayExtensions } from './utilities';\n\n/**\n * Action Input Class for get-current-category-hierarchy.\n */\nexport class CurrentCategoryHierarchyInput extends CategoriesInput {\n public activeCategoryId: number;\n\n public constructor(context: IRequestContext, mappedToHierarchy: boolean, maxItems?: number, activeCategoryId?: number) {\n super(context, mappedToHierarchy, maxItems);\n const defaultActiveCategoryId = 0;\n this.activeCategoryId = activeCategoryId ?? defaultActiveCategoryId;\n }\n\n // @ts-expect-error: Overriding cache object type\n public getCacheObjectType = () => 'CurrentCategoryHierarchy';\n\n public getCacheKey = () => `${this.activeCategoryId}-${this.channelId}`;\n}\n\n/**\n * Creates the input required for the data action.\n * @param inputData\n */\nexport const createCategoriesHierarchyInput = (inputData: ICreateActionContext>): IActionInput => {\n const topItems = inputData.config?.topCategories && Number.parseInt(inputData.config.topCategories, 10);\n let activeCategoryId =\n inputData.requestContext.urlTokens.pageType === 'Category' ? inputData.requestContext.urlTokens.itemId : undefined;\n activeCategoryId = activeCategoryId ?? inputData.requestContext.query?.categoryId;\n const activeCategoryParsedId = activeCategoryId ? Number.parseInt(activeCategoryId, 10) : undefined;\n\n return new CurrentCategoryHierarchyInput(inputData.requestContext, true, topItems, activeCategoryParsedId);\n};\n\n/**\n * Finds the given category in the list of categories and returns an array with the info on where it's located.\n * @param categories - Categories list to search from.\n * @param categoryId - The category id to find.\n * @returns A list of categories starting from the given category id, ending up the root parent.\n */\nconst findCategoryHierarchy = (categories: CategoryHierarchy[], categoryId: number): CategoryHierarchy[] | null => {\n for (const category of categories) {\n if (category.RecordId === categoryId) {\n return [category];\n }\n\n if (ArrayExtensions.hasElements(category.Children)) {\n const innerCategoryHierarchy = findCategoryHierarchy(category.Children, categoryId);\n if (ArrayExtensions.hasElements(innerCategoryHierarchy)) {\n innerCategoryHierarchy.push(category);\n return innerCategoryHierarchy;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the hierarchy of categories that are currently active as a parent -> child array.\n * Return will be as follows: [ParentCategory, Child, SubChild, SubSubChild].\n * @param input\n * @param ctx\n */\nexport async function getCurrentCategoryHierarchyAction(\n input: CurrentCategoryHierarchyInput,\n ctx: IActionContext\n): Promise {\n const fullCategoryHierarchy = await getCategoriesHierarchy(new CategoriesInput(ctx.requestContext, true, input.maxItems), ctx);\n const categoryArray = findCategoryHierarchy(fullCategoryHierarchy, input.activeCategoryId) ?? [];\n const sortedCategoryArray = categoryArray.reverse();\n return sortedCategoryArray;\n}\n\nexport const getCurrentCategoryHierarchyActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-current-category-hierarchy',\n action: getCurrentCategoryHierarchyAction as IAction,\n input: createCategoriesHierarchyInput\n});\n\nexport default getCurrentCategoryHierarchyActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getParameterizeFeatureFlags,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric,\n IParameterizeFeatureFlags,\n IRequestContext\n} from '@msdyn365-commerce/core';\n\nimport { buildCacheKey } from '.';\nimport getCategoryHierarchy, { CategoriesInput } from './get-categories-hierarchy';\nimport { parameterize } from './utilities/Url-builder';\n\n/**\n * Input class for GetCurrentCategory data action.\n */\nexport class CurrentCategoryInput implements IActionInput {\n public categoryId?: number;\n\n public categorySlug?: string;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n private readonly locale?: string;\n\n constructor(context: IRequestContext) {\n let categoryId;\n let categorySlug;\n if (context.query && context.query.categoryId) {\n categoryId = Number(context.query.categoryId);\n\n if (Number.isNaN(categoryId)) {\n throw new Error('Failed to cast category id into a number.');\n }\n } else if (context.urlTokens && context.urlTokens.recordId) {\n categoryId = Number(context.urlTokens.recordId);\n if (Number.isNaN(categoryId)) {\n throw new Error('Failed to cast category id into a number.');\n }\n } else if (context.urlTokens && context.urlTokens.categories && context.urlTokens.categories.length > 0) {\n const categories: string[] = (context.urlTokens.categories);\n\n if (categories.length === 0) {\n throw new Error('Failed to get category name from urlTokens');\n }\n\n // TODO: fix getParameterizeFeatureFlags to take requestContext as input.\n const tempActionContext = {\n requestContext: context\n };\n categorySlug = `/${categories\n .map(category => {\n // @ts-expect-error TODO: fix getParameterizeFeatureFlags to take requestContext as an input\n const parameterizeFeatureFlags: IParameterizeFeatureFlags = getParameterizeFeatureFlags(tempActionContext);\n return parameterize(category, undefined, parameterizeFeatureFlags);\n })\n .join('/')}`;\n }\n this.categoryId = categoryId;\n this.categorySlug = categorySlug;\n this.apiSettings = context.apiSettings;\n this.locale = context.locale || '';\n }\n\n public getCacheKey = () => buildCacheKey(`${this.categoryId || this.categorySlug}`, this.apiSettings, this.locale);\n\n public getCacheObjectType = () => 'Current-Category';\n\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * Creates a current category input from an ICreateActionContext.\n * @param inputData\n */\nexport const createGetCurrentCategoryInput = (inputData: ICreateActionContext>): IActionInput => {\n if (inputData && inputData.requestContext) {\n return new CurrentCategoryInput(inputData.requestContext);\n }\n\n throw new Error('Please specify categoryId query string in request.');\n};\n\n/**\n * Rescrusive Search Method to find a given category amongts a complete CategoryHierarcy.\n * @param categories The current Category Hierarchy.\n * @param categorySlug The category slug being searched for.\n * @param categoryId The category Id being search for.\n */\nexport function searchCategory(categories: CategoryHierarchy[], categorySlug?: string, categoryId?: number): CategoryHierarchy | undefined {\n let foundCategory;\n categories.forEach((cat: CategoryHierarchy) => {\n if ((categoryId && cat.RecordId === categoryId) || (categorySlug && cat.Slug === categorySlug)) {\n return (foundCategory = cat);\n } else if (cat.Children && cat.Children.length > 0) {\n const matchingChild = searchCategory(cat.Children, categorySlug, categoryId);\n if (matchingChild) {\n foundCategory = matchingChild;\n }\n }\n });\n return foundCategory;\n}\n\n/**\n * Action method for the getCurrentCategory Data Action.\n * @param input The action input class.\n * @param ctx The action context.\n */\nexport async function getCurrentCategoryAction(input: CurrentCategoryInput, ctx: IActionContext): Promise {\n if (input.categorySlug || input.categoryId) {\n const categoryInput = new CategoriesInput(ctx.requestContext, true);\n const categories = await getCategoryHierarchy(categoryInput, ctx);\n if (!categories) {\n ctx.trace('[getCurrentCategory] Unable to get categories from server');\n return;\n }\n\n const category = searchCategory(categories, input.categorySlug, input.categoryId);\n if (!category) {\n ctx.trace('[getCurrentCategory] Unable to find category');\n return;\n }\n return category;\n }\n}\n\n/**\n * The getCurrentCategory data action\n * First makes a call to the getCategories RetailServer API\n * to get a list of every available category, then returns a CategoryHierarchy\n * based on the categoryId query param set in the URL of the request.\n */\nexport const getCurrentCategoryActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-current-category',\n action: >getCurrentCategoryAction,\n input: createGetCurrentCategoryInput\n});\n\nexport default getCurrentCategoryActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { CustomerBalances } from '@msdyn365-commerce/retail-proxy';\nimport { getCustomerBalanceAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\n\nimport { buildCacheKey } from '.';\nimport getCustomer, { GetCustomerInput } from './get-customer';\n\n/**\n * Input class for the GetCustomerBalance data action.\n */\nexport class GetCustomerBalanceInput implements IActionInput {\n public customerAccountNumber?: string;\n\n public apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, customerAccountNumber?: string) {\n this.customerAccountNumber = customerAccountNumber;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey(`CustomerBalance-${this.customerAccountNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'GetCustomerBalance';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the GetCustomerBalance method.\n * @param inputData The input data passed to the createInput method.\n */\n\nexport const createGetCustomerBalanceInput = (inputData: ICreateActionContext): GetCustomerBalanceInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create get customer balance input. User is not authenticated.');\n }\n\n return new GetCustomerBalanceInput(requestContext.apiSettings);\n};\n\n/**\n * The action method for the GetCustomerBalance data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function getCustomerBalanceAction(input: GetCustomerBalanceInput, ctx: IActionContext): Promise {\n const customerInput = new GetCustomerInput(input.apiSettings, input.customerAccountNumber);\n const customer = await getCustomer(customerInput, ctx);\n\n if (!customer) {\n ctx.telemetry.error('Not able to get customer', new Error('Not able to get customer'));\n }\n\n return getCustomerBalanceAsync(\n {\n callerContext: ctx,\n queryResultSettings: {}\n },\n customer.AccountNumber,\n customer.InvoiceAccount\n );\n}\n\n/**\n * The GetCustomerBalance data action\n * Returns the customer's balance.\n */\nexport const getCustomerBalanceActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-customer-balance',\n action: >getCustomerBalanceAction,\n input: <(args: ICreateActionContext) => IActionInput>createGetCustomerBalanceInput\n});\n\nexport default getCustomerBalanceActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { createObservableDataAction, IAction, IActionInput, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { LoyaltyCard, retailAction } from '@msdyn365-commerce/retail-proxy';\nimport { createGetCustomerLoyaltyCardsInput } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nconst createCustomerLoyaltyCardsInput = (inputData: ICreateActionContext>): IActionInput => {\n if (inputData.requestContext && inputData.requestContext.user && inputData.requestContext.user.isAuthenticated) {\n return createGetCustomerLoyaltyCardsInput({}, null);\n }\n\n throw new Error('Unable to create order history input. User is not authenticated.');\n};\n\nexport const retailActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-customer-loyalty-cards',\n action: >retailAction,\n input: createCustomerLoyaltyCardsInput\n});\n\nexport default retailActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { ProductAvailableQuantity, ProductDeliveryOptions, ProductsDataActions } from '@msdyn365-commerce/retail-proxy';\n\nimport { ActiveCartProductsInput, buildCacheKey, getActiveCartProductsAction } from '.';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Input class for delivery options for items in cart.\n */\nexport class ProductDeliveryOptionsForCartLineItems implements IActionInput {\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings) {\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('ActiveCartLineItemsDeliveryOptions', this.apiSettings);\n\n public getCacheObjectType = () => 'ActiveCartLineItemsDeliveryOptions';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\nconst createInput = (inputData: ICreateActionContext>) => {\n return new ProductDeliveryOptionsForCartLineItems(inputData.requestContext.apiSettings);\n};\n\n/**\n * Calls the Retail API to get the delivery options for items in the cart.\n * @param input\n * @param ctx\n */\nexport async function getDeliveryOptionsForCartLineItems(\n input: ProductDeliveryOptionsForCartLineItems,\n ctx: IActionContext\n): Promise {\n // If no input is provided fail out\n if (!input) {\n throw new Error('[getDeliveryOptionsForCartLineItems]No valid Input was provided, failing');\n }\n const cartState = await getCartState(ctx);\n const cart = cartState.cart;\n const products = await getActiveCartProductsAction(new ActiveCartProductsInput(), ctx);\n\n if (!cart || !products || products.length === 0) {\n ctx.trace('[getDeliveryOptionsForCartLineItems] Not able to get cart OR channelConfiguration or no products in cart');\n return [];\n }\n\n return ProductsDataActions.getDeliveryOptionsAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n products.map(x => x.RecordId),\n {},\n null\n )\n .then(result => {\n return result;\n })\n .catch((error: Error) => {\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getDeliveryOptionsForCartLineItems]Error executing action');\n throw new Error('[getDeliveryOptionsForCartLineItems]Error executing action');\n });\n}\n\nexport const getDeliveryOptionsForCartLineItemsDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-delivery-options-for-cartlines',\n action: >getDeliveryOptionsForCartLineItems,\n input: createInput\n});\n\nexport default getDeliveryOptionsForCartLineItemsDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { FeatureState } from '@msdyn365-commerce/retail-proxy';\nimport { getDeliveryOptionsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport {\n FilterDeliveryModeOption,\n ProductDeliveryOptions,\n ReleasedProductType,\n SimpleProduct\n} from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { getSelectedProductIdFromActionInput, getSelectedVariant, SelectedVariantInput } from '.';\nimport { FeatureStateInput, getFeatureStateActionDataAction } from './get-feature-state';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Input class for the GetDeliveryOptionsForSelectedVariant Data Action.\n */\nexport class GetDeliveryOptionsForSelectedVariantInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public selectedProduct: SimpleProduct | undefined;\n\n public customerId: string;\n\n public featureState?: boolean;\n\n constructor(productId: number, channelId: number, selectedProduct?: SimpleProduct, customerId?: string, featureState?: boolean) {\n this.productId = productId;\n this.channelId = channelId;\n this.selectedProduct = selectedProduct;\n this.customerId = customerId || '';\n this.featureState = featureState;\n }\n\n public getCacheKey = () => 'DeliveryOptionsForSelectedVariant';\n\n public getCacheObjectType = () => 'DeliveryOptions';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Calls the Retail Feature State API and returns a list of feature with isEnabled flag.\n * @param context\n */\nexport async function getFeatureState(context: IActionContext): Promise {\n return getFeatureStateActionDataAction(new FeatureStateInput(), context);\n}\n\n/**\n * The createInput method for the GetDeliveryOptionsForSelectedVariant Data Action.\n * @param inputData The input data for the createInput method.\n */\nexport const createDeliveryOptionsForSelectedVariantInput = (\n inputData: ICreateActionContext>\n): GetDeliveryOptionsForSelectedVariantInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n\n if (productId) {\n return new GetDeliveryOptionsForSelectedVariantInput(\n +productId,\n +inputData.requestContext.apiSettings.channelId,\n undefined,\n undefined\n );\n }\n throw new Error('Unable to create PriceForSelectedVariantInput, no productId found on module config or query');\n};\n\n/**\n * The Action Method for the GetDeliveryOptionsForSelectedVariant Data Action\n * Pulls the currently selected variant from the cache using the getSelectedVariant data action, and gets it's supported delivery options\n * via the getDeliveryOptionsAsync RetailServer API.\n * @param input\n * @param ctx\n */\nexport async function getDeliveryOptionsForSelectedVariantAction(\n input: GetDeliveryOptionsForSelectedVariantInput,\n ctx: IActionContext\n): Promise {\n if (input.featureState === undefined) {\n const featureState = await getFeatureState(ctx);\n input.featureState = featureState?.find(\n item => item.Name === 'Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature'\n )?.IsEnabled;\n }\n\n return Promise.resolve()\n .then(() => {\n const activeProduct: SimpleProduct | undefined = input.selectedProduct;\n\n if (!activeProduct) {\n const selectedVariantInput = new SelectedVariantInput(\n input.productId,\n input.channelId,\n undefined,\n undefined,\n ctx.requestContext\n );\n\n return getSelectedVariant(selectedVariantInput, ctx);\n }\n\n return activeProduct;\n })\n .then((productResult: SimpleProduct | null) => {\n const activeProduct: SimpleProduct | undefined = productResult;\n\n if (activeProduct) {\n return getDeliveryOptionsAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n [activeProduct.RecordId],\n {},\n\n // For service item, should not apply the filter, otherwise there will be no electronic delivery mode\n input.featureState && productResult?.ItemTypeValue !== ReleasedProductType.Service\n ? FilterDeliveryModeOption.FilterOutNonPickupDeliveryMode\n : null\n ).then(response => {\n if (response && response.length > 0) {\n return response[0];\n }\n\n return undefined;\n });\n }\n\n return undefined;\n })\n .catch((error: Error) => {\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getDeliveryOptionsForSelectedVariantAction]Error executing action');\n throw new Error('[getDeliveryOptionsForSelectedVariantAction]Error executing action');\n });\n}\n\nexport const getDeliveryOptionsForSelectedVariantActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-delivery-options-for-selected-variant',\n action: >getDeliveryOptionsForSelectedVariantAction,\n input: createDeliveryOptionsForSelectedVariantInput\n});\n\nexport default getDeliveryOptionsForSelectedVariantActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IProductsDimensionsAvailabilities } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICoreContext } from '@msdyn365-commerce/core';\nimport { ProductDimensionType, ProductDimensionValueInventoryAvailability, ProductSearchResult } from '@msdyn365-commerce/retail-proxy';\n\nimport {\n getDimensionAvailabilitiesForProductsAction,\n ProductsDimensionAvailabilitiesInput\n} from './get-dimension-availabilities-for-products';\nimport {\n ArrayExtensions,\n checkIfShouldDisplayAsSwatch,\n DimensionTypes,\n DimensionSwatchDisplayTypes,\n getInventoryLevelCodeFromDimensionValue,\n IDimensionsApp,\n InventoryLevelValues\n} from './utilities';\n\n/**\n * Input class for the GetDimensionAvailabilitiesForProductSearchResult Data Action.\n */\nexport class DimensionAvailabilitiesForProductSearchResultInput implements IActionInput {\n public products: ProductSearchResult[];\n\n public dimensionContext: ICoreContext;\n\n public displayType: DimensionSwatchDisplayTypes | undefined;\n\n public constructor(\n products: ProductSearchResult[],\n dimensionContext: ICoreContext,\n displayType?: DimensionSwatchDisplayTypes\n ) {\n this.products = products;\n this.dimensionContext = dimensionContext;\n this.displayType = displayType;\n }\n\n /**\n * Get the cache key.\n * @returns The cache key.\n */\n public getCacheKey = (): string =>\n `DimensionAvailabilitiesForProductSearchResult-${this.products.map(product => product.RecordId).join('-')}`;\n\n /**\n * Get the cache object type.\n * @returns The cache object type.\n */\n public getCacheObjectType = (): string => 'ProductDimensionValueInventoryAvailability';\n\n /**\n * Define the data cache type.\n * @returns The cache type.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * The createInput method for the GetDimensionAvailabilitiesForProductSearchResultDataAction.\n * @param products -- The product search result.\n * @param dimensionContext -- The dimension app context.\n * @returns The input.\n */\nexport const createDimensionAvailabilitiesForProductSearchResultInput = (\n products: ProductSearchResult[],\n dimensionContext: ICoreContext\n): DimensionAvailabilitiesForProductSearchResultInput => {\n return new DimensionAvailabilitiesForProductSearchResultInput(products, dimensionContext);\n};\n\n/**\n * The Action Method for the GetDimensionAvailabilitiesForProductSearchResultInput Data Action\n * Gets the active price for product search result via the getDimensionAvailabilitiesForProduct API.\n * @param input -- The data input.\n * @param context -- The core context.\n * @returns The ProductsDimensionsAvailabilities.\n */\nexport async function getDimensionAvailabilitiesForProductSearchResultAction(\n input: DimensionAvailabilitiesForProductSearchResultInput,\n context: IActionContext\n): Promise {\n const products = input.products;\n const productsDimensionInputs: ProductsDimensionAvailabilitiesInput[] = [];\n const inventoryLevel = input.dimensionContext.app.config.inventoryLevel;\n const displayType = input.displayType;\n\n for (const product of products) {\n const filteredProductAttributes = product.AttributeValues?.filter(attributeValue => {\n return checkIfShouldDisplayAsSwatch(\n (attributeValue.Name?.toLocaleLowerCase() ?? '') as DimensionTypes,\n input.dimensionContext,\n displayType\n );\n });\n\n if (ArrayExtensions.hasElements(filteredProductAttributes)) {\n for (const attributeValue of filteredProductAttributes) {\n if (attributeValue.Name) {\n const productionDimensionType: ProductDimensionType =\n ProductDimensionType[attributeValue.Name as keyof typeof ProductDimensionType];\n\n productsDimensionInputs.push(\n new ProductsDimensionAvailabilitiesInput(\n product.MasterProductId ?? product.RecordId,\n productionDimensionType,\n context.requestContext\n )\n );\n }\n }\n }\n }\n\n if (!ArrayExtensions.hasElements(productsDimensionInputs)) {\n return Promise.resolve([]);\n }\n\n try {\n const dimensionForProducts: ProductDimensionValueInventoryAvailability[][] = await getDimensionAvailabilitiesForProductsAction(\n productsDimensionInputs,\n context\n );\n const productsDimensionAvailabilities = productsDimensionInputs.map((dimensionInput, index) => {\n return dimensionForProducts[index].map(dimensionValuesWithInventory => {\n const inventoryLevelCode = getInventoryLevelCodeFromDimensionValue(dimensionValuesWithInventory, inventoryLevel);\n const dimensionValue = dimensionValuesWithInventory.DimensionValue!;\n return {\n value: dimensionValue.Value ?? '',\n isDisabled: inventoryLevelCode === InventoryLevelValues.outOfStock,\n masterProductId: dimensionInput.masterProductId\n };\n });\n });\n\n if (!ArrayExtensions.hasElements(productsDimensionAvailabilities)) {\n context.telemetry.warning('ProductsDimensionAvailabilities is empty');\n return Promise.resolve([]);\n }\n\n return Promise.resolve(productsDimensionAvailabilities);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- existing error.\n context.telemetry.warning(error);\n }\n\n return Promise.resolve([]);\n}\n\n/**\n * The GetDimensionAvailabilitiesForProductSearchResult data action.\n */\nexport const getDimensionAvailabilitiesForProductSearchResultDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-dimension-availabilities-for-product-search-result',\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- existing pattern.\n action: >getDimensionAvailabilitiesForProductSearchResultAction,\n input: createDimensionAvailabilitiesForProductSearchResultInput\n});\n\nexport default getDimensionAvailabilitiesForProductSearchResultDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport {\n ProductDimensionAvailabilitySearchCriteria,\n ProductDimensionType,\n ProductDimensionValueInventoryAvailability,\n ProductsDataActions\n} from '@msdyn365-commerce/retail-proxy';\n\nimport { ArrayExtensions } from './utilities';\nimport { createInventoryAvailabilitySearchCriteria } from './utilities/product-inventory-utils';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Interface for IProductDimension.\n */\nexport interface IProductDimension {\n masterProductId: number;\n requestDimensionType: ProductDimensionType;\n}\n\n/**\n * Product Input.\n */\nexport class ProductsDimensionAvailabilitiesInput implements IActionInput {\n public masterProductId: number;\n\n public requestDimensionType: ProductDimensionType;\n\n public catalogId?: number;\n\n public constructor(masterProductId: number, requestDimensionType: ProductDimensionType, requestContext?: IRequestContext) {\n this.masterProductId = masterProductId;\n this.requestDimensionType = requestDimensionType;\n\n if (requestContext) {\n this.catalogId = getCatalogId(requestContext);\n }\n }\n\n /**\n * Cache key.\n * @returns String.\n */\n public getCacheKey: () => string = () => {\n return `MasterProductId-${this.masterProductId.toString()}-DimensionType-${this.requestDimensionType}-Availabilities-${this\n .catalogId ?? 0}`;\n };\n\n /**\n * Cache object type.\n * @returns String.\n */\n public getCacheObjectType = (): string => 'MasterProductDimensionAvailabilities';\n\n /**\n * Cache type.\n * @returns String.\n */\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * Create input method for the getDimensionsForSelectedVariant data action.\n * @param inputData - The input data passed to the createInput method.\n * @returns - The input for the data action.\n */\nexport const createProductsDimensionAvailabilitiesInput = (\n inputData: ICreateActionContext>\n): ProductsDimensionAvailabilitiesInput[] => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- ignore type of config.\n const productsDimensions: IProductDimension[] = inputData.config?.productsDimensions;\n\n return productsDimensions.map((productDimension: IProductDimension) => {\n return new ProductsDimensionAvailabilitiesInput(\n productDimension.masterProductId,\n productDimension.requestDimensionType,\n inputData.requestContext\n );\n });\n};\n\n/**\n * Action Method for the getDimensionsForSelectedVariant Data Action.\n * @param inputs - Input for the data action.\n * @param context - Action context.\n * @returns Master product dimensions with availabilities.\n */\nexport async function getDimensionAvailabilitiesForProductsAction(\n inputs: ProductsDimensionAvailabilitiesInput[],\n context: IActionContext\n): Promise {\n if (!Array.isArray(inputs) || !ArrayExtensions.hasElements(inputs)) {\n context.trace('[getDimensionAvailabilitiesForProductsAction] Invalid or empty inputs passed.');\n return [];\n }\n\n const promise = inputs.map(input => {\n // As per default PDP loads shipping inventory policies, so making swatch to pick the same configuration\n const shippingInventoryConfiguration = createInventoryAvailabilitySearchCriteria(\n context,\n [input.masterProductId],\n true,\n undefined,\n undefined\n );\n\n const searchCriteria: ProductDimensionAvailabilitySearchCriteria = {\n RequestedDimensionTypeValue: input.requestDimensionType,\n MatchingDimensionValues: undefined,\n DefaultWarehouseOnly: shippingInventoryConfiguration.DefaultWarehouseOnly,\n FilterByChannelFulfillmentGroup: shippingInventoryConfiguration.FilterByChannelFulfillmentGroup,\n DeliveryModeTypeFilterValue: shippingInventoryConfiguration.DeliveryModeTypeFilterValue,\n CatalogId: input.catalogId\n };\n\n const dimensionValuesPromise = ProductsDataActions.getDimensionValuesWithEstimatedAvailabilitiesAsync(\n { callerContext: context, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context) },\n input.masterProductId,\n searchCriteria\n );\n\n return dimensionValuesPromise;\n });\n\n // eslint-disable-next-line no-return-await -- existing code\n return await Promise.all(promise);\n}\n\n/**\n * The GetDimensionAvailabilitiesForProductsAction\n * Gets the available product dimensions for the master product via the getDimensionValues RetailServer API.\n */\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-dimension-availabilities-for-products',\n action: getDimensionAvailabilitiesForProductsAction as IAction,\n input: createProductsDimensionAvailabilitiesInput,\n isBatched: true\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IProductDimensionsWithAvailabilitiesFull, ProductDimensionFull } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport {\n ProductDimension,\n ProductDimensionAvailabilitySearchCriteria,\n ProductDimensionValue,\n ProductDimensionValueInventoryAvailability,\n ProductsDataActions\n} from '@msdyn365-commerce/retail-proxy';\n\nimport { ArrayExtensions } from './utilities';\nimport { createInventoryAvailabilitySearchCriteria } from './utilities/product-inventory-utils';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { getDimensionValuesFromQuery, getSelectedProductIdFromActionInput } from './utilities/utils';\n\n/**\n * Defines the dimension value type for get dimensions for selected variant data action.\n * Includes old API format for backward compatibility and new API info for availabilities for new logic.\n */\nexport interface IDimensionValueForSelectedVariant extends ProductDimensionValueInventoryAvailability, ProductDimensionValue {}\n\n/**\n * Defines the returned type for get dimensions for selected variant data action.\n * Includes old API format for backward compatibility and new API info for availabilities for new logic.\n */\nexport interface IDimensionForSelectedVariant extends ProductDimensionFull, IProductDimensionsWithAvailabilitiesFull {}\n\n/**\n * Input class for the getDimensionsForSelectedVariant data action.\n */\nexport class GetDimensionsForSelectedVariantInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public matchingDimensionValues: ProductDimension[];\n\n public catalogId?: number;\n\n public constructor(\n productId: number,\n channelId: number,\n matchingDimensionValues?: ProductDimension[],\n requestContext?: IRequestContext\n ) {\n this.productId = productId;\n this.channelId = channelId;\n this.matchingDimensionValues = matchingDimensionValues || [];\n\n if (requestContext) {\n this.catalogId = getCatalogId(requestContext);\n }\n }\n\n /**\n * Cache key.\n * @returns String.\n */\n public getCacheKey: () => string = () => `DimensionsForSelectedVariantInput-${this.productId}-${this.channelId}-${this.catalogId ?? 0}`;\n\n /**\n * Cache object type.\n * @returns String.\n */\n public getCacheObjectType: () => string = () => 'DimensionsForSelectedVariantInput';\n\n /**\n * Cache type.\n * @returns String.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Create input method for the getDimensionsForSelectedVariant data action.\n * @param inputData - The input data passed to the createInput method.\n * @returns - The input for the data action.\n */\nconst createDimensionsForSelectedVariantInput = (inputData: ICreateActionContext>): GetDimensionsForSelectedVariantInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n\n if (productId) {\n return new GetDimensionsForSelectedVariantInput(\n +productId,\n +inputData.requestContext.apiSettings.channelId,\n getDimensionValuesFromQuery(inputData.requestContext.url.requestUrl),\n inputData.requestContext\n );\n }\n throw new Error('Unable to create DimensionsForSelectedVariantInput, no productId found on module config or query');\n};\n\n/**\n * Converts new API type with availabilities to old API type to preserve backward compatibility.\n * @param dimensions - Dimensions to convert.\n * @returns Dimensions in old API format.\n */\nconst prepareDimensionsDataResult = (dimensions: IProductDimensionsWithAvailabilitiesFull[]): IDimensionForSelectedVariant[] => {\n return dimensions.map(newDimension => {\n const oldDimension: IDimensionForSelectedVariant = { ...newDimension };\n oldDimension.DimensionValues = ArrayExtensions.validValues(\n newDimension.dimensionValuesWithInventory?.map(value => value.DimensionValue)\n );\n return oldDimension;\n });\n};\n\n/**\n * Action Method for the getDimensionsForSelectedVariant Data Action.\n * @param input - Input for the data action.\n * @param context - Action context.\n * @returns Product dimensions with availability.\n */\nexport async function getDimensionsForSelectedVariantAction(\n input: GetDimensionsForSelectedVariantInput,\n context: IActionContext\n): Promise {\n const activeProducts = ArrayExtensions.validValues(\n await ProductsDataActions.getByIdsAsync(\n {\n callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\n },\n input.channelId,\n [input.productId],\n null,\n input.catalogId ?? 0\n )\n );\n\n if (!ArrayExtensions.hasElements(activeProducts)) {\n return [];\n }\n\n const activeProduct = activeProducts[0];\n\n if (!ArrayExtensions.hasElements(activeProduct.Dimensions)) {\n return [];\n }\n\n const promises = activeProduct.Dimensions.map(dimension => {\n const shippingInventoryConfiguration = createInventoryAvailabilitySearchCriteria(context, [], true, undefined, undefined);\n\n const searchCriteria: ProductDimensionAvailabilitySearchCriteria = {\n RequestedDimensionTypeValue: dimension.DimensionTypeValue,\n MatchingDimensionValues: input.matchingDimensionValues.filter(item => item.DimensionTypeValue !== dimension.DimensionTypeValue),\n DefaultWarehouseOnly: shippingInventoryConfiguration.DefaultWarehouseOnly,\n FilterByChannelFulfillmentGroup: shippingInventoryConfiguration.FilterByChannelFulfillmentGroup,\n DeliveryModeTypeFilterValue: shippingInventoryConfiguration.DeliveryModeTypeFilterValue,\n CatalogId: input.catalogId\n };\n\n const dimensionValuesPromise = ProductsDataActions.getDimensionValuesWithEstimatedAvailabilitiesAsync(\n { callerContext: context, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context) },\n activeProduct.MasterProductId ? activeProduct.MasterProductId : activeProduct.RecordId,\n searchCriteria\n );\n const fullDimensionPromise = dimensionValuesPromise.then(dimensionValues => {\n const fullDimension: IProductDimensionsWithAvailabilitiesFull = {\n ...dimension,\n dimensionValuesWithInventory: dimensionValues\n };\n return fullDimension;\n });\n\n return fullDimensionPromise;\n });\n\n const dimensionValuesResults = await Promise.all(promises);\n\n return prepareDimensionsDataResult(dimensionValuesResults);\n}\n\n/**\n * The GetDimensionsForSelectedVariantDataAction\n * Get the currently selected Variant via the getSelectedVariant data action, and the gets the\n * available product dimensions for the variant via the getDimensionValues RetailServer API.\n */\nexport const getDimensionsForSelectedVariantActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-dimensions/for-selected-variant',\n action: getDimensionsForSelectedVariantAction as IAction,\n input: createDimensionsForSelectedVariantInput\n});\n\nexport default getDimensionsForSelectedVariantActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { FeatureState, StoreOperationsDataActions } from '@msdyn365-commerce/retail-proxy';\n\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Input class for the getFeatureState data action.\n * The life time of the data action is 'application'.\n */\nexport class FeatureStateInput implements IActionInput {\n // Any additional feature names that needs to be checked in the code for enablement needs to be appended here:\n public readonly featureNames: string[] = [\n 'Dynamics.AX.Application.RetailB2BEcommerceFeature',\n 'Dynamics.AX.Application.RetailDefaultOrderQuantityLimitsFeature',\n 'Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature',\n 'Dynamics.AX.Application.RetailSearchPriceRangeFeature',\n 'Dynamics.AX.Application.RetailSalesAgreementPriceSupportFeature',\n 'Dynamics.AX.Application.ChannelMultipleCatalogsFeature',\n 'Dynamics.AX.Application.RetailAsyncAddressCreationFeature',\n 'UseLegacySalesAgreementHTMLFeature'\n ];\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n public getCacheKey = (): string => 'FeatureState';\n\n /**\n * Get Cache type Name.\n * @returns - Cache name string.\n */\n public getCacheObjectType = (): string => 'FeatureState';\n\n /**\n * Get Cache type.\n * @returns - CacheType enum.\n */\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * CreateInput method for the getFeatureState method.\n * @param inputData -- The input data passed to the createInput method.\n * @returns - Input for data action.\n */\nexport const createGetFeatureStateInput = (inputData: ICreateActionContext>): IActionInput => {\n return new FeatureStateInput();\n};\n\n/**\n * The action method for the getFeatureState data action.\n * @param input -- The action input.\n * @param ctx -- The action context.\n * @returns -- Feature state.\n */\nexport async function getFeatureStateAction(input: FeatureStateInput, ctx: IActionContext): Promise {\n const featureState = await StoreOperationsDataActions.getFeatureStatesAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n input.featureNames\n );\n return featureState;\n}\n\n/**\n * The getFeatureState data action.\n * Gets the feature state via the read RetailServer API.\n * @returns Address information associated with the retrieved customer.\n */\nexport const getFeatureStateActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-feature-state',\n action: getFeatureStateAction as IAction,\n input: createGetFeatureStateInput\n});\n\nexport default getFeatureStateActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport {\n ChannelDeliveryOption,\n DeliveryModeTypeFilter,\n FeatureState,\n ItemAvailability,\n OrgUnitAvailability,\n OrgUnitLocation,\n ProductWarehouseInventoryInformation,\n SearchArea,\n StoreHours\n} from '@msdyn365-commerce/retail-proxy';\nimport {\n getChannelDeliveryOptionsAsync,\n getOrgUnitLocationsByAreaAsync,\n getStoreHoursAsync\n} from '@msdyn365-commerce/retail-proxy/dist/DataActions/OrgUnitsDataActions.g';\nimport { getEstimatedAvailabilityAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport { FeatureStateInput, getFeatureStateActionDataAction } from './get-feature-state';\nimport { IFullOrgUnitAvailability } from './utilities/full-org-unit-availability';\nimport { DeliveryMode, IProductInventoryInformation } from './utilities/product-inventory-information';\nimport { createInventoryAvailabilitySearchCriteria, mapProductInventoryInformation } from './utilities/product-inventory-utils';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Get selected variant action input class.\n */\nexport class GetFullAvailableInventoryNearbyInput implements IActionInput {\n public latitude?: number;\n\n public longitude?: number;\n\n public radius?: number;\n\n public productId?: number;\n\n public DistanceUnitValue?: number;\n\n public IgnoreLocation?: boolean;\n\n constructor(\n _productId?: number,\n _latitude?: number,\n _longitude?: number,\n _radius?: number,\n _DistanceUnitValue?: number,\n _IgnoreLocation?: boolean\n ) {\n this.productId = _productId;\n this.latitude = _latitude;\n this.longitude = _longitude;\n this.radius = _radius;\n this.DistanceUnitValue = _DistanceUnitValue;\n this.IgnoreLocation = _IgnoreLocation;\n }\n\n public getCacheKey = () => 'GetFullAvailableInventoryNearbyInputCache';\n\n public getCacheObjectType = () => 'GetFullAvailableInventoryNearbyInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the getSelectedVariant data action.\n * @param inputData - The input data passed to the createInput method.\n * @returns GetFullAvailableInventoryNearbyInput - The action input.\n */\nexport const createGetFullAvailableInventoryNearbyInput = (\n inputData: ICreateActionContext>\n): GetFullAvailableInventoryNearbyInput => {\n return new GetFullAvailableInventoryNearbyInput();\n};\n\n/**\n * Calls the Retail Feature State API and returns a list of feature with isEnabled flag.\n * @param context - The context.\n * @returns FeatureState - The feature state.\n */\nexport async function getFeatureState(context: IActionContext): Promise {\n return getFeatureStateActionDataAction(new FeatureStateInput(), context);\n}\n\n/**\n * Action method for the getSelectedVariant data aciton.\n * @param input - The action input class.\n * @param ctx - The action context.\n * @returns IFullOrgUnitAvailability - The full org unit availability.\n */\nexport async function getFullAvailableInventoryNearbyAction(\n input: GetFullAvailableInventoryNearbyInput,\n ctx: IActionContext\n): Promise {\n // No valid product we want to return undefined so module knows there are no results yet\n if (!input.productId) {\n return undefined;\n }\n\n if (((!input.radius && input.radius !== 0) || !input.latitude || !input.longitude) && !input.IgnoreLocation) {\n // No valid location we want to return empty array so module can show no locations message\n return [];\n }\n\n const searchArea: SearchArea = {\n Latitude: input.latitude,\n Longitude: input.longitude,\n Radius: input.radius,\n DistanceUnitValue: input.DistanceUnitValue || 0 // 0 is miles\n };\n\n const featureState = await getFeatureState(ctx);\n const retailMulitplePickupMFeatureState = featureState?.find(\n item => item.Name === 'Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature'\n )?.IsEnabled;\n const searchCriteria = createInventoryAvailabilitySearchCriteria(ctx, [input.productId], false, true, searchArea, DeliveryMode.pickup);\n return getEstimatedAvailabilityAsync({ callerContext: ctx }, searchCriteria)\n .then(async (productWarehouseInformation: ProductWarehouseInventoryInformation) => {\n // For store selector, inventory should always come from an individual store\n const productInventoryInformation = mapProductInventoryInformation(\n ctx,\n productWarehouseInformation.ProductWarehouseInventoryAvailabilities\n );\n return getOrgUnitLocationsByAreaAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n searchArea,\n DeliveryModeTypeFilter.Pickup\n )\n .then(async (stores: OrgUnitLocation[]) => {\n // Constructing a store mapping based on the InventoryId.\n const storeMap = new Map();\n stores.forEach(store => {\n if (store.InventoryLocationId) {\n storeMap.set(store.InventoryLocationId, store);\n }\n });\n\n let locationDeliveryOptions: ChannelDeliveryOption[] | undefined = [];\n\n // If multiple pickup mode is enable then call getchanneldeliveryoption\n if (retailMulitplePickupMFeatureState) {\n const orgUnitChannel = stores.map(store => store.ChannelId);\n locationDeliveryOptions = await _getLocationPickUpDeliveryModes(orgUnitChannel, ctx);\n }\n\n const availabilityPromiseList = stores.map(store => {\n const locationDeliveryOption = locationDeliveryOptions?.find(\n _channeldeliveryoption => _channeldeliveryoption.ChannelId === store.ChannelId\n );\n return _getAvailabilityWithHours(store, productInventoryInformation, storeMap, ctx, locationDeliveryOption);\n });\n\n return Promise.all(availabilityPromiseList);\n })\n .catch((error: Error) => {\n ctx.trace('[GetFullAvailableInventoryNearby] error getting Available Inventory Nearby');\n ctx.trace(error.message);\n ctx.telemetry.error(error.message);\n ctx.telemetry.debug('[GetFullAvailableInventoryNearby] error getting Available Inventory Nearby');\n return [];\n });\n })\n .catch((error: Error) => {\n ctx.trace(\n '[GetFullAvailableInventoryNearby][getEstimatedAvailabilityAsync] error getting availability product warehouse information.'\n );\n ctx.trace(error.message);\n ctx.telemetry.error(error.message);\n ctx.telemetry.debug(\n '[GetFullAvailableInventoryNearby][getEstimatedAvailabilityAsync] error getting availability product warehouse information.'\n );\n return [];\n });\n}\n\n/**\n * Action method that obtains the store information along with store hours and product availability.\n * @param orgUnitLocation - The org unit location.\n * @param productInventoryInformation - The product inventory information.\n * @param storeMap - A map that contains store information group by the inventory location id.\n * @param ctx The action context.\n * @param channelDeleiveryOptions - The channel delivery options.\n * @returns IFullOrgUnitAvailability - The full org unit availability.\n */\nasync function _getAvailabilityWithHours(\n orgUnitLocation: OrgUnitLocation,\n productInventoryInformation: IProductInventoryInformation[],\n storeMap: Map,\n ctx: IActionContext,\n channelDeleiveryOptions: ChannelDeliveryOption | undefined\n): Promise {\n if (!orgUnitLocation || !orgUnitLocation.OrgUnitNumber) {\n return { OrgUnitAvailability: undefined };\n }\n\n return getStoreHoursAsync({ callerContext: ctx }, orgUnitLocation.OrgUnitNumber)\n .then((hours: StoreHours) => {\n const itemAvailabilities: ItemAvailability[] = [];\n if (productInventoryInformation && storeMap) {\n productInventoryInformation.forEach(element => {\n if (\n element.InventLocationId &&\n storeMap.has(element.InventLocationId) &&\n element.InventLocationId === orgUnitLocation.InventoryLocationId\n ) {\n itemAvailabilities.push({ AvailableQuantity: element.ProductAvailableQuantity?.AvailableQuantity });\n }\n });\n }\n\n const availability: OrgUnitAvailability = {\n OrgUnitLocation: orgUnitLocation,\n ItemAvailabilities: itemAvailabilities\n };\n\n if (hours && !(hours instanceof Error)) {\n return {\n OrgUnitAvailability: availability,\n StoreHours: hours,\n ProductInventoryInformation: productInventoryInformation,\n OrgUnitPickUpDeliveryModes: channelDeleiveryOptions\n };\n }\n\n return {\n OrgUnitAvailability: availability,\n ProductInventoryInformation: productInventoryInformation,\n OrgUnitPickUpDeliveryModes: channelDeleiveryOptions\n };\n })\n .catch((error: Error) => {\n ctx.trace('[GetFullAvailableInventoryNearby] error getting availability with hours');\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[GetFullAvailableInventoryNearby] error getting availability with hours');\n return { OrgUnitAvailability: {} };\n });\n}\n\n/**\n * Action method that obtains the channel delivery option information.\n * @param channelCollection - The org unit channel Id list.\n * @param ctx - The action context.\n * @returns ChannelDeliveryOption - The channel delivery option collection.\n */\nasync function _getLocationPickUpDeliveryModes(\n channelCollection: (number | undefined)[],\n ctx: IActionContext\n): Promise {\n if (channelCollection?.length === 0 || channelCollection === undefined) {\n return undefined;\n }\n\n const channelIdList: number[] = [];\n channelCollection?.map(id => {\n if (id !== undefined) {\n return channelIdList.push(id);\n }\n });\n\n // To get all channel pickup delivery mode filterOption should be 4\n return getChannelDeliveryOptionsAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n channelIdList,\n 4\n )\n .then((channelDeliveryOptions: ChannelDeliveryOption[]) => {\n if (channelDeliveryOptions && !(channelDeliveryOptions instanceof Error)) {\n return channelDeliveryOptions;\n }\n\n return undefined;\n })\n .catch((error: Error) => {\n ctx.trace(\n '[GetFullAvailableInventoryNearby][getChannelDeliveryOptionsAsync] error getting availability with channel delivery options'\n );\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug(\n '[GetFullAvailableInventoryNearby] [getChannelDeliveryOptionsAsync] error getting availability with channel delivery options'\n );\n return [];\n });\n}\n\n/**\n * The complete getFullAvailableInventoryNearby data action.\n */\nexport const getFullAvailableInventoryNearbyActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-full-available-inventory-nearby',\n action: >getFullAvailableInventoryNearbyAction,\n input: createGetFullAvailableInventoryNearbyInput\n});\n\nexport default getFullAvailableInventoryNearbyActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { ProductList } from '@msdyn365-commerce/retail-proxy';\n\nimport { QuickOrderTemplateLine } from './quick-order-template-line';\n\n/**\n * Quick Order template class.\n */\nexport class QuickOrderTemplate {\n public productList: ProductList;\n\n public quickOrderTemplateLines: QuickOrderTemplateLine[];\n\n public totalLines: number;\n\n public constructor(productList: ProductList, quickOrderTemplateLines: QuickOrderTemplateLine[], totalLines: number) {\n this.productList = productList;\n this.quickOrderTemplateLines = quickOrderTemplateLines;\n this.totalLines = totalLines;\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\n\nimport getProductList, { GetProductListInput } from './get-product-list';\nimport getProductListLines, { GetProductListLinesInput } from './get-product-list-lines';\nimport { QuickOrderTemplate } from './utilities/quick-order-templates';\n\n/**\n * Input class for the GetProductList data action.\n */\nexport class GetFullProductListInput implements IActionInput {\n public productListId: string | undefined;\n\n public constructor(productListId?: string) {\n this.productListId = productListId;\n }\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n public getCacheKey = (): string => 'GetFullProductList';\n\n /**\n * Get Cachetype Name.\n * @returns - Cache name string.\n */\n public getCacheObjectType = (): string => 'GetFullProductList';\n\n /**\n * Get Cachetype.\n * @returns - CacheType enum.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the GetProductList method.\n * @param inputData - The input data passed to the createInput method.\n * @param productListId - ProductListId.\n * @returns - Input for data action.\n */\nexport const createGetFullProductListInput = (inputData: ICreateActionContext, productListId?: string): GetFullProductListInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to get full product list. User is not authenticated.');\n }\n\n return new GetFullProductListInput(productListId);\n};\n\n/**\n * The action method for the GetFullProductList data action.\n * @param input - The action input.\n * @param context - The action context.\n * @returns - Quick Order Template object.\n */\nexport async function getFullProductListAction(input: GetFullProductListInput, context: IActionContext): Promise {\n if (!context.requestContext.user.isAuthenticated) {\n throw new Error('Unable to get full quick order template. User is not authenticated.');\n }\n\n const inputParameters = new GetProductListInput(input.productListId);\n const quickorderTemplate = await getProductList(inputParameters, context).then(productLists => {\n const inputLines = new GetProductListLinesInput(productLists[0].Id);\n return getProductListLines(inputLines, context).then(linesState => {\n return new QuickOrderTemplate(productLists[0], linesState.lines, linesState.totalCount);\n });\n });\n return quickorderTemplate;\n}\n\n/**\n * The GetFullProductList Data Action\n * Returns order templates.\n */\nexport const getFullProductListActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-full-product-list',\n action: getFullProductListAction as IAction,\n input: createGetFullProductListInput\n});\n\nexport default getFullProductListActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { FullProduct, IRefineFullProductSearchOutput } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { ProductRefinerValue, ProductSearchResult } from '@msdyn365-commerce/retail-proxy';\nimport { refineSearchByCategoryAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport getFullProducts, { FullProductInput, ProductDetailsCriteria } from './get-full-products';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { getProductDetailsCriteriaFromActionInput } from './utilities/utils';\n\n/**\n * Refine search for full products input.\n */\nexport class FullProductsRefineSearchByCategoryInput implements IActionInput {\n public readonly categoryId?: number;\n\n public readonly channelId?: number;\n\n public readonly refinementCriteria: ProductRefinerValue[];\n\n public readonly catalogId: number;\n\n public ProductDetailsCriteria?: ProductDetailsCriteria;\n\n public readonly queryResultSettingsProxy: QueryResultSettingsProxy;\n\n constructor(\n queryResultSettingsProxy: QueryResultSettingsProxy,\n categoryId?: number,\n channelId?: number,\n refinementCriteria?: ProductRefinerValue[],\n catalogId?: number,\n criteria?: ProductDetailsCriteria\n ) {\n this.queryResultSettingsProxy = queryResultSettingsProxy;\n this.categoryId = categoryId;\n this.channelId = channelId;\n this.refinementCriteria = refinementCriteria || [];\n this.catalogId = catalogId ?? 0;\n this.ProductDetailsCriteria = criteria;\n }\n\n public getCacheKey = () => 'FullProductsRefineSearchByCategoryInputCache';\n\n public getCacheObjectType = () => 'FullProductsRefineSearchByCategoryInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Creates the input required to make the core action calls.\n * @param inputData\n */\nexport const createFullProductsRefineSearchByCategoryInput = (inputData: ICreateActionContext>): IActionInput => {\n const refinementCriteria = inputData.config && inputData.config.refinementCriteria;\n const queryResultSettingsProxy = QueryResultSettingsProxy.fromInputData(inputData);\n if (!Array.isArray(refinementCriteria)) {\n return new FullProductsRefineSearchByCategoryInput(queryResultSettingsProxy);\n }\n\n if (inputData && inputData.requestContext && inputData.requestContext.query && inputData.requestContext.query.categoryId) {\n const categoryId = Number(inputData.requestContext.query.categoryId);\n const channelId = inputData.requestContext.apiSettings.channelId;\n const productDetailsCriteria = getProductDetailsCriteriaFromActionInput(inputData);\n return new FullProductsRefineSearchByCategoryInput(\n queryResultSettingsProxy,\n categoryId,\n +channelId,\n refinementCriteria,\n undefined,\n productDetailsCriteria\n );\n }\n\n throw new Error('Please specify categoryId, refinerId, and refinerSourceValue query string in request.');\n};\n\n/**\n * Calls the refine-search-by-category action.\n * Based on search result calls get-full-products to get all the product details.\n * @param input\n * @param ctx\n */\nexport async function getFullProductsByRefineSearchCategoryAction(\n input: FullProductsRefineSearchByCategoryInput,\n ctx: IActionContext\n): Promise {\n if (!input || !input.refinementCriteria) {\n ctx.trace('[getFullProductsByRefineSearchCategoryAction] Invalid input.');\n return {};\n }\n\n const hasSortingColumn =\n input.queryResultSettingsProxy.QueryResultSettings &&\n input.queryResultSettingsProxy.QueryResultSettings.Sorting &&\n input.queryResultSettingsProxy.QueryResultSettings.Sorting.Columns &&\n input.queryResultSettingsProxy.QueryResultSettings.Sorting.Columns.length > 0;\n if (input.refinementCriteria.length === 0 && !hasSortingColumn) {\n ctx.telemetry.trace('[getFullProductsByRefineSearchCategoryAction] No refiners or sorting specified.');\n return {};\n }\n const { apiSettings } = ctx.requestContext;\n\n const catalogId = getCatalogId(ctx.requestContext);\n\n let refinementCriteria: ProductRefinerValue[] = [];\n const fullProductInputs = await refineSearchByCategoryAsync(\n { callerContext: ctx, queryResultSettings: input.queryResultSettingsProxy.QueryResultSettings },\n input.channelId || 0,\n input.catalogId || catalogId,\n input.categoryId || 0,\n input.refinementCriteria\n ).then(searchResults => {\n refinementCriteria = input.refinementCriteria;\n return searchResults.map(\n (product: ProductSearchResult): FullProductInput => {\n return new FullProductInput(\n product.RecordId,\n apiSettings,\n input.ProductDetailsCriteria || new ProductDetailsCriteria(),\n ctx.requestContext\n );\n }\n );\n });\n\n if (fullProductInputs.length > 0) {\n const productResult = await (>getFullProducts(fullProductInputs, ctx));\n return {\n productSearchResult: productResult,\n refinementCriteria\n };\n }\n return {\n productSearchResult: [],\n refinementCriteria\n };\n}\n\nexport const getFullProductsByRefineSearchCategoryActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-full-products-by-refine-search-category',\n action: >getFullProductsByRefineSearchCategoryAction,\n input: createFullProductsRefineSearchByCategoryInput,\n isBatched: false\n});\n\nexport default getFullProductsByRefineSearchCategoryActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IRefineFullProductSearchOutput } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { ProductRefinerValue } from '@msdyn365-commerce/retail-proxy';\nimport { refineSearchByTextAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport { ProductDetailsCriteria } from './get-full-products';\nimport { parseSearchData } from './utilities/input-data-parser';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { getRefinedFullProducts, IRefinableProductsInput } from './utilities/refiner-utils';\nimport { getProductDetailsCriteriaFromActionInput } from './utilities/utils';\n\n/**\n * Input for refining products returned by the search text.\n */\nexport class FullProductsRefineSearchByTextInput implements IActionInput, IRefinableProductsInput {\n public readonly searchText: string;\n\n public readonly channelId?: number;\n\n public readonly refinementCriteria: ProductRefinerValue[];\n\n public readonly itemsPerPage?: number;\n\n public readonly skipCount?: number;\n\n public readonly catalogId: number;\n\n public productDetailsCriteria?: ProductDetailsCriteria;\n\n public readonly queryResultSettingsProxy: QueryResultSettingsProxy;\n\n public constructor(\n queryResultSettingsProxy: QueryResultSettingsProxy,\n searchText?: string,\n channelId?: number,\n refinementCriteria?: ProductRefinerValue[],\n catalogId?: number,\n criteria?: ProductDetailsCriteria\n ) {\n this.queryResultSettingsProxy = queryResultSettingsProxy;\n this.searchText = searchText || '';\n this.channelId = channelId;\n this.refinementCriteria = refinementCriteria || [];\n this.catalogId = catalogId ?? 0;\n this.productDetailsCriteria = criteria;\n }\n\n public getCacheKey = () => 'FullProductsRefineSearchByTextInputCache';\n\n public getCacheObjectType = () => 'FullProductsRefineSearchByTextInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Creates the input required to make the core action calls.\n * @param inputData\n */\nexport const createFullProductsRefineSearchByTextInput = (inputData: ICreateActionContext>): IActionInput => {\n const refinementCriteria = inputData.config && inputData.config.refinementCriteria;\n const queryResultSettingsProxy = QueryResultSettingsProxy.fromInputData(inputData);\n if (!Array.isArray(refinementCriteria)) {\n return new FullProductsRefineSearchByTextInput(queryResultSettingsProxy);\n }\n\n const searchInputData = parseSearchData(inputData);\n const productDetailsCriteria = getProductDetailsCriteriaFromActionInput(inputData);\n\n return new FullProductsRefineSearchByTextInput(\n queryResultSettingsProxy,\n searchInputData.q,\n searchInputData.channelId,\n refinementCriteria,\n undefined,\n productDetailsCriteria\n );\n};\n\n/**\n * Calls the refine-search-by-text action.\n * Based on search result calls get-full-products to get all the product details.\n * @param input\n * @param ctx\n */\nexport function getFullProductsByRefineSearchTextAction(\n input: FullProductsRefineSearchByTextInput,\n ctx: IActionContext\n): Promise {\n const catalogId = getCatalogId(ctx.requestContext);\n\n return getRefinedFullProducts(input, ctx, () => {\n return refineSearchByTextAsync(\n { callerContext: ctx, queryResultSettings: input.queryResultSettingsProxy.QueryResultSettings },\n input.channelId || 0,\n input.catalogId || catalogId,\n input.searchText,\n input.refinementCriteria\n );\n });\n}\n\nexport const getFullProductsByRefineSearchTextActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-full-products-by-refine-search-text',\n action: >getFullProductsByRefineSearchTextAction,\n input: createFullProductsRefineSearchByTextInput,\n isBatched: false\n});\n\nexport default getFullProductsByRefineSearchTextActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IRefineFullProductSearchOutput } from '@msdyn365-commerce/commerce-entities';\nimport { IActionContext } from '@msdyn365-commerce/core';\nimport { ProductRefinerValue, ProductSearchResult } from '@msdyn365-commerce/retail-proxy';\n\nimport getFullProducts, { FullProductInput, ProductDetailsCriteria } from '../get-full-products';\n\n/**\n * Common refinable products input includes both product detail criteria and refinement criteria.\n */\nexport interface IRefinableProductsInput {\n refinementCriteria: ProductRefinerValue[];\n productDetailsCriteria?: ProductDetailsCriteria;\n}\n\n/**\n * If refinement criteria is set, then gets refined products.\n * @param input Refinable products input.\n * @param ctx Action context.\n * @param getRefinedProducts Callback function to get a promise (e.g. RefineSearchByCategoryAsync, refineSearchByTextAsync)\n * that is executed to get refined products or full set of products.\n */\nexport async function getRefinedFullProducts(\n input: IRefinableProductsInput,\n ctx: IActionContext,\n getRefinedProducts: () => Promise\n): Promise {\n if (!input || !input.refinementCriteria) {\n ctx.trace('[getFullProductsByRefineSearchCategoryAction] Invalid input.');\n return {};\n }\n\n if (input.refinementCriteria.length === 0) {\n ctx.trace('[getFullProductsByRefineSearchCategoryAction] No refiners specified.');\n return {};\n }\n const { apiSettings } = ctx.requestContext;\n\n let fullProductInputs: FullProductInput[] = [];\n\n const searchResults = await getRefinedProducts();\n if (!searchResults) {\n ctx.telemetry.error('[getFullProductsByRefineSearchCategoryAction] no searchResults returned');\n } else {\n fullProductInputs = searchResults.map(\n (product: ProductSearchResult): FullProductInput => {\n return new FullProductInput(\n product.RecordId,\n apiSettings,\n input.productDetailsCriteria || new ProductDetailsCriteria(),\n ctx.requestContext\n );\n }\n );\n }\n\n if (fullProductInputs.length > 0) {\n const productResult = await getFullProducts(fullProductInputs, ctx);\n return {\n productSearchResult: productResult,\n refinementCriteria: input.refinementCriteria\n };\n }\n return {\n productSearchResult: [],\n refinementCriteria: input.refinementCriteria\n };\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getCatalogId, IRequestContext, versionLt } from '@msdyn365-commerce/core-internal';\nimport { getCartFromCustomer } from '@msdyn365-commerce/global-state';\nimport { AffiliationLoyaltyTier, ProjectionDomain } from '@msdyn365-commerce/retail-proxy';\nimport { getActivePricesAsync, getProductRatingsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport getSimpleProducts, { ProductInput } from './get-simple-products';\nimport { ArrayExtensions, QueryResultSettingsProxy } from './utilities';\nimport { buildCacheKey, generateKey, getProductDetailsCriteriaFromActionInput } from './utilities/utils';\n\n/**\n * Full Product Input.\n */\nexport class FullProductInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public readonly catalogId?: number;\n\n public ProductDetailsCriteria: ProductDetailsCriteria;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n public constructor(\n productId: number | string,\n apiSettings: ICommerceApiSettings,\n criteria: ProductDetailsCriteria,\n requestContext?: IRequestContext,\n catalogId?: number\n ) {\n this.productId = typeof productId === 'string' ? Number.parseInt(productId, 10) : productId;\n this.ProductDetailsCriteria = criteria;\n this.apiSettings = apiSettings;\n this.channelId = apiSettings.channelId;\n this.catalogId = catalogId;\n\n if (this.catalogId === undefined && requestContext) {\n this.catalogId = getCatalogId(requestContext);\n }\n }\n\n public getCacheKey = () => {\n const { getPrice, getRating } = this.ProductDetailsCriteria;\n return buildCacheKey(generateKey([this.productId, this.catalogId, getPrice, getRating]), this.apiSettings);\n };\n\n public getCacheObjectType = () => 'FullProduct';\n\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * Class to define criteria to get full product like price, ratings etc.\n */\nexport class ProductDetailsCriteria {\n public getPrice: boolean;\n\n public getRating: boolean;\n\n constructor(getPrice?: boolean, getRating?: boolean) {\n this.getPrice = getPrice || false;\n this.getRating = getRating || false;\n }\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nexport const createInput = (inputData: ICreateActionContext>): IActionInput[] => {\n let productIds = inputData.config && inputData.config.productIds;\n const productDetailsCriteria = getProductDetailsCriteriaFromActionInput(inputData);\n if (typeof productIds === 'string') {\n productIds = productIds.split(',');\n }\n if (Array.isArray(productIds) && productIds.length > 0) {\n return productIds.map((productId: string) => {\n return new FullProductInput(+productId, inputData.requestContext.apiSettings, productDetailsCriteria, inputData.requestContext);\n });\n }\n return [];\n};\n\n/**\n * Calls the Retail API and returns the product based on the passed ProductInput.\n * @param inputs\n * @param ctx\n */\nexport async function getFullProductsAction(inputs: FullProductInput[], ctx: IActionContext): Promise {\n if (!Array.isArray(inputs) || inputs.length === 0) {\n ctx.trace('[getFullProductsAction] Invalid or empty inputs passed.');\n return {};\n }\n\n const { apiSettings } = ctx.requestContext;\n const productInputs = inputs.map(\n (input: FullProductInput): ProductInput => {\n return new ProductInput(input.productId, apiSettings, undefined, undefined, ctx.requestContext);\n }\n );\n\n return getSimpleProducts(productInputs, ctx)\n .then(result => {\n return result.map(product => {\n return { ProductDetails: product };\n });\n })\n .then((productCollection: FullProduct[]) => {\n const validProductIds = new Set(productCollection.map(input => input.ProductDetails && input.ProductDetails.RecordId));\n\n const ratingsAndPricePromises = [\n _getActivePrices(inputs, validProductIds, productCollection, ctx),\n _getProductRatings(inputs, validProductIds, productCollection, ctx)\n ];\n return Promise.all(ratingsAndPricePromises).then(() => {\n return productCollection;\n });\n })\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('Unable to get Simple products');\n return [];\n });\n}\n\nasync function _getActivePrices(\n inputs: FullProductInput[],\n validProductIds: Set,\n productCollection: FullProduct[],\n ctx: IActionContext\n): Promise {\n let catalogId = 0;\n if (ArrayExtensions.hasElements(inputs)) {\n catalogId = inputs[0].catalogId ?? 0;\n }\n\n const projectDomain: ProjectionDomain = { ChannelId: +ctx.requestContext.apiSettings.channelId, CatalogId: catalogId };\n const validInputs = inputs\n .map(input => {\n if (input.ProductDetailsCriteria.getPrice && validProductIds.has(input.productId)) {\n return input.productId;\n }\n })\n .filter(Boolean);\n\n let affiliations: AffiliationLoyaltyTier[] | undefined = [];\n if (ctx.requestContext.user.isAuthenticated) {\n const cart = await getCartFromCustomer(ctx);\n affiliations = cart?.AffiliationLines;\n }\n\n if (validInputs.length === 0) {\n return Promise.resolve();\n }\n\n return getActivePricesAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n projectDomain,\n validInputs,\n new Date(),\n null,\n affiliations,\n true\n )\n .then(result => {\n result.forEach(productPrice => {\n const fullProduct: FullProduct | undefined = productCollection.find(x => {\n return x.ProductDetails && x.ProductDetails.RecordId === productPrice.ProductId;\n });\n if (fullProduct) {\n // If RS Version < 9.16.0 (aka 10.0.6), customer contextual price won't be\n // included so instead just use AdjustedPrice\n if (versionLt(ctx.requestContext.apiSettings.retailServerProxyVersion, '9.16.0')) {\n productPrice.CustomerContextualPrice = productPrice.AdjustedPrice;\n }\n fullProduct.ProductPrice = productPrice;\n }\n });\n })\n .catch((error: Error) => {\n const telemetry = ctx.telemetry;\n telemetry.debug('[getActivePricesAsync] Unable to get active price.');\n telemetry.exception(error);\n });\n}\n\nasync function _getProductRatings(\n inputs: FullProductInput[],\n validProductIds: Set,\n productCollection: FullProduct[],\n ctx: IActionContext\n): Promise {\n const validInputs = inputs\n .map(input => {\n if (input.ProductDetailsCriteria.getRating && validProductIds.has(input.productId)) {\n return input.productId;\n }\n })\n .filter(Boolean);\n\n if (validInputs.length === 0) {\n return Promise.resolve();\n }\n\n return getProductRatingsAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n validInputs\n )\n .then(result => {\n result.forEach(productRating => {\n const fullProduct: FullProduct | undefined = productCollection.find(x => {\n return x.ProductDetails && x.ProductDetails.RecordId === productRating.ProductId;\n });\n if (fullProduct) {\n fullProduct.ProductRating = productRating;\n }\n });\n })\n .catch(error => {\n const telemetry = ctx.telemetry;\n telemetry.debug('[getProductRatingsAsync] Unable to get product ratings.');\n telemetry.exception(error);\n });\n}\n\nexport const getFullProductsActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-full-products',\n action: >getFullProductsAction,\n input: createInput,\n isBatched: true\n});\n\nexport default getFullProductsActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { CommerceListLine } from '@msdyn365-commerce/retail-proxy';\nimport { getByCustomerAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CommerceListsDataActions.g';\n\nimport { FullProductInput, getFullProducts, getProductDetailsCriteriaFromActionInput } from '.';\n\n/**\n * Input class for getActiveWishlistItems data action.\n */\nexport class ActiveWishlistInput implements IActionInput {\n public getCacheKey = () => 'ActiveWishlistItems';\n\n public getCacheObjectType = () => 'ActiveWishlistItems';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\nconst createInput = (inputData: ICreateActionContext) => {\n return new ActiveWishlistInput();\n};\n\n/**\n * Calls the Retail API and returns a CommerceList object based on the passed GetCartInput.\n * @param input\n * @param ctx\n */\nexport async function getActiveWishlistItems(input: ActiveWishlistInput, ctx: IActionContext): Promise {\n // If no cart ID is provided in input, we need to create a cart object\n if (!input) {\n throw new Error('[getActiveWishlistItems]No valid Input was provided, failing');\n }\n\n if (ctx.requestContext.user.isAuthenticated) {\n const wishlists = await getByCustomerAsync(\n {\n callerContext: ctx,\n queryResultSettings: {}\n },\n null\n );\n\n if (wishlists && wishlists.length > 0) {\n const productInputs: FullProductInput[] = [];\n if (wishlists[0].CommerceListLines) {\n wishlists[0].CommerceListLines.forEach((commerceListLine: CommerceListLine) => {\n if (commerceListLine.ProductId) {\n productInputs.push(\n new FullProductInput(\n commerceListLine.ProductId,\n ctx.requestContext.apiSettings,\n getProductDetailsCriteriaFromActionInput(ctx),\n ctx.requestContext\n )\n );\n }\n });\n }\n\n if (productInputs.length > 0) {\n return getFullProducts(productInputs, ctx)\n .then(products => {\n if (products) {\n return products;\n }\n return [];\n })\n .catch(error => {\n ctx.trace(error);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getActiveWishlistItems]Unable to hydrate cart with product information');\n throw new Error('[getActiveWishlistItems]Unable to hydrate cart with product information');\n });\n }\n ctx.trace('No productIds found for wishlist');\n } else {\n ctx.trace('[getActiveWishlistItems]Not able to get wishlists for the customer');\n return [];\n }\n }\n ctx.trace('[getActiveWishlistItems]User token not found for wishlists');\n return [];\n}\n\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-items-in-wishlist',\n action: >getActiveWishlistItems,\n input: createInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { SimpleProduct } from '@msdyn365-commerce/retail-proxy';\nimport { Image, ISubList, List } from '@msdyn365-commerce-modules/data-types';\n\nimport GetProducts, { ProductInput } from './get-simple-products';\n\n/**\n * List Input action.\n */\nexport class ListInput implements IActionInput {\n public DocumentId: string;\n\n public Title: string;\n\n public Description: string;\n\n public ShortDescription: string;\n\n public BackgroundColor: string;\n\n public ForegroundColor: string;\n\n public Images: Image[];\n\n public Items: (IProductItem[] | ISubList)[];\n\n public ProductItems: IProductItem[];\n\n public ItemsCount: number;\n\n public ItemsPerPage: number;\n\n public SkipCount: number;\n\n constructor(\n documentId: string,\n title: string,\n description: string,\n shortDescription: string,\n backgroundColor: string,\n foregroundColor: string,\n images: Image[],\n items: (IProductItem[] | ISubList)[],\n productItems: IProductItem[],\n itemsCount: number,\n itemsPerPage: number,\n skipCount: number\n ) {\n this.DocumentId = documentId;\n this.Title = title;\n this.Description = description;\n this.ShortDescription = shortDescription;\n this.BackgroundColor = backgroundColor;\n this.ForegroundColor = foregroundColor;\n this.Images = images;\n this.Items = items;\n this.ProductItems = productItems;\n this.ItemsCount = itemsCount;\n this.ItemsPerPage = itemsPerPage;\n this.SkipCount = skipCount;\n }\n\n public shouldCacheOutput = () => true;\n\n public getCacheObjectType = () => 'LIST';\n\n public getCacheKey = () => `${this.DocumentId}-${this.ItemsCount}-${this.ItemsPerPage}-${this.SkipCount}`;\n}\n\nexport interface IProductItem {\n RecordId: string;\n CatalogId: string;\n}\n\n/**\n * List item type enum.\n */\nenum ListItemType {\n list = 'list',\n product = 'product'\n}\n\n/**\n * Calls to getSimpleProducts to get product array by ID's in list.\n * @param input\n * @param ctx\n */\nexport async function getListData(input: ListInput, ctx: IActionContext): Promise {\n ctx.trace(`List Title: ${input.Title}`);\n\n const { apiSettings } = ctx.requestContext;\n\n const sublists: (SimpleProduct | ISubList)[] = [];\n const result: List = {\n Title: input.Title,\n Description: input.Description,\n ShortDescription: input.ShortDescription,\n BackgroundColor: input.BackgroundColor,\n ForegroundColor: input.ForegroundColor,\n Items: sublists,\n ItemsCount: input.ItemsCount\n };\n\n if (input && input.Items && input.Items.length > 0) {\n // Get all products\n let products: SimpleProduct[] = [];\n if (input.ProductItems && input.ProductItems.length > 0) {\n const inputArray = input.ProductItems.map(\n item => new ProductInput(+item.RecordId, apiSettings, undefined, undefined, ctx.requestContext)\n );\n products = await GetProducts(inputArray, ctx);\n }\n\n // Build map from recordId to product, which will be used later when build the output.\n const productMap: { [recordId: string]: SimpleProduct } = {};\n products.forEach(item => {\n if (item) {\n productMap[`${item.RecordId}`] = item;\n }\n });\n\n for (const listitem of input.Items) {\n if (isSublist(listitem)) {\n result.Items.push(listitem);\n } else {\n listitem.forEach(item => {\n if (productMap[item.RecordId]) {\n result.Items.push(productMap[item.RecordId]);\n }\n });\n }\n }\n }\n\n return result;\n}\n\n/**\n * Check if an item is sublist.\n * @param listItem\n */\nfunction isSublist(listItem: IProductItem[] | ISubList): listItem is ISubList {\n return (listItem).Images !== undefined;\n}\n\n/**\n * Get images.\n * @param images\n */\nfunction getImages(images: IGeneric[]): Image[] {\n const resultImageList: Image[] = [];\n\n if (!images) {\n return resultImageList;\n }\n\n images.forEach(item => {\n if (item && item.image && item.image.href) {\n // Add image item\n const imageItem: Image = {\n href: item.image.href,\n altText: item.image.altText,\n title: item.image.title,\n width: item.image.width,\n height: item.image.height\n };\n\n resultImageList.push(imageItem);\n }\n });\n\n return resultImageList;\n}\n\n/**\n * Get the url of sub list.\n * @param listName\n * @param sitePath\n */\nfunction getSubListUrl(listName: string, sitePath: string): string {\n if (!listName) {\n return '';\n }\n\n if (!sitePath) {\n return `/${listName}.l`;\n }\n\n // SitePath has a leading '/'\n return `${sitePath}/${listName}.l`;\n}\n\n/**\n * Get input list data.\n * @param inputData\n */\nfunction getInutListData(inputData: ICreateActionContext, IGeneric>): IGeneric {\n let listData =\n !inputData || !inputData.requestContext || !inputData.requestContext.pageData ? null : inputData.requestContext.pageData.list;\n if (\n !inputData ||\n !inputData.requestContext ||\n !inputData.requestContext.pageData ||\n !inputData.requestContext.pageData.list ||\n !inputData.requestContext.pageData.list.content ||\n !inputData.requestContext.pageData.list.content.items ||\n !inputData.requestContext.pageData.list.content.title ||\n !inputData.requestContext.pageData.list._id\n ) {\n if (\n !inputData ||\n !inputData.data ||\n !inputData.data.list ||\n !inputData.data.list.content ||\n !inputData.data.list.content.items ||\n !inputData.data.list.content.title ||\n !inputData.data.list._id\n ) {\n console.error('data is not well defined for list action input');\n throw new Error('data is not well defined for list action input');\n }\n\n listData = inputData.data.list;\n }\n return listData;\n}\n\n/**\n * Get sub list item.\n * @param item\n * @param sitePathOfRequest\n */\nfunction getSubListItem(item: IGeneric, sitePathOfRequest: string): ISubList {\n const imageList: Image[] = getImages(item.fields.content.images);\n\n const sublistHref = getSubListUrl(item.fields._name, sitePathOfRequest);\n return {\n Title: item.fields.content.title,\n Description: item.fields.content.description,\n ShortDescription: item.fields.content.shortDescription,\n BackgroundColor: item.fields.content.backgroundColor,\n ForegroundColor: item.fields.content.foregroundColor,\n Href: sublistHref,\n Images: imageList\n };\n}\n\n/**\n * Get site path.\n * @param inputData\n */\nfunction getSitePath(inputData: ICreateActionContext, IGeneric>): string {\n return inputData && inputData.requestContext && inputData.requestContext.sitePath ? inputData.requestContext.sitePath : '';\n}\n\n/**\n * Get items per page.\n * @param inputData\n */\nfunction getItemsPerPage(inputData: ICreateActionContext, IGeneric>): number {\n if (!inputData || !inputData.config || !inputData.config.itemsPerPage) {\n return 50;\n }\n\n const result = Number(inputData.config.itemsPerPage);\n if (isNaN(result)) {\n return 50;\n }\n\n return result;\n}\n\n/**\n * Get skip count.\n * @param inputData\n */\nfunction getSkipCount(inputData: ICreateActionContext, IGeneric>): number {\n return inputData && inputData.requestContext && inputData.requestContext.query && inputData.requestContext.query.skipCount\n ? Number(inputData.requestContext.query.skipCount)\n : 0;\n}\n\n/**\n * Creates the input required to make the list call to get products.\n * @param inputData\n */\nconst createListInput = (inputData: ICreateActionContext, IGeneric>): IActionInput => {\n const listData: IGeneric = getInutListData(inputData);\n const listItems: (IProductItem[] | ISubList)[] = [];\n let productList: IProductItem[] = [];\n\n const parentImageList: Image[] = getImages(listData.content.images);\n\n const itemsPerPage = getItemsPerPage(inputData);\n const skipCount = getSkipCount(inputData);\n\n // This is the list contains all product and will be used to call getSimpleProducts data action.\n const productItems: IProductItem[] = [];\n const sum = skipCount + itemsPerPage;\n for (let index = skipCount; index < listData.content.items.length && index < sum; index++) {\n const item = listData.content.items[index];\n if (item.type === ListItemType.list) {\n if (!item.fields || !item.fields.content || !item.fields.content.title) {\n console.error(`sublist item fields, content or title missing in list ${listData._id}`);\n continue;\n }\n\n // If any elements in product list, then copy it and add to list items\n if (productList.length > 0) {\n const clonedList = [...productList];\n listItems.push(clonedList);\n productList = [];\n }\n\n // Build and add sublist item\n listItems.push(getSubListItem(item, getSitePath(inputData)));\n }\n\n if (item.type === ListItemType.product) {\n if (!item.fields || !item.fields.recordId) {\n console.error(`product item missing recordId in list ${listData._id}`);\n continue;\n }\n\n // Add product item\n const productItem: IProductItem = {\n RecordId: item.fields.recordId,\n CatalogId: item.fields.catalogId || '0'\n };\n\n productList.push(productItem);\n productItems.push(productItem);\n }\n }\n\n // Save the last portion of product items.\n if (productList.length > 0) {\n listItems.push(productList);\n }\n\n return new ListInput(\n listData._id,\n listData.content.title,\n listData.content.description,\n listData.content.shortDescription,\n listData.content.backgroundColor,\n listData.content.foregroundColor,\n parentImageList,\n listItems,\n productItems,\n listData.content.items.length,\n itemsPerPage,\n skipCount\n );\n};\n\nexport const getListDataDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-list',\n action: >getListData,\n input: createListInput\n});\n\nexport default getListDataDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { LoyaltyCard } from '@msdyn365-commerce/retail-proxy';\nimport {\n getCustomerLoyaltyCardsAsync,\n getLoyaltyCardAsync\n} from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\n\nimport { buildCacheKey, QueryResultSettingsProxy } from '.';\n\n/**\n * Input class for the getLoyaltyCard data action.\n */\nexport class GetLoyaltyCardInput implements IActionInput {\n public userAccountNumber?: string;\n\n public apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, userAccountNumber?: string) {\n this.userAccountNumber = userAccountNumber;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey(`GetLoyaltyCard-${this.userAccountNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'GetLoyaltyCard';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the getLoyaltyCard method.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createGetLoyaltyCardInput = (inputData: ICreateActionContext): GetLoyaltyCardInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create get loyalty card input. User is not authenticated.');\n }\n\n return new GetLoyaltyCardInput(inputData.requestContext.apiSettings);\n};\n\n/**\n * The action method for the getLoyaltyCard data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function getLoyaltyAction(input: GetLoyaltyCardInput, ctx: IActionContext): Promise {\n return getCustomerLoyaltyCardsAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n input.userAccountNumber || null\n )\n .then(cards => {\n if (!cards || cards.length === 0) {\n return {};\n }\n\n const firstCard = cards[0];\n\n return getLoyaltyCardAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n firstCard.CardNumber\n )\n .then(card => {\n card.LoyaltyEnrollmentDate = firstCard.LoyaltyEnrollmentDate;\n card.LoyaltyEnrollmentDateLocal = firstCard.LoyaltyEnrollmentDateLocal;\n return card;\n })\n\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('Unable to get loyalty card');\n throw new Error('Unable to get loyalty card');\n });\n })\n .catch(error => {\n ctx.telemetry.exception(error.message);\n ctx.telemetry.debug('Unable to get customers loyalty card');\n throw new Error('Unable to get customers loyalty card');\n });\n}\n\n/**\n * The getLoyaltyCard data action\n * Returns the loyalty card belonging to the customer.\n */\nexport const getLoyaltyActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-loyalty-card',\n action: >getLoyaltyAction,\n input: <(args: ICreateActionContext) => IActionInput>createGetLoyaltyCardInput\n});\n\nexport default getLoyaltyActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { Cart, ChannelConfiguration, LoyaltyCard, LoyaltyPointRedemptionEstimate } from '@msdyn365-commerce/retail-proxy';\nimport { getMaxLoyaltyPointsToRedeemForTransactionBalanceAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CartsDataActions.g';\nimport { getOrgUnitConfigurationAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/OrgUnitsDataActions.g';\n\nimport { buildCacheKey, getLoyalty, GetLoyaltyCardInput } from '.';\n\n/**\n * Input class for the getLoyaltyCard data action.\n */\nexport class GetLoyaltyTransactionEstimationInput implements IActionInput {\n public userAccountNumber?: string;\n\n public apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, userAccountNumber?: string) {\n this.userAccountNumber = userAccountNumber;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey(`GetLoyaltyCardTransactionEstimation-${this.userAccountNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'GetLoyaltyCardTransactionEstimation';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the getLoyaltyCard method.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createGetLoyaltyTransactionEstimationInput = (inputData: ICreateActionContext): GetLoyaltyTransactionEstimationInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n return new GetLoyaltyTransactionEstimationInput(inputData.requestContext.apiSettings);\n }\n\n return new GetLoyaltyTransactionEstimationInput(inputData.requestContext.apiSettings);\n};\n\n/**\n * The action method for the getLoyaltyCard data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function getLoyaltyTransactionEstimationAction(\n input: GetLoyaltyTransactionEstimationInput,\n ctx: IActionContext\n): Promise {\n if (!ctx.requestContext.user.isAuthenticated) {\n return {};\n }\n\n const promises: [Promise, Promise, Promise] = [\n _getCart(ctx),\n _getLoyalty(input, ctx),\n _getOrgUnits(ctx)\n ];\n return Promise.all(promises)\n .then(result => {\n if (result && result.length >= 2 && result[1].CardNumber) {\n return getMaxLoyaltyPointsToRedeemForTransactionBalanceAsync(\n { callerContext: ctx },\n result[0].Id,\n result[1].CardNumber,\n result[2].Currency || ''\n )\n .then(points => {\n return points;\n })\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('Error getting Loyalty Point Redemption Estimate');\n throw new Error('Error getting Loyalty Point Redemption Estimate');\n });\n }\n return {};\n })\n .catch(error => {\n return {};\n });\n}\n\nasync function _getCart(ctx: IActionContext): Promise {\n const cartState = await getCartState(ctx);\n\n return cartState.cart;\n}\n\nasync function _getLoyalty(input: GetLoyaltyTransactionEstimationInput, ctx: IActionContext): Promise {\n const loyaltyCardInput = new GetLoyaltyCardInput(input.apiSettings);\n return getLoyalty(loyaltyCardInput, ctx);\n}\n\nasync function _getOrgUnits(ctx: IActionContext): Promise {\n return getOrgUnitConfigurationAsync({ callerContext: ctx, queryResultSettings: {} });\n}\n\n/**\n * The getLoyaltyTransactionEstimation data action\n * Returns the loyalty card belonging to the customer.\n */\nexport const getLoyaltyTransactionEstimationActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-loyalty-transaction-estimation',\n action: >getLoyaltyTransactionEstimationAction,\n input: <(args: ICreateActionContext) => IActionInput>createGetLoyaltyTransactionEstimationInput\n});\n\nexport default getLoyaltyTransactionEstimationActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getMediaLocationsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport { MediaLocation } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { buildCacheKey, generateImageUrl } from './utilities/utils';\n\n/**\n * Product Input.\n */\nexport class MediaLocationsByIdInput implements IActionInput {\n public productId?: number;\n\n public channelId: number;\n\n public catalogId: number;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, productId?: number, catalogId?: number) {\n this.productId = productId;\n this.channelId = +apiSettings.channelId;\n this.catalogId = catalogId || 0;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () =>\n buildCacheKey(`MediaLocationID-${this.productId && this.productId.toString()}-${this.catalogId}`, this.apiSettings);\n\n public getCacheObjectType = () => 'MediaLocations';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nexport const createMediaLocationsByIdInput = (inputData: ICreateActionContext>): MediaLocationsByIdInput => {\n const productId = (inputData.config && +inputData.config.productId) || undefined;\n const catalogId = getCatalogId(inputData.requestContext);\n return new MediaLocationsByIdInput(inputData.requestContext.apiSettings, productId, catalogId);\n};\n\n/**\n * Calls the Retail API and returns the product based on the passed MediaLocationsByIdInput.\n * @param input\n * @param ctx\n */\nexport async function getMediaLocationsByIdAction(input: MediaLocationsByIdInput, ctx: IActionContext): Promise {\n if (input.productId) {\n return getMediaLocationsAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n input.productId,\n input.channelId,\n input.catalogId\n ).then(response => {\n return response.map(\n (mediaLocation: MediaLocation): MediaLocation => {\n mediaLocation.Uri = generateImageUrl(mediaLocation.Uri, ctx.requestContext.apiSettings);\n mediaLocation.AltText = mediaLocation.AltText ? mediaLocation.AltText : '';\n return mediaLocation;\n }\n );\n });\n }\n return [];\n}\n\nexport const getMediaLocationsByIdActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-media-locations-by-id',\n action: >getMediaLocationsByIdAction,\n input: createMediaLocationsByIdInput\n});\n\nexport default getMediaLocationsByIdActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { AsyncResult, MediaLocation, SimpleProduct } from '@msdyn365-commerce/retail-proxy';\nimport { getMediaLocationsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport getSelectedVariant, { SelectedVariantInput } from './get-selected-variant';\nimport { generateImageUrl, getSelectedProductIdFromActionInput } from './utilities';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * The action input class for the getMediaLocationsForSelectedVariant data action.\n */\nexport class MediaLocationsForSelectedVariantInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public catalogId: number;\n\n public selectedProduct: SimpleProduct | undefined;\n\n constructor(productId: number, channelId: number, selectedProduct?: SimpleProduct, catalogId?: number) {\n this.productId = productId;\n this.channelId = channelId;\n this.catalogId = catalogId || 0;\n this.selectedProduct = selectedProduct;\n }\n\n public getCacheKey = () => 'MediaLocationsForSelectedVariant';\n\n public getCacheObjectType = () => 'MediaLocations';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * The createInput method for the getMediaLocationsForSelectedVariant data action.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createMediaLocationsForSelectedVariantInput = (\n inputData: ICreateActionContext>\n): MediaLocationsForSelectedVariantInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n const catalogId = getCatalogId(inputData.requestContext);\n\n if (productId) {\n return new MediaLocationsForSelectedVariantInput(+productId, +inputData.requestContext.apiSettings.channelId, undefined, catalogId);\n }\n throw new Error('Unable to create MediaLocationsForSelectedVariantInput, no productId found on module config or query');\n};\n\n/**\n * The action method for the getMediaLocationsForSelectedVariant data action.\n * @param input\n * @param ctx\n */\nexport async function getMediaLocationsForSelectedVariantAction(\n input: MediaLocationsForSelectedVariantInput,\n ctx: IActionContext\n): Promise {\n return AsyncResult.resolve()\n .then(() => {\n const activeProduct: SimpleProduct | undefined = input.selectedProduct;\n\n if (!activeProduct) {\n const selectedVariantInput = new SelectedVariantInput(\n input.productId,\n input.channelId,\n undefined,\n undefined,\n ctx.requestContext\n );\n return getSelectedVariant(selectedVariantInput, ctx);\n }\n\n return activeProduct;\n })\n .then(productResult => {\n const activeProduct = productResult?.productVariant ?? productResult;\n\n if (activeProduct) {\n return getMediaLocationsAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n activeProduct.RecordId,\n input.channelId,\n input.catalogId\n ).then(response => {\n return response.map(\n (mediaLocation: MediaLocation): MediaLocation => {\n mediaLocation.Uri = generateImageUrl(mediaLocation.Uri, ctx.requestContext.apiSettings);\n mediaLocation.AltText = mediaLocation.AltText ? mediaLocation.AltText : activeProduct.Name;\n return mediaLocation;\n }\n );\n });\n }\n\n return [];\n })\n .catch(error => {\n ctx.trace(error);\n ctx.telemetry.error(error.message);\n ctx.telemetry.debug('[getMediaLocationsForSelectedVariantAction]Error executing action');\n throw new Error('[getMediaLocationsForSelectedVariantAction]Error executing action');\n });\n}\n\n/**\n * The getMediaLocationsForSelectedVariant data action\n * Gets the currently selected variant for the page via the getSelectedVariant data action,\n * and then gets the media location information for the variant via the MediaLocations RetailServer API.\n */\nexport const getMediaLocationsForSelectedVariantActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-media-locations-for-selected-variant',\n action: >getMediaLocationsForSelectedVariantAction,\n input: createMediaLocationsForSelectedVariantInput\n});\n\nexport default getMediaLocationsForSelectedVariantActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { createObservableDataAction, IAction, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { IDataServiceRequest, retailAction } from '@msdyn365-commerce/retail-proxy/dist';\nimport { createGetOrderShipmentsHistoryInput } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g';\nimport { OrderShipments } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nconst createInput = (inputData: ICreateActionContext>): IDataServiceRequest => {\n if (inputData.requestContext && inputData.requestContext.user && inputData.requestContext.user.isAuthenticated) {\n return createGetOrderShipmentsHistoryInput(\n {\n Paging: {\n Top: 100,\n Skip: 0\n }\n },\n\n // @ts-expect-error\n null\n );\n }\n\n throw new Error('Unable to create order history input. User is not authenticated.');\n};\n\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-order-history',\n action: >retailAction,\n input: createInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { createObservableDataAction, IAction } from '@msdyn365-commerce/core';\nimport { retailAction } from '@msdyn365-commerce/retail-proxy/dist';\nimport { createGetOrgUnitConfigurationInput } from '@msdyn365-commerce/retail-proxy/dist/DataActions/OrgUnitsDataActions.g';\nimport { ProductSearchResult } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\n/**\n * Get Org Unit Configuration Data Action.\n */\nexport const retailActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-org-unit-configuration',\n action: >retailAction,\n input: () => {\n return createGetOrgUnitConfigurationInput();\n }\n});\n\nexport default retailActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { getCurrentAsync, getUsersAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/BusinessPartnersDataActions.g';\n\n/**\n * Input class for get customer data action.\n */\nexport class OrganizationUsersCountInput implements IActionInput {\n public getCacheKey = () => 'OrganizationUsersCount';\n\n public getCacheObjectType = () => 'BusinessPartner';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\nexport const createGetOrganizationUsersCountInput = (inputData: ICreateActionContext): IActionInput => {\n const { requestContext } = inputData;\n\n // Check if the user is authenticated.\n if (!requestContext.user.isAuthenticated) {\n throw new Error('User is not logged in.');\n }\n\n return new OrganizationUsersCountInput();\n};\n\nexport async function getOrganizationUsersCount(input: OrganizationUsersCountInput, ctx: IActionContext): Promise {\n return getCurrentAsync({ callerContext: ctx })\n .then(businessPartner => {\n if (!businessPartner) {\n return 0;\n }\n\n return getUsersAsync({ callerContext: ctx }, businessPartner.BusinessPartnerId)\n .then(users => {\n return users.length;\n })\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.trace('[get-organization-users-count] Unable to load users');\n throw new Error('[get-organization-users-count] Unable to load users');\n });\n })\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[get-organization-users-count] Unable to get BusinessPartner');\n throw new Error('[get-organization-users-count] Unable to get BusinessPartner');\n });\n}\nexport default createObservableDataAction({\n id: 'get-organization-users-count',\n action: >(getOrganizationUsersCount),\n input: createGetOrganizationUsersCountInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { BusinessPartnerUser } from '@msdyn365-commerce/retail-proxy';\nimport { getCurrentAsync, getUsersAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/BusinessPartnersDataActions.g';\n\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input class for get customer data action.\n */\nexport class OrganizationUsersInput implements IActionInput {\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings) {\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('OrganizationUsers', this.apiSettings);\n\n public getCacheObjectType = () => 'BusinessPartner';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\nexport const createGetOrganizationUsersInput = (inputData: ICreateActionContext): IActionInput => {\n const { requestContext } = inputData;\n\n // Check if the user is authenticated.\n if (!requestContext.user.isAuthenticated) {\n throw new Error('User is not logged in.');\n }\n\n return new OrganizationUsersInput(requestContext.apiSettings);\n};\n\nexport async function getOrganizationUsers(input: OrganizationUsersInput, ctx: IActionContext): Promise {\n return getCurrentAsync({ callerContext: ctx })\n .then(businessPartner => {\n return getUsersAsync({ callerContext: ctx }, businessPartner.BusinessPartnerId)\n .then(users => {\n return users;\n })\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.trace('[get-organization-users] Unable to load users');\n throw new Error('[get-organization-users] Unable to load users');\n });\n })\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[get-organization-users] Unable to get BusinessPartner');\n throw new Error('[get-organization-users] Unable to get BusinessPartner');\n });\n}\nexport const getOrganizationUsersDataAction = createObservableDataAction({\n id: 'get-organization-users',\n action: >(getOrganizationUsers),\n input: createGetOrganizationUsersInput\n});\n\nexport default getOrganizationUsersDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { convertToString, IQueryResultSettings } from '@msdyn365-commerce/retail-proxy';\nimport { getCurrentAsync, getOrderHistoryAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/BusinessPartnersDataActions.g';\nimport { OrderShipments } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Input class for the GetOrganizationWideOrderHistory data action.\n */\nexport class GetOrganizationWideOrderHistoryInput implements IActionInput {\n public queryResultSettings: IQueryResultSettings;\n\n constructor(queryResultSettings: IQueryResultSettings) {\n this.queryResultSettings = queryResultSettings;\n }\n\n public getCacheKey = () => `GetOrganizationWideOrderHistoryInput|${convertToString(this.queryResultSettings)}`;\n\n public getCacheObjectType = () => 'GetOrganizationWideOrderHistoryInput';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the GetOrganizationWideOrderHistory method.\n * @param {ICreateActionContext} inputData The input data passed to the createInput method.\n */\nexport const getOrganizationWideOrderHistoryInput = (inputData: ICreateActionContext): GetOrganizationWideOrderHistoryInput => {\n if (!inputData?.requestContext?.user?.isAuthenticated) {\n throw new Error('Unable to get order history. User is not authenticated.');\n }\n\n const queryResultSettings: IQueryResultSettings = QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings;\n return new GetOrganizationWideOrderHistoryInput(queryResultSettings);\n};\n\n/**\n * The action method for the GetOrganizationWideOrderHistory data action.\n * @param {GetOrganizationWideOrderHistory} input The action input.\n * @param {IActionContext} ctx The action context.\n * @param context\n */\nexport async function getOrganizationWideOrderHistory(\n input: GetOrganizationWideOrderHistoryInput,\n context: IActionContext\n): Promise {\n if (!context?.requestContext?.user?.isAuthenticated) {\n throw new Error('Unable to get order history. User is not authenticated.');\n }\n\n const businessPartner = await getCurrentAsync({ callerContext: context });\n if (!businessPartner) {\n throw new Error('Unable to get order history. Failed to retrieve business partner id.');\n }\n\n return getOrderHistoryAsync(\n { callerContext: context, queryResultSettings: input.queryResultSettings },\n businessPartner.BusinessPartnerId\n );\n}\n\nexport const getOrganizationWideOrderHistoryDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-organization-wide-order-history',\n action: >getOrganizationWideOrderHistory,\n input: getOrganizationWideOrderHistoryInput\n});\n\nexport default getOrganizationWideOrderHistoryDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { ProductDeliveryOptions, ProductsDataActions } from '@msdyn365-commerce/retail-proxy';\n\nimport { ActiveCartProductsInput, buildCacheKey, getActiveCartProductsAction } from '.';\nimport { ArrayExtensions } from './utilities';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Input class for pickup delivery options for items in cart.\n */\nexport class ProductPickUpOptionsForCartLineItems implements IActionInput {\n public readonly apiSettings: ICommerceApiSettings;\n\n public constructor(apiSettings: ICommerceApiSettings) {\n this.apiSettings = apiSettings;\n }\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n public getCacheKey = (): string => buildCacheKey('ActiveCartLineItemsPickUpOptions', this.apiSettings);\n\n /**\n * Get Cachetype Name.\n * @returns - Cache name string.\n */\n public getCacheObjectType = (): string => 'ActiveCartLineItemsPickUpOptions';\n\n /**\n * Get Cachetype.\n * @returns - CacheType enum.\n */\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the GetPickUpOptionCartLineItems method.\n * @param inputData - The input data passed to the createInput method.\n * @returns - Input for data action.\n */\nconst createInput = (inputData: ICreateActionContext>) => {\n return new ProductPickUpOptionsForCartLineItems(inputData.requestContext.apiSettings);\n};\n\n/**\n * The action method for the GetPickUpOptionCartLineItems data action.\n * @param input - The action input.\n * @param context - The action context.\n * @returns - Order Template object.\n */\nexport async function getPickUpOptionsForCartLineItems(\n input: ProductPickUpOptionsForCartLineItems,\n context: IActionContext\n): Promise {\n // If no input is provided fail out\n if (!input.apiSettings.channelId) {\n throw new Error('[getPickUpOptionsForCartLineItems]No valid Input was provided, failing');\n }\n const cartState = await getCartState(context);\n const cart = cartState.cart;\n const products = await getActiveCartProductsAction(new ActiveCartProductsInput(), context);\n const filterOption = 4;\n const response: ProductDeliveryOptions[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- existing code.\n if (cart === undefined || !ArrayExtensions.hasElements(products)) {\n return Promise.resolve(response);\n }\n\n const pickupoptions = await ProductsDataActions.getDeliveryOptionsAsync(\n {\n callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\n },\n products.map(product => product.RecordId),\n {},\n filterOption\n );\n\n return pickupoptions;\n}\n\n/**\n * The GetPickupOptionCartLineItems Data Action\n * Returns pickup options.\n */\nexport const getPickUpOptionsForCartLineItemsDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-pickup-options-for-cartlines',\n action: getPickUpOptionsForCartLineItems as IAction,\n input: createInput\n});\n\nexport default getPickUpOptionsForCartLineItemsDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext, IActionInput } from '@msdyn365-commerce/core';\nimport { getCartFromCustomer } from '@msdyn365-commerce/global-state';\nimport { ProductPrice, ProductsDataActions, ProductSearchResult, ProjectionDomain } from '@msdyn365-commerce/retail-proxy';\n\nimport { ArrayExtensions } from './utilities';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Input class for the GetPriceForProductSearchResult Data Action.\n */\nexport class PriceForProductSearchResultInput implements IActionInput {\n public products: ProductSearchResult[];\n\n public constructor(products: ProductSearchResult[]) {\n this.products = products;\n }\n\n /**\n * Get the cache key.\n * @returns The cache key.\n */\n public getCacheKey = (): string => `PriceForProductSearchResult-${JSON.stringify(this.products)}`;\n\n /**\n * Get the cache object type.\n * @returns The cache object type.\n */\n public getCacheObjectType = (): string => 'ProductSearchResult';\n\n /**\n * Define the data cache type.\n * @returns The cache type.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * The createInput method for the GetPriceForProductSearchResultDataAction.\n * @param products -- The product search result.\n * @returns The input.\n */\nexport const createActivePriceForProductSearchResultInput = (products: ProductSearchResult[]): PriceForProductSearchResultInput => {\n return new PriceForProductSearchResultInput(products);\n};\n\n/**\n * The Action Method for the GetPriceForProductSearchResult Data Action\n * Gets the active price for product search result via the getActivePrice RetailServer API.\n * @param input -- The data input.\n * @param context -- The action context.\n * @returns The product search result updated with price.\n */\nexport async function getPriceForProductSearchResultAction(\n input: PriceForProductSearchResultInput,\n context: IActionContext\n): Promise {\n let productRecIds: number[];\n if (ArrayExtensions.hasElements(input.products)) {\n productRecIds = input.products.map(product => product.RecordId);\n } else {\n return Promise.resolve([]);\n }\n\n const catalogId = getCatalogId(context.requestContext);\n\n const projectDomain: ProjectionDomain = { ChannelId: +context.requestContext.apiSettings.channelId, CatalogId: catalogId };\n const cart = await getCartFromCustomer(context);\n const affiliation = cart?.AffiliationLines;\n const priceZero = 0;\n\n try {\n const productPrices: ProductPrice[] = await ProductsDataActions.getActivePricesAsync(\n { callerContext: context, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context) },\n projectDomain,\n productRecIds,\n new Date(),\n null,\n affiliation,\n true\n );\n\n const productResults: ProductSearchResult[] = input.products.map(product => {\n const activePrice = productPrices.find(price => price.ProductId === product.RecordId);\n if (activePrice) {\n product.Price = activePrice.CustomerContextualPrice ?? product.Price;\n product.BasePrice = Math.max(\n activePrice.BasePrice ?? priceZero,\n activePrice.TradeAgreementPrice ?? priceZero,\n activePrice.AdjustedPrice ?? priceZero\n );\n }\n return product;\n });\n\n return Promise.resolve(productResults);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- existing error type.\n context.telemetry.exception(error);\n context.telemetry.debug('[getPriceForProductSearchResultAction]Error executing action');\n throw new Error('[getPriceForProductSearchResultAction]Error executing action');\n }\n}\n\n/**\n * The getPriceForProductSearchResult data action.\n */\nexport const getPriceForProductSearchResultDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-price-for-product-search-result',\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- existing pattern.\n action: >getPriceForProductSearchResultAction,\n input: createActivePriceForProductSearchResultInput\n});\n\nexport default getPriceForProductSearchResultDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getCartFromCustomer } from '@msdyn365-commerce/global-state';\nimport { FeatureState } from '@msdyn365-commerce/retail-proxy';\nimport { getActivePricesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport {\n AffiliationLoyaltyTier,\n ProductPrice,\n ProductType,\n ProjectionDomain,\n SimpleProduct\n} from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { getSelectedProductIdFromActionInput, getSelectedVariant, SelectedVariantInput } from '.';\nimport { FeatureStateInput, getFeatureStateActionDataAction } from './get-feature-state';\nimport { ArrayExtensions } from './utilities';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Input class for the GetPriceForSelectedVariant Data Action.\n */\nexport class PriceForSelectedVariantInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public selectedProduct: SimpleProduct | undefined;\n\n public customerId?: string;\n\n public constructor(productId: number, channelId: number, selectedProduct?: SimpleProduct, customerId?: string) {\n this.productId = productId;\n this.channelId = channelId;\n this.selectedProduct = selectedProduct;\n this.customerId = customerId ?? '';\n }\n\n public getCacheKey = (): string => 'PriceForSelectedVariant';\n\n public getCacheObjectType = (): string => 'Price';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * The createInput method for the GetPriceForSelectedVariantDataAction.\n * @param inputData - The input data for the createInput method.\n * @returns The PriceForSelectedVariantInput.\n */\nexport const createActivePriceForSelectedVariantInput = (inputData: ICreateActionContext>): PriceForSelectedVariantInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n\n if (productId) {\n return new PriceForSelectedVariantInput(+productId, +inputData.requestContext.apiSettings.channelId, undefined);\n }\n throw new Error('Unable to create PriceForSelectedVariantInput, no productId found on module config or query');\n};\n\n/**\n * The Action Method for the GetPriceForSelectedVariant Data Action\n * Pulls the currently selected variant from the cache using the getSelectedVariant data action, and gets it's current contextual price\n * via the getActivePrice RetailServer API.\n * @param input - The input.\n * @param ctx - The ctx.\n * @returns The Promise.\n */\nexport async function getPriceForSelectedVariantAction(\n input: PriceForSelectedVariantInput,\n ctx: IActionContext\n): Promise {\n let affiliations: AffiliationLoyaltyTier[] | undefined = [];\n if (ctx.requestContext.user.isAuthenticated) {\n const cart = await getCartFromCustomer(ctx);\n affiliations = cart?.AffiliationLines;\n }\n return Promise.resolve()\n .then(() => {\n const activeProduct: SimpleProduct | undefined = input.selectedProduct;\n\n if (!activeProduct) {\n const selectedVariantInput = new SelectedVariantInput(\n input.productId,\n input.channelId,\n undefined,\n undefined,\n ctx.requestContext\n );\n\n return getSelectedVariant(selectedVariantInput, ctx);\n }\n\n return activeProduct;\n })\n .then(async (productResult: SimpleProduct | null) => {\n const catalogId = getCatalogId(ctx.requestContext);\n const projectDomain: ProjectionDomain = {\n ChannelId: +ctx.requestContext.apiSettings.channelId,\n CatalogId: catalogId\n };\n\n const activeProduct: SimpleProduct | undefined = productResult as SimpleProduct | undefined;\n if (activeProduct) {\n const featureStates: FeatureState[] = await getFeatureStateActionDataAction(new FeatureStateInput(), ctx);\n return getActivePricesAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n projectDomain,\n [activeProduct.RecordId],\n new Date(),\n input.customerId,\n affiliations,\n true,\n featureStates.find(featureState => featureState.Name === 'Dynamics.AX.Application.RetailSearchPriceRangeFeature')\n ?.IsEnabled &&\n (activeProduct.ProductTypeValue === ProductType.Master || activeProduct.ProductTypeValue === ProductType.KitMaster),\n featureStates.find(\n featureState => featureState.Name === 'Dynamics.AX.Application.RetailSalesAgreementPriceSupportFeature'\n )?.IsEnabled\n ).then((productPrices: ProductPrice[]) => {\n if (!ArrayExtensions.hasElements(productPrices)) {\n throw new Error('[getPriceForSelectedVariantAction]Invalid response recieved from getActivePricesAsync');\n }\n return productPrices[0];\n });\n }\n\n return null;\n })\n .catch((error: Error) => {\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getPriceForSelectedVariantAction]Error executing action');\n throw new Error('[getPriceForSelectedVariantAction]Error executing action');\n });\n}\n\nexport const getPriceForSelectedVariantActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-price-for-selected-variant',\n action: getPriceForSelectedVariantAction as IAction,\n input: createActivePriceForSelectedVariantInput\n});\n\nexport default getPriceForSelectedVariantActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport {\n ProductAvailableQuantity,\n ProductsDataActions,\n ProductType,\n ProductWarehouseInventoryAvailability,\n ReleasedProductType\n} from '@msdyn365-commerce/retail-proxy';\n\nimport getSelectedVariant, { SelectedVariantInput } from './get-selected-variant';\nimport { ArrayExtensions, getSelectedProductIdFromActionInput } from './utilities';\nimport { DeliveryMode, IProductInventoryInformation } from './utilities/product-inventory-information';\nimport { createInventoryAvailabilitySearchCriteria, mapAggregatedProductInventoryInformation } from './utilities/product-inventory-utils';\n\n/**\n * Input class for the getProductAvailabilitiesForSelectedVariant Data Action.\n */\nexport class ProductAvailabilitiesForSelectedVariantInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public constructor(productId: number | string, channelId: number) {\n this.productId = typeof productId === 'string' ? +productId : productId;\n this.channelId = channelId;\n }\n\n /**\n * GetCacheKey.\n * @returns - Returns string.\n */\n public getCacheKey = (): string => 'ProductAvailabilitiesForSelectedVariant';\n\n /**\n * GetCacheObjectType.\n * @returns - Cache Object Type string.\n */\n public getCacheObjectType = (): string => 'ProductAvailabilities';\n\n /**\n * DataCacheType.\n * @returns - CacheType string.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the getProductAvailabilitiesForSelectedVariant data action.\n * @param inputData - The input data passed to the createInput method.\n * @returns - ProductAvailabilitiesForSelectedVariant or error.\n */\nexport const createProductAvailabilitiesForSelectedVariantInput = (\n inputData: ICreateActionContext>\n): ProductAvailabilitiesForSelectedVariantInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n\n if (productId) {\n return new ProductAvailabilitiesForSelectedVariantInput(+productId, +inputData.requestContext.apiSettings.channelId);\n }\n throw new Error('Unable to create ProductAvailabilitiesForSelectedVariantInput, no productId found on module config or query');\n};\n\n/**\n * The action method for the getProductAvailabilitiesForSelectedVariant data action.\n * @param input - ProductAvailabilitiesForSelectedVariant.\n * @param ctx - Action Context.\n * @returns - Product inventory information.\n */\nexport async function getProductAvailabilitiesForSelectedVariantAction(\n input: ProductAvailabilitiesForSelectedVariantInput,\n ctx: IActionContext\n): Promise {\n const selectedVariantInput = new SelectedVariantInput(input.productId, input.channelId, undefined, undefined, ctx.requestContext);\n const productInventoryInformation: IProductInventoryInformation[] = [];\n\n try {\n const productResult = await getSelectedVariant(selectedVariantInput, ctx);\n\n // Don't get availability if it is service item && enableStockCheck is disbaled.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Reading config.\n if (\n ctx.requestContext.app.config.enableStockCheck &&\n productResult &&\n productResult.ItemTypeValue !== ReleasedProductType.Service &&\n productResult.ProductTypeValue !== ProductType.Master\n ) {\n const shippingSearchCriteria = createInventoryAvailabilitySearchCriteria(\n ctx,\n [productResult.RecordId],\n true,\n undefined,\n undefined,\n DeliveryMode.shipping\n );\n const pickupSearchCriteria = createInventoryAvailabilitySearchCriteria(\n ctx,\n [input.productId],\n false,\n true,\n undefined,\n DeliveryMode.pickup\n );\n const shippingAvailability = await ProductsDataActions.getEstimatedAvailabilityAsync(\n { callerContext: ctx },\n shippingSearchCriteria\n );\n if (shippingAvailability.ProductWarehouseInventoryAvailabilities) {\n const shippingInventory = mapAggregatedProductInventoryInformation(ctx, shippingAvailability);\n if (ArrayExtensions.hasElements(shippingInventory)) {\n shippingInventory[0].deliveryType = DeliveryMode.shipping;\n productInventoryInformation.push(shippingInventory[0]);\n }\n }\n const pickupAvailability = await ProductsDataActions.getEstimatedAvailabilityAsync(\n { callerContext: ctx },\n pickupSearchCriteria\n );\n if (pickupAvailability.ProductWarehouseInventoryAvailabilities) {\n const pickupInventory = mapAggregatedProductInventoryInformation(ctx, pickupAvailability);\n if (ArrayExtensions.hasElements(pickupInventory)) {\n pickupInventory[0].deliveryType = DeliveryMode.pickup;\n productInventoryInformation.push(pickupInventory[0]);\n }\n }\n return productInventoryInformation;\n }\n return undefined;\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- cann't assign type to the error variable.\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getPriceForSelectedVariantAction]Error executing action');\n return undefined;\n }\n}\n\n/**\n * The function that maps a ProductWareHouse object into a ProductAvailabilityQuantity.\n * @param productsWarehouseInventory - Product warehouse inventory.\n * @returns Product Available quantity.\n */\nexport function mergeProductWarehouseToProductAvailabities(\n productsWarehouseInventory: ProductWarehouseInventoryAvailability[]\n): ProductAvailableQuantity[] {\n const productAvailable: ProductAvailableQuantity[] = [];\n if (ArrayExtensions.hasElements(productsWarehouseInventory)) {\n for (const product of productsWarehouseInventory) {\n if (product.TotalAvailable !== undefined && product.ProductId !== undefined) {\n productAvailable.push({ ProductId: product.ProductId, AvailableQuantity: product.TotalAvailable });\n }\n }\n }\n return productAvailable;\n}\n\n/**\n * The complete getProductAvailabilitiesForSelectedVariant data action\n * Get the currently selected variant via the getSelectedVariant data action, and\n * then gets the availabilities for the variant via the getProductAvailabilities RetailServer API.\n */\nexport const getProductAvailabilitiesForSelectedVariantActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-product-availabilities-for-selected-variant',\n action: >getProductAvailabilitiesForSelectedVariantAction,\n input: createProductAvailabilitiesForSelectedVariantInput\n});\n\nexport default getProductAvailabilitiesForSelectedVariantActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IProductDimensionsWithAvailabilitiesFull } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport { ProductDimensionAvailabilitySearchCriteria, ProductsDataActions } from '@msdyn365-commerce/retail-proxy';\n\nimport { ArrayExtensions, getSelectedProductIdFromActionInput } from './utilities';\nimport { createInventoryAvailabilitySearchCriteria } from './utilities/product-inventory-utils';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Product dimension with availability Input.\n */\nexport class ProductDimensionsWithAvailabilitiesInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public catalogId?: number;\n\n public constructor(productId: number, channelId: number, requestContext?: IRequestContext) {\n this.productId = productId;\n this.channelId = channelId;\n\n if (requestContext) {\n this.catalogId = getCatalogId(requestContext);\n }\n }\n\n /**\n * Cache key.\n * @returns String.\n */\n public getCacheKey: () => string = () => 'ProductDimensionsWithAvailabilities';\n\n /**\n * Cache object type.\n * @returns String.\n */\n public getCacheObjectType: () => string = () => 'ProductDimensionsWithAvailabilities';\n\n /**\n * Cache type.\n * @returns String.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Create input method for the get-product-dimension-with-availability data action.\n * @param inputData - The input data passed to the createInput method.\n * @returns - The input for the data action.\n */\nexport const createProductDimensionsWithAvailabilitiesInput = (\n inputData: ICreateActionContext>\n): ProductDimensionsWithAvailabilitiesInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n\n if (productId) {\n return new ProductDimensionsWithAvailabilitiesInput(\n +productId,\n +inputData.requestContext.apiSettings.channelId,\n inputData.requestContext\n );\n }\n throw new Error('Unable to create ProductDimensionsWithAvailabilitiesInput, no productId found on module config or query');\n};\n\n/**\n * Action method for the getProductDimensionsWithAvailabilities Data Action.\n * @param input - Input for the data action.\n * @param context - Action context.\n * @returns Product dimensions with availabilities.\n */\nexport async function getProductDimensionsWithAvailabilitiesAction(\n input: ProductDimensionsWithAvailabilitiesInput,\n context: IActionContext\n): Promise {\n const activeProducts = ArrayExtensions.validValues(\n await ProductsDataActions.getByIdsAsync(\n {\n callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\n },\n input.channelId,\n [input.productId],\n null,\n input.catalogId ?? 0\n )\n );\n\n if (!ArrayExtensions.hasElements(activeProducts)) {\n return [];\n }\n\n const activeProduct = activeProducts[0];\n\n if (!ArrayExtensions.hasElements(activeProduct.Dimensions)) {\n return [];\n }\n\n const promises = activeProduct.Dimensions.map(dimension => {\n const shippingInventoryConfiguration = createInventoryAvailabilitySearchCriteria(context, [], true, undefined, undefined);\n const searchCriteria: ProductDimensionAvailabilitySearchCriteria = {\n RequestedDimensionTypeValue: dimension.DimensionTypeValue,\n MatchingDimensionValues: [],\n DefaultWarehouseOnly: shippingInventoryConfiguration.DefaultWarehouseOnly,\n FilterByChannelFulfillmentGroup: shippingInventoryConfiguration.FilterByChannelFulfillmentGroup,\n DeliveryModeTypeFilterValue: shippingInventoryConfiguration.DeliveryModeTypeFilterValue,\n CatalogId: input.catalogId\n };\n\n const dimensionValuesPromise = ProductsDataActions.getDimensionValuesWithEstimatedAvailabilitiesAsync(\n { callerContext: context, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context) },\n activeProduct.MasterProductId ? activeProduct.MasterProductId : activeProduct.RecordId,\n searchCriteria\n );\n const fullDimensionPromise = dimensionValuesPromise.then(dimensionValues => {\n const fullDimension: IProductDimensionsWithAvailabilitiesFull = {\n ...dimension,\n dimensionValuesWithInventory: dimensionValues\n };\n return fullDimension;\n });\n\n return fullDimensionPromise;\n });\n\n // eslint-disable-next-line no-return-await -- existing code\n return await Promise.all(promises);\n}\n\n/**\n * The GetProductDimensionsWithAvailabilitiesAction\n * Gets the available product dimensions for the product via the getDimensionValueswithEstimatedAvailibilities RetailServer API.\n */\nexport const getProductDimensionsWithAvailabilities = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-product-dimensions-with-availabilities',\n action: getProductDimensionsWithAvailabilitiesAction as IAction,\n input: createProductDimensionsWithAvailabilitiesInput\n});\n\nexport default getProductDimensionsWithAvailabilities;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport { ProductListLine } from '@msdyn365-commerce/retail-proxy';\n\n/**\n * QuickOrderTemplateLine state information.\n */\nexport class QuickOrderTemplateLine {\n public productListLine: ProductListLine;\n\n public fullProduct?: FullProduct;\n\n public constructor(productListLine: ProductListLine, fullProduct?: FullProduct) {\n this.productListLine = productListLine;\n this.fullProduct = fullProduct;\n }\n}\n\n/**\n * Quick Order template line state.\n */\nexport interface IQuickOrderTemplateLinesState {\n lines: QuickOrderTemplateLine[];\n totalCount: number;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput } from '@msdyn365-commerce/core';\nimport { ProductListsDataActions } from '@msdyn365-commerce/retail-proxy';\n\nimport getFullProducts, { FullProductInput } from './get-full-products';\nimport { ArrayExtensions } from './utilities';\nimport { IQuickOrderTemplateLinesState, QuickOrderTemplateLine } from './utilities/quick-order-template-line';\nimport { getProductDetailsCriteriaFromActionInput } from './utilities/utils';\n\n/**\n * Input class for the GetProductListLines data action.\n *\n */\nexport class GetProductListLinesInput implements IActionInput {\n public productListId: string;\n\n public searchText: string;\n\n public constructor(productListId: string, searchText?: string) {\n this.productListId = productListId;\n this.searchText = searchText ?? '';\n }\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n public getCacheKey = (): string => `GetProductListLines|${this.productListId}|${this.searchText}`;\n\n /**\n * Get Cachetype Name.\n * @returns - Cache name string.\n */\n public getCacheObjectType = (): string => 'GetProductListLines';\n\n /**\n * Get Cachetype.\n * @returns - CacheType enum.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the GetProductListLines method.\n * @param productListId - ProductList Id.\n * @param searchText - Search Text.\n * @returns - Input data for getproductlistlines.\n */\nexport const createGetProductListLinesInput = (productListId: string, searchText?: string): GetProductListLinesInput => {\n return new GetProductListLinesInput(productListId, searchText);\n};\n\n/**\n * The action method for the GetProductListLines data action.\n * @param input - The action input.\n * @param context - The action context.\n * @returns - Product list lines.\n */\nexport async function getProductListLinesAction(\n input: GetProductListLinesInput,\n context: IActionContext\n): Promise {\n if (!context.requestContext.user.isAuthenticated) {\n throw new Error('Unable to get full product list lines. User is not authenticated.');\n }\n\n const quickOrderTemplateLinesState: IQuickOrderTemplateLinesState = {\n lines: [],\n totalCount: 0\n };\n\n const promise = ProductListsDataActions.getProductListLinesAsync(\n {\n callerContext: context\n },\n input.productListId,\n input.searchText\n );\n\n const productListLines = await promise;\n const productInputs: FullProductInput[] = [];\n\n if (ArrayExtensions.hasElements(productListLines)) {\n quickOrderTemplateLinesState.totalCount = promise.metadata.count ?? quickOrderTemplateLinesState.lines.length;\n productListLines.map(listLine => {\n if (listLine.ProductId) {\n quickOrderTemplateLinesState.lines.push(new QuickOrderTemplateLine(listLine));\n productInputs.push(\n new FullProductInput(\n listLine.ProductId,\n context.requestContext.apiSettings,\n getProductDetailsCriteriaFromActionInput(context),\n context.requestContext\n )\n );\n }\n return productInputs;\n });\n if (ArrayExtensions.hasElements(productInputs)) {\n const fullProductsInfo = await getFullProducts(productInputs, context)\n .then((products: FullProduct[]) => {\n return products;\n })\n .catch((error: Error) => {\n context.trace(error.message);\n context.telemetry.error('[getProductListLinesAction] Unable to retrieve product info.');\n });\n if (fullProductsInfo) {\n quickOrderTemplateLinesState.lines.map(line => {\n const fullProduct = fullProductsInfo.find(\n product => product.ProductDetails.RecordId === line.productListLine.ProductId\n );\n if (!fullProduct) {\n context.telemetry.error('[getProductListLinesAction] Unable to find product info for an product list line.');\n return null;\n }\n line.fullProduct = fullProduct;\n return null;\n });\n }\n return quickOrderTemplateLinesState;\n }\n context.trace(quickOrderTemplateLinesState.lines.length.toString());\n return quickOrderTemplateLinesState;\n }\n return quickOrderTemplateLinesState;\n}\n\n/**\n * The GetProductListLines Data Action\n * Returns order templates.\n */\nexport const getProductListLinesActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-product-list-lines',\n action: getProductListLinesAction as IAction,\n input: createGetProductListLinesInput\n});\n\nexport default getProductListLinesActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport {\n ProductList,\n ProductListsDataActions,\n ProductListSearchCriteria,\n ProductListType,\n QueryResultSettings\n} from '@msdyn365-commerce/retail-proxy';\n\n/**\n * Input class for the GetProductList data action.\n */\nexport class GetProductListInput implements IActionInput {\n public readonly productListId: string;\n\n public readonly queryResultSettings?: QueryResultSettings;\n\n public constructor(productListId?: string, queryResultSettings?: QueryResultSettings) {\n this.productListId = productListId ? productListId : '';\n this.queryResultSettings = queryResultSettings;\n }\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n public getCacheKey = (): string => 'ProductList';\n\n /**\n * Get Cachetype Name.\n * @returns - Cache name string.\n */\n public getCacheObjectType = (): string => 'ProductList';\n\n /**\n * Get Cachetype.\n * @returns - CacheType enum.\n */\n public dataCacheType = (): CacheType => 'none';\n\n /**\n * Set Cache output.\n * @returns - Flag for cache output.\n */\n public shouldCacheOutput = (): boolean => false;\n}\n\n/**\n * CreateInput method for the GetProductList method.\n * @param inputData - The input data passed to the createInput method.\n * @param productListId - The product list identifier.\n * @param queryResultSettings - The query result setting required for pagination/ordering.\n * @returns - Product List input.\n */\nexport const createGetProductListInput = (\n inputData: ICreateActionContext,\n productListId?: string,\n queryResultSettings?: QueryResultSettings\n): GetProductListInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create get product list. User is not authenticated.');\n }\n\n return new GetProductListInput(productListId ? productListId : '', queryResultSettings);\n};\n\n/**\n * The action method for the GetProductList data action.\n * @param input - The action input.\n * @param context - The action context.\n * @returns - ProductList array.\n */\nexport async function getProductListAction(input: GetProductListInput, context: IActionContext): Promise {\n const productListType = ProductListType.QuickOrder.toString();\n const productListSearchCriteria: ProductListSearchCriteria = {\n ProductListType: productListType\n };\n const productLists = await ProductListsDataActions.searchAsync(\n {\n callerContext: context,\n queryResultSettings: input.queryResultSettings\n },\n productListSearchCriteria\n ).then(result => {\n return result;\n });\n\n return productLists;\n}\n\n/**\n * The GetProductList Data Action\n * Returns product list.\n */\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-product-list',\n action: getProductListAction as IAction,\n input: createGetProductListInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { ProductSearchResult, SimpleProduct } from '@msdyn365-commerce/retail-proxy';\nimport { searchByCategoryAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport getCurrentCategory, { CurrentCategoryInput } from './get-current-category';\nimport getProducts, { ProductInput } from './get-simple-products';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Product by category ID Input action.\n */\nexport class ProductsByCategoryInput implements IActionInput {\n public categoryId?: number;\n\n public categorySlug?: string;\n\n public categoryName?: string;\n\n public catalogId: number;\n\n public currentCategory: CurrentCategoryInput;\n\n public readonly queryResultSettingsProxy: QueryResultSettingsProxy;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(category: CurrentCategoryInput, apiSettings: ICommerceApiSettings, queryResultSettingsProxy: QueryResultSettingsProxy) {\n this.apiSettings = apiSettings;\n this.currentCategory = category;\n this.queryResultSettingsProxy = queryResultSettingsProxy;\n this.catalogId = apiSettings.catalogId;\n this.categoryId = category.categoryId;\n this.categorySlug = category.categorySlug;\n }\n\n public getCacheKey = () =>\n buildCacheKey(\n `${this.categoryId || this.categorySlug}|${this.catalogId}|${this.queryResultSettingsProxy.cacheKeyHint}`,\n this.apiSettings\n );\n\n public getCacheObjectType = () => 'Products-From-Search';\n\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * CreateInput method for the getProductsByCategory data aciton.\n * @param inputData\n */\nexport const createGetProductsByCategoryInput = (inputData: ICreateActionContext>): IActionInput => {\n if (inputData && inputData.requestContext) {\n const currentCategory = new CurrentCategoryInput(inputData.requestContext);\n const queryResultSettingsProxy = QueryResultSettingsProxy.fromInputData(inputData);\n return new ProductsByCategoryInput(currentCategory, inputData.requestContext.apiSettings, queryResultSettingsProxy);\n }\n\n throw new Error('Please specify categoryId query string in request.');\n};\n\n/**\n * Action method for the getProductsByCategory data action.\n * @param input\n * @param ctx\n */\nexport async function getProductsByCategoryAction(input: ProductsByCategoryInput, ctx: IActionContext): Promise {\n const { apiSettings } = ctx.requestContext;\n let categoryId = input.currentCategory.categoryId;\n if (input.currentCategory.categorySlug && !categoryId) {\n const category = await getCurrentCategory(input.currentCategory, ctx);\n if (!category) {\n ctx.trace('[getProductsByCategoryAction] Unable to find category');\n return [];\n }\n categoryId = category.RecordId;\n }\n\n const productInputs = await searchByCategoryAsync(\n { callerContext: ctx, queryResultSettings: input.queryResultSettingsProxy.QueryResultSettings },\n +apiSettings.channelId,\n input.catalogId,\n categoryId || 0\n ).then(productSearchResults => {\n return productSearchResults.map(\n (product: ProductSearchResult): ProductInput => {\n return new ProductInput(product.RecordId, apiSettings, undefined, undefined, ctx.requestContext);\n }\n );\n });\n\n if (productInputs.length > 0) {\n // eslint-disable-next-line no-return-await -- existing code\n return await getProducts(productInputs, ctx);\n }\n return [];\n}\n\n/**\n * The getProductsByCategory data action\n * Retrieves the current category of the request via the getCurrentCategory data action\n * Then calls the searchByCategory RetailServer API to get a list of products associated with\n * the current category, and finally fully hydrates the data for those prodcuts via the\n * getProducts data action, returning a list of SimpleProducts within the current category.\n */\nexport const getProductsByCategoryActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-products-by-category',\n action: >getProductsByCategoryAction,\n input: createGetProductsByCategoryInput\n});\n\nexport default getProductsByCategoryActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { FeatureState } from '@msdyn365-commerce/retail-proxy';\nimport { Cart, CartLine, SimpleProduct } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { createGetFeatureStateInput, getCustomer, GetCustomerInput, getFeatureState, getSimpleProducts, ProductInput } from '.';\nimport { ArrayExtensions } from './utilities';\n\n/**\n * Input class for activeCartWithProducts data action.\n */\nexport class ActiveCartProductsInput implements IActionInput {\n public getCacheKey = () => 'ActiveCartProducts';\n\n public getCacheObjectType = () => 'ActiveCartProducts';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\nconst createInput = (inputData: ICreateActionContext) => {\n return new ActiveCartProductsInput();\n};\n\n/**\n * Calls the Retail API and returns a cart object based on the passed GetCartInput.\n * @param input\n * @param ctx\n */\nexport async function getActiveCartProductsAction(input: ActiveCartProductsInput, ctx: IActionContext): Promise {\n // If no cart ID is provided in input, we need to create a cart object\n if (!input) {\n throw new Error('[getActiveCartWithProducts]No valid Input was provided, failing');\n }\n\n const cartState = await getCartState(ctx);\n const cart = cartState.cart;\n\n const isQuantityLimitsFeatureIsOn: boolean = await isOrderQuantityLimitsFeatureEnabled(ctx);\n\n if (isQuantityLimitsFeatureIsOn) {\n return getActiveCartProductsActionWhenQuantityLimitsFeatureIsOn(cart, ctx);\n }\n\n // If there are cart lines, make call to get products\n if (!cartState.hasInvoiceLine && cart && cart.CartLines && cart.CartLines.length > 0) {\n ctx.trace('Getting cart product information...');\n return getSimpleProducts(\n cart.CartLines.map(cartLine => {\n if (cartLine.ProductId) {\n return new ProductInput(\n cartLine.ProductId,\n ctx.requestContext.apiSettings,\n undefined,\n undefined,\n ctx.requestContext,\n cartLine.CatalogId\n );\n }\n return undefined;\n }).filter(Boolean),\n ctx\n )\n .then((products: SimpleProduct[]) => {\n if (products) {\n return products;\n }\n return [];\n })\n .catch((error: Error) => {\n ctx.trace(error.toString());\n ctx.telemetry.error(error.message);\n ctx.telemetry.debug('[getActiveCartWithProducts]Unable to hydrate cart with product information');\n throw new Error('[getActiveCartWithProducts]Unable to hydrate cart with product information');\n });\n }\n\n ctx.trace('[getActiveCartWithProducts]No Products Found in cart');\n return [];\n}\n\nexport const getActiveCartProductsActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-products-in-active-cart',\n action: >getActiveCartProductsAction,\n input: createInput\n});\nexport default getActiveCartProductsActionDataAction;\n\nasync function getActiveCartProductsActionWhenQuantityLimitsFeatureIsOn(cart: Cart, ctx: IActionContext): Promise {\n const productIdsByWarehouseId: Map = new Map();\n let resultProducts: SimpleProduct[] = [];\n cart.CartLines?.forEach(cartLine =>\n productIdsByWarehouseId.has(cartLine.WarehouseId!)\n ? productIdsByWarehouseId.get(cartLine.WarehouseId!)?.push(cartLine)\n : productIdsByWarehouseId.set(cartLine.WarehouseId!, [cartLine])\n );\n return Promise.all(\n [...productIdsByWarehouseId].map(([entryWarehouseId, entryProductIds]) => {\n return getSimpleProducts(\n entryProductIds\n .map(cartLine => {\n if (cartLine.ProductId) {\n return new ProductInput(\n cartLine.ProductId,\n ctx.requestContext.apiSettings,\n undefined,\n entryWarehouseId,\n ctx.requestContext,\n cartLine.CatalogId\n );\n }\n return undefined;\n })\n .filter(Boolean),\n ctx\n ).then((products: SimpleProduct[]) => {\n if (products) {\n resultProducts = products.reduce((accum, product) => {\n if (product) {\n accum.push(product);\n }\n return accum;\n }, resultProducts);\n }\n });\n })\n ).then(() => resultProducts);\n}\n\nasync function isOrderQuantityLimitsFeatureEnabled(ctx: IActionContext): Promise {\n const defaultOrderQuantityLimitsFeatureConfig = ctx.requestContext.app?.platform?.enableDefaultOrderQuantityLimits;\n if (defaultOrderQuantityLimitsFeatureConfig === 'none') {\n return Promise.resolve(false);\n }\n\n const featureStates = await getFeatureState(createGetFeatureStateInput(ctx), ctx);\n let isQuantityLimitsFeatureEnabledInHq = false;\n if (ArrayExtensions.hasElements(featureStates)) {\n isQuantityLimitsFeatureEnabledInHq =\n featureStates.find(\n (featureState: FeatureState) => featureState.Name === 'Dynamics.AX.Application.RetailDefaultOrderQuantityLimitsFeature'\n )?.IsEnabled || false;\n }\n\n if (!isQuantityLimitsFeatureEnabledInHq) {\n return false;\n }\n\n if (defaultOrderQuantityLimitsFeatureConfig === 'all') {\n return Promise.resolve(true);\n }\n\n return getCustomer(new GetCustomerInput(ctx.requestContext.apiSettings), ctx)\n .then(customerInfo => {\n return (\n !!customerInfo &&\n ((defaultOrderQuantityLimitsFeatureConfig === 'b2b' && customerInfo.IsB2b) ||\n (defaultOrderQuantityLimitsFeatureConfig === 'b2c' && !customerInfo.IsB2b))\n );\n })\n .catch((error: Error) => {\n ctx.telemetry.warning(error.message);\n ctx.telemetry.debug('Unable to get customer info');\n return false;\n });\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { CartPromotionLine } from '@msdyn365-commerce/retail-proxy';\nimport { getAvailablePromotionsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CartsDataActions.g';\n\nimport { ActiveCartProductsInput, buildCacheKey, getActiveCartProductsAction } from '.';\n\n/**\n * Input class for promotion options for items in cart.\n */\nexport class PromotionOptionsForCartLineItems implements IActionInput {\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings) {\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('ActiveCartLineItemsPromotionOptions', this.apiSettings);\n\n public getCacheObjectType = () => 'ActiveCartLineItemsPromotionOptions';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\nconst createInput = (inputData: ICreateActionContext>) => {\n return new PromotionOptionsForCartLineItems(inputData.requestContext.apiSettings);\n};\n\n/**\n * Calls the Retail API to get the promotion options for items in the cart.\n * @param input\n * @param ctx\n */\nexport async function getPromotionOptionsForCartLineItems(\n input: PromotionOptionsForCartLineItems,\n ctx: IActionContext\n): Promise {\n // If no input is provided fail out\n if (!input) {\n throw new Error('[getPromotionOptionsForCartLineItems]No valid Input was provided, failing');\n }\n const cartState = await getCartState(ctx);\n if (cartState.hasInvoiceLine) {\n ctx.trace('[getPromotionOptionsForCartLineItems] cart has invoice line');\n return [];\n }\n const cart = cartState.cart;\n const products = await getActiveCartProductsAction(new ActiveCartProductsInput(), ctx);\n\n if (!cart || !cart.CartLines || !products || products.length === 0) {\n ctx.trace('[getPromotionOptionsForCartLineItems] Not able to get cart OR channelConfiguration or no products in cart');\n return [];\n }\n\n const cartLineIds = cart.CartLines.map(c => c.LineId || '');\n\n return getAvailablePromotionsAsync({ callerContext: ctx, queryResultSettings: {}, bypassCache: 'get' }, cart.Id, cartLineIds || null)\n .then(result => {\n return result;\n })\n .catch((error: Error) => {\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getPromotionOptionsForCartLineItems]Error executing action');\n throw new Error('[getPromotionOptionsForCartLineItems]Error executing action');\n });\n}\n\nexport const getPromotionOptionsForCartLineItemsDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-promotion-options-for-cartlines',\n action: >getPromotionOptionsForCartLineItems,\n input: createInput\n});\n\nexport default getPromotionOptionsForCartLineItemsDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CacheType, IActionInput } from '@msdyn365-commerce/core';\n\n/**\n * ReviewsGetRatingsSummary Input Action.\n */\nexport class GetRatingsSummaryInput implements IActionInput {\n /**\n * The Id representing the product to get the ratings for.\n */\n public productId: string;\n\n /**\n * The ID representing the tenant.\n */\n public tenantId: string;\n\n /**\n * The ratings and reviews service endpoint.\n */\n public serviceEndpoint: string;\n\n constructor(productId: string, tenantId: string, serviceEndpoint: string) {\n this.productId = productId;\n this.tenantId = tenantId;\n this.serviceEndpoint = serviceEndpoint;\n }\n\n // RnR does not use RS endpoint, so shouldn't use buildCacheKey\n public getCacheKey = () => `${this.productId}-${this.tenantId}`;\n\n public getCacheObjectType = () => 'RatingsSummary';\n\n public dataCacheType = (): CacheType => 'application';\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { RatingsSummary } from '@msdyn365-commerce/commerce-entities';\nimport {\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric,\n sendRequest\n} from '@msdyn365-commerce/core';\n\nimport { GetRatingsSummaryInput, getSelectedProductIdFromActionInput } from '.';\nimport { getRnrEndpointId, getRnrPartnerId } from './utilities/getRnrKeys';\n\nexport const createInput = (input: ICreateActionContext>): IActionInput => {\n const productId = getSelectedProductIdFromActionInput(input);\n if (productId) {\n return new GetRatingsSummaryInput(productId, getRnrPartnerId(input), getRnrEndpointId(input));\n }\n throw new Error('[GetRatingsSummary] Not all necessary parameters found while creating Input for getRatingsSummaryApi');\n};\n\n/**\n * This function gets the ratings summary.\n * @param input\n * @param ctx\n */\nexport async function getRatingsSummary(input: GetRatingsSummaryInput, ctx: IActionContext): Promise {\n if (!inputIsValid(input)) {\n ctx.trace('[GetRatingsSummary] Failed to get ratings summary for product');\n return {};\n }\n\n const requestUrl = `${input.serviceEndpoint}/v2.0/ratings/product/${input.productId}/summary?` + `tenantId=${input.tenantId}`;\n return sendRequest(requestUrl, 'get')\n .then(response => {\n return response.data;\n })\n .catch(error => {\n ctx.trace('[GetRatingsSummary] Failed to get ratings summary for product');\n throw error;\n });\n}\n\nfunction inputIsValid(input: GetRatingsSummaryInput): boolean {\n return input && input.productId.length > 0 && input.tenantId.length > 0;\n}\n\nexport const getRatingsSummaryDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-ratings-summary',\n action: >getRatingsSummary,\n input: createInput\n});\n\nexport default getRatingsSummaryDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { ProductRefiner } from '@msdyn365-commerce/retail-proxy';\nimport { getRefinersByCategoryAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport getCurrentCategory, { CurrentCategoryInput } from './get-current-category';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Action Input class for the getRefinersByCategory data action.\n */\nexport class RefinersByCategoryInput implements IActionInput {\n public readonly catalogId: number;\n\n public readonly currentCategory: CurrentCategoryInput;\n\n public readonly queryResultSettingsProxy: QueryResultSettingsProxy;\n\n constructor(category: CurrentCategoryInput, queryResultSettingsProxy: QueryResultSettingsProxy, catalogId?: number) {\n this.queryResultSettingsProxy = queryResultSettingsProxy;\n this.catalogId = catalogId || 0;\n this.currentCategory = category;\n }\n\n public getCacheKey = () => `${this.currentCategory.getCacheKey()}|${this.catalogId}|${this.queryResultSettingsProxy.cacheKeyHint}`;\n\n public getCacheObjectType = () => 'ProductRefiner';\n\n public shouldCacheOutput = () => true;\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nexport const createRefinersByCategoryInput = (inputData: ICreateActionContext>): IActionInput => {\n if (inputData && inputData.requestContext) {\n const catalogId = getCatalogId(inputData.requestContext);\n const currentCategory = new CurrentCategoryInput(inputData.requestContext);\n\n return new RefinersByCategoryInput(currentCategory, QueryResultSettingsProxy.fromInputData(inputData), catalogId);\n }\n\n throw new Error('Please specify categoryId query string in request.');\n};\n\n/**\n * Calls the Retail API and returns all refiners by category.\n * @param input\n * @param ctx\n */\nexport async function getRefinersByCategoryAction(input: RefinersByCategoryInput, ctx: IActionContext): Promise {\n let categoryId = input.currentCategory.categoryId;\n if (input.currentCategory.categorySlug && !categoryId) {\n const category = await getCurrentCategory(input.currentCategory, ctx);\n if (!category) {\n ctx.trace('[getRefinersByCategoryAction] Unable to find category');\n return [];\n }\n categoryId = category.RecordId;\n }\n\n return getRefinersByCategoryAsync(\n { callerContext: ctx, queryResultSettings: input.queryResultSettingsProxy.QueryResultSettings },\n input.catalogId,\n categoryId || 0\n );\n}\n\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-refiners-by-category',\n action: >getRefinersByCategoryAction,\n input: createRefinersByCategoryInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { ProductRefiner } from '@msdyn365-commerce/retail-proxy';\nimport { getRefinersByTextAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport { parseSearchData } from './utilities/input-data-parser';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Action Input class for the getRefinersByText data action.\n */\nexport class RefinersByTextInput implements IActionInput {\n public readonly catalogId: number;\n\n public readonly searchText: string;\n\n public readonly queryResultSettingsProxy: QueryResultSettingsProxy;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(\n searchText: string,\n catalogId: number,\n queryResultSettingsProxy: QueryResultSettingsProxy,\n apiSettings: ICommerceApiSettings\n ) {\n this.catalogId = catalogId;\n this.searchText = searchText;\n this.queryResultSettingsProxy = queryResultSettingsProxy;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () =>\n buildCacheKey(`${this.searchText}|${this.catalogId}|${this.queryResultSettingsProxy.cacheKeyHint}`, this.apiSettings);\n\n public getCacheObjectType = () => 'ProductRefiner';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nexport const createRefinersByTextInput = (inputData: ICreateActionContext>): IActionInput => {\n const searchInputData = parseSearchData(inputData);\n const catalogId = inputData.config ? Number(inputData.config.catalogId) : 0;\n\n return new RefinersByTextInput(\n searchInputData.q,\n Number.isNaN(catalogId) ? 0 : catalogId,\n QueryResultSettingsProxy.fromInputData(inputData),\n inputData.requestContext.apiSettings\n );\n};\n\n/**\n * Calls the Retail API and returns all refiners by text.\n * @param input\n * @param ctx\n */\nexport async function getRefinersByTextAction(input: RefinersByTextInput, ctx: IActionContext): Promise {\n return getRefinersByTextAsync(\n { callerContext: ctx, queryResultSettings: input.queryResultSettingsProxy.QueryResultSettings },\n input.catalogId,\n input.searchText\n );\n}\n\nexport const getRefinersByTextActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-refiners-by-text',\n action: >getRefinersByTextAction,\n input: createRefinersByTextInput\n});\n\nexport default getRefinersByTextActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { getRelatedProductsAsync, getRelationTypesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport { ProductRelationType, ProductSearchResult } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport getFullProducts, { FullProductInput, ProductDetailsCriteria } from './get-full-products';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { getProductDetailsCriteriaFromActionInput } from './utilities/utils';\n\n/**\n * GetRelatedProducts Input Action.\n */\nexport class GetRelatedProductsInput implements IActionInput {\n public readonly productId: number;\n\n public readonly catalogId: number;\n\n public readonly relationType: string;\n\n public ProductDetailsCriteria: ProductDetailsCriteria;\n\n public readonly queryResultSettingsProxy: QueryResultSettingsProxy;\n\n public constructor(\n productId: number,\n catalogId: number,\n relationType: string,\n queryResultSettingsProxy: QueryResultSettingsProxy,\n criteria: ProductDetailsCriteria\n ) {\n this.productId = productId;\n this.catalogId = catalogId;\n this.relationType = relationType;\n this.queryResultSettingsProxy = queryResultSettingsProxy;\n this.ProductDetailsCriteria = criteria;\n }\n\n public getCacheKey = () =>\n `${this.productId}|${this.catalogId}|${this.relationType.toLowerCase()}|${this.queryResultSettingsProxy.cacheKeyHint}|${\n this.ProductDetailsCriteria.getPrice\n }`;\n\n public getCacheObjectType = () => 'GetRelatedProducts';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * Creates the input required to make GetRelatedProducts retail api call.\n * @param inputData\n */\nexport const createGetRelatedProductsInput = (inputData: ICreateActionContext>): IActionInput => {\n if (inputData && inputData.requestContext && inputData.config) {\n const catalogId = getCatalogId(inputData.requestContext);\n const relationType = inputData.config.relationType;\n\n let productId = inputData.requestContext.urlTokens ? Number(inputData.requestContext.urlTokens.recordId) : 0;\n const productDetailsCriteria = getProductDetailsCriteriaFromActionInput(inputData);\n if (!relationType) {\n throw new Error('Input relation type is invalid.');\n }\n\n // Query string may override the product id from url\n if (inputData.requestContext.query && inputData.requestContext.query.productId) {\n productId = Number(inputData.requestContext.query.productId);\n }\n\n if (Number.isNaN(productId) || productId <= 0) {\n throw new Error('No valid product id available in url or query string.');\n }\n\n const queryResultSettingsProxy = QueryResultSettingsProxy.fromInputData(inputData);\n return new GetRelatedProductsInput(productId, catalogId, relationType, queryResultSettingsProxy, productDetailsCriteria);\n }\n\n throw new Error('Invalid input data or request context');\n};\n\nexport function searchProductRelationType(productRelationTypes: ProductRelationType[], _productRelationType: string): number | undefined {\n let foundProductRelationTypeId;\n _productRelationType = _productRelationType.toLowerCase();\n productRelationTypes.forEach((productRelationType: ProductRelationType) => {\n if (productRelationType.Name && productRelationType.Name.toLowerCase() === _productRelationType) {\n return (foundProductRelationTypeId = productRelationType.RecordId);\n }\n });\n\n return foundProductRelationTypeId;\n}\n\nasync function getRelatedProductsAction(input: GetRelatedProductsInput, ctx: IActionContext): Promise {\n const apiSettings = ctx.requestContext.apiSettings;\n const querySettings = input.queryResultSettingsProxy.QueryResultSettings;\n\n const productRelationTypes = await getRelationTypesAsync(\n { callerContext: ctx, queryResultSettings: querySettings },\n input.productId,\n +apiSettings.channelId,\n input.catalogId\n );\n if (!productRelationTypes) {\n ctx.trace(`[getProductRelationType] Unable to get product relation types for product ${input.productId}`);\n return [];\n }\n const productRelationTypeId = searchProductRelationType(productRelationTypes, input.relationType);\n if (!productRelationTypeId) {\n ctx.trace(`[getRelatedProducts] Unable to find relation type ${input.relationType} for product ${input.productId}`);\n return [];\n }\n\n const productInputs = await getRelatedProductsAsync(\n { callerContext: ctx, queryResultSettings: querySettings },\n input.productId,\n +apiSettings.channelId,\n input.catalogId,\n productRelationTypeId\n )\n .then(response => {\n if (response && response.length > 0) {\n return response.map(\n (product: ProductSearchResult): FullProductInput => {\n return new FullProductInput(product.RecordId, apiSettings, input.ProductDetailsCriteria, ctx.requestContext);\n }\n );\n }\n\n ctx.trace('[getRelatedProductsAction] Invalid response from server');\n return [];\n })\n .catch((error: Error) => {\n ctx.trace(error.message);\n ctx.trace(error.stack || '');\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getRelatedProductsAction] Unable to Fetch Products.');\n ctx.trace('[getRelatedProductsAction] Unable to Fetch Products.');\n return [];\n });\n\n if (productInputs.length > 0) {\n return getFullProducts(productInputs, ctx);\n }\n return [];\n}\n\n/**\n * The getRelatedProducts data action\n * Uses a productId URL Token and finds the relation types for said product\n * using the getRelationTypes RetailServer API, and then finds and retusn all products that\n * share that relation type via the getRelatedProducts RetailServer API.\n */\nexport const getRelatedProductsActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-related-products',\n action: >getRelatedProductsAction,\n input: createGetRelatedProductsInput\n});\n\nexport default getRelatedProductsActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { readAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ScanResultsDataActions.g';\nimport { ProductDimension } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { getDimensionsForSelectedVariant, GetDimensionsForSelectedVariantInput } from '.';\nimport { IScanResultWithProduct } from './utilities/scan-result-with-product';\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input class to get product from sku number.\n */\nexport class GetScanResultInput implements IActionInput {\n public skuNumber: string;\n\n public channelId: number;\n\n public matchingDimensionValues: ProductDimension[];\n\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, sku: string, channelId: number, matchingDimensionValues?: ProductDimension[]) {\n this.skuNumber = sku;\n this.channelId = channelId;\n this.matchingDimensionValues = matchingDimensionValues || [];\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey(`Product-${this.skuNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'ProductSKU';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the getSelectedVariant data action.\n * @param inputData The input data passed to the createInput method.\n * @param skuuNumber SkuNumber to send ScanResult API.\n * @param skuNumber\n * @param channelId ChannelId required to get dimension for given product.\n * @param matchingDimensionValues\n */\nconst createInput = (\n inputData: ICreateActionContext,\n skuNumber: string,\n channelId: number,\n matchingDimensionValues?: ProductDimension[]\n) => {\n return new GetScanResultInput(inputData.requestContext.apiSettings, skuNumber, channelId, matchingDimensionValues);\n};\n\n/**\n * Action method for the product and dimension from scan result and dimension api.\n * @param input The action input class.\n * @param ctx The action context.\n */\nexport async function getScanResult(input: GetScanResultInput, ctx: IActionContext): Promise {\n return readAsync({ callerContext: ctx }, input.skuNumber)\n .then(scanResults => {\n if (scanResults && scanResults.Product) {\n return getDimensionsForSelectedVariant(\n new GetDimensionsForSelectedVariantInput(\n scanResults.Product.MasterProductId ? scanResults.Product.MasterProductId : scanResults.Product.RecordId,\n input.channelId,\n input.matchingDimensionValues,\n ctx.requestContext\n ),\n ctx\n )\n .then(response => {\n if (response && response.length > 0) {\n return { ScanResult: scanResults, Product: scanResults.Product, ProductDimensionFull: response };\n }\n return { ScanResult: scanResults, Product: scanResults.Product };\n })\n .catch((error: Error) => {\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getScanResult, getDimensionsForSelectedVariant]Error executing action');\n throw new Error('[getScanResult, getDimensionsForSelectedVariant]Error executing action');\n });\n }\n\n throw new Error('Unable to get result from scan result data action.');\n })\n .catch((error: Error) => {\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[getScanResult]Error executing action');\n throw new Error('[getScanResult]Error executing action');\n });\n}\n\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-scan-results',\n action: >getScanResult,\n input: createInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { SortColumn } from '@msdyn365-commerce/retail-proxy';\nimport { getSearchConfigurationAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\n\nimport { buildCacheKey } from '.';\n\n// TODO: import from commerce entities when available\n// eslint-disable-next-line @typescript-eslint/naming-convention\ninterface SearchConfiguration {\n ProductSortColumns?: SortColumn[];\n}\n\n/**\n * Action Input class for the getSearchConfiguration data action.\n */\nexport class SearchConfigurationInput implements IActionInput {\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings) {\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('SearchConfig', this.apiSettings);\n\n public getCacheObjectType = () => 'SearchConfiguration';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nexport const createSearchConfigurationInput = (inputData: ICreateActionContext>): IActionInput => {\n return new SearchConfigurationInput(inputData.requestContext.apiSettings);\n};\n\n/**\n * Calls the Retail API.\n * @param input\n * @param ctx\n */\nexport async function getSearchConfigurationAction(input: SearchConfigurationInput, ctx: IActionContext): Promise {\n return getSearchConfigurationAsync({ callerContext: ctx });\n}\n\nexport const getSearchConfigurationActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-search-configurations',\n action: >getSearchConfigurationAction,\n input: createSearchConfigurationInput\n});\n\nexport default getSearchConfigurationActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IProductDimensionsWithAvailabilitiesFull } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport {\n BypassCache,\n ProductDimension,\n ProductDimensionAvailabilitySearchCriteria,\n ProductsDataActions,\n SimpleProduct\n} from '@msdyn365-commerce/retail-proxy';\n\nimport { ArrayExtensions } from './utilities';\nimport { createInventoryAvailabilitySearchCriteria } from './utilities/product-inventory-utils';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { generateProductImageUrl, getDimensionValuesFromQuery, getSelectedProductIdFromActionInput } from './utilities/utils';\n\n/**\n * Stores data about the selected product.\n */\nexport interface ISelectedProduct extends SimpleProduct {\n productVariant?: SimpleProduct;\n}\n\n/**\n * Get selected variant action input class.\n */\nexport class SelectedVariantInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public matchingDimensionValues?: ProductDimension[];\n\n public bypassCache?: BypassCache;\n\n public catalogId?: number;\n\n public constructor(\n productId: number,\n channelId: number,\n matchingDimensionValues?: ProductDimension[],\n bypassCache?: BypassCache,\n requestContext?: IRequestContext\n ) {\n this.productId = productId;\n this.channelId = channelId;\n this.matchingDimensionValues = matchingDimensionValues;\n this.bypassCache = bypassCache;\n\n if (requestContext) {\n this.catalogId = getCatalogId(requestContext);\n }\n }\n\n /**\n * Cache key.\n * @returns String.\n */\n public getCacheKey: () => string = () => 'SelectedVariant';\n\n /**\n * Cache object type.\n * @returns String.\n */\n public getCacheObjectType: () => string = () => 'SimpleProduct';\n\n /**\n * Cache type.\n * @returns String.\n */\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the getSelectedVariant data action.\n * @param inputData - The input data passed to the createInput method.\n * @returns The input for the ata action getSelectedVariantNewAction.\n */\nconst createInput = (inputData: ICreateActionContext>): SelectedVariantInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n\n if (productId) {\n return new SelectedVariantInput(\n +productId,\n +inputData.requestContext.apiSettings.channelId,\n undefined,\n undefined,\n inputData.requestContext\n );\n }\n throw new Error('Unable to create SelectedVariantInput, no productId found on module config or query');\n};\n\n/**\n * Checks if given product has any unmatched dimensions.\n * Modifies product entity to use matched dimension values.\n * @param product - The product to analyze and modify.\n * @param matchingDimensionValues - Matched dimensions.\n * @returns True if has any unmatched dimension, false if all dimensions are specified.\n */\nconst checkIfHasUnmatchedDimensions = (product: SimpleProduct, matchingDimensionValues: ProductDimension[]): boolean => {\n let hasUnmatchedDimension: boolean = false;\n if (product.Dimensions) {\n product.Dimensions = product.Dimensions.map(dimension => {\n return { ...dimension };\n });\n for (const dimension of product.Dimensions) {\n const matchedTargetDimension = matchingDimensionValues.find(\n targetDimension => targetDimension.DimensionTypeValue === dimension.DimensionTypeValue\n );\n\n if (matchedTargetDimension) {\n dimension.DimensionValue = matchedTargetDimension.DimensionValue;\n } else {\n hasUnmatchedDimension = true;\n }\n }\n }\n return hasUnmatchedDimension;\n};\n\n/**\n * Retrieves product dimensions with availabilities.\n * @param product - Product for which the dimensions need to be retrieved.\n * @param matchingDimensionValues - Selected dimensions - filter criteria for the dimensions API.\n * @param context - Action context.\n * @param catalogId - Catalog id.\n * @returns Array of dimensions.\n */\nconst getFullDimensions = async (\n product: SimpleProduct,\n matchingDimensionValues: ProductDimension[],\n context: IActionContext,\n catalogId?: number\n) => {\n let fullDimensions: IProductDimensionsWithAvailabilitiesFull[] = [];\n const fullDimensionPromises = (product.Dimensions ?? []).map(dimension => {\n const shippingInventoryConfiguration = createInventoryAvailabilitySearchCriteria(context, [], true, undefined, undefined);\n const searchCriteria: ProductDimensionAvailabilitySearchCriteria = {\n RequestedDimensionTypeValue: dimension.DimensionTypeValue,\n MatchingDimensionValues: matchingDimensionValues,\n DefaultWarehouseOnly: shippingInventoryConfiguration.DefaultWarehouseOnly,\n FilterByChannelFulfillmentGroup: shippingInventoryConfiguration.FilterByChannelFulfillmentGroup,\n DeliveryModeTypeFilterValue: shippingInventoryConfiguration.DeliveryModeTypeFilterValue,\n CatalogId: catalogId\n };\n const dimensionValuesPromise = ProductsDataActions.getDimensionValuesWithEstimatedAvailabilitiesAsync(\n { callerContext: context, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context) },\n product.MasterProductId ? product.MasterProductId : product.RecordId,\n searchCriteria\n );\n\n return dimensionValuesPromise.then(dimensionValues => {\n const fullDimension: IProductDimensionsWithAvailabilitiesFull = {\n ...dimension,\n dimensionValuesWithInventory: dimensionValues\n };\n return fullDimension;\n });\n });\n fullDimensions = await Promise.all(fullDimensionPromises);\n return fullDimensions;\n};\n\n/**\n * Retrieves product variant for the given input or undefined if not found.\n * @param input - Action input.\n * @param context - Action context.\n * @param fullDimensions - Product dimensions with availabilities.\n * @returns A product variant that is available or undefined.\n */\nconst getProductVariant = async (\n input: SelectedVariantInput,\n context: IActionContext,\n fullDimensions: IProductDimensionsWithAvailabilitiesFull[]\n) => {\n let productVariant: SimpleProduct | undefined;\n if (\n ArrayExtensions.hasElements(fullDimensions) &&\n ArrayExtensions.hasElements(fullDimensions[0].dimensionValuesWithInventory) &&\n ArrayExtensions.hasElements(fullDimensions[0].dimensionValuesWithInventory[0].ProductIds)\n ) {\n const variantProductId = fullDimensions[0].dimensionValuesWithInventory[0].ProductIds[0];\n const result = await ProductsDataActions.getByIdsAsync(\n {\n callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context),\n bypassCache: input.bypassCache\n },\n input.channelId,\n [variantProductId],\n null,\n input.catalogId ?? 0\n );\n productVariant = result[0];\n productVariant = { ...productVariant };\n const variantImageUrl = generateProductImageUrl(productVariant, context.requestContext.apiSettings);\n\n if (variantImageUrl) {\n productVariant.PrimaryImageUrl = variantImageUrl;\n }\n }\n\n return productVariant;\n};\n\n/**\n * Action method for the getSelectedVariant data action.\n * @param input - The action input class.\n * @param context - The action context.\n * @returns Simple product.\n */\nasync function getSelectedVariantAction(input: SelectedVariantInput, context: IActionContext): Promise {\n const matchingDimensionValues = input.matchingDimensionValues ?? getDimensionValuesFromQuery(context.requestContext.url.requestUrl);\n\n const result = await ProductsDataActions.getByIdsAsync(\n {\n callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context),\n bypassCache: input.bypassCache\n },\n input.channelId,\n [input.productId],\n null,\n input.catalogId ?? 0\n );\n let product = result[0];\n\n // Need to dereference this before editing it. Otherwise we might not\n // properly get the mobx events because if things aren't properly observable\n // they won't fire when you set them, and then if you don't deref the value in\n // the cache will match the value when you try to save it, so it won't detect any\n // changes there either\n product = { ...product };\n const hasUnmatchedDimension = checkIfHasUnmatchedDimensions(product, matchingDimensionValues);\n\n const newImageUrl = generateProductImageUrl(product, context.requestContext.apiSettings);\n\n if (newImageUrl) {\n product.PrimaryImageUrl = newImageUrl;\n }\n\n const fullDimensions: IProductDimensionsWithAvailabilitiesFull[] = await getFullDimensions(\n product,\n matchingDimensionValues,\n context,\n input.catalogId\n );\n\n // Retrieve product variants only if matching dimensions are provided.\n const productVariant: SimpleProduct | undefined = ArrayExtensions.hasElements(matchingDimensionValues)\n ? await getProductVariant(input, context, fullDimensions)\n : undefined;\n\n // Update dimension value back to the one that comes from API since the URL query might have a different format for the dimension values.\n if (productVariant?.Dimensions && product.Dimensions) {\n for (const dimension of product.Dimensions) {\n const matchedTargetDimensionFromApi = productVariant.Dimensions.find(\n targetDimension => targetDimension.DimensionTypeValue === dimension.DimensionTypeValue\n );\n const matchedTargetDimensionFromSearch = matchingDimensionValues.find(\n targetDimension => targetDimension.DimensionTypeValue === dimension.DimensionTypeValue\n );\n\n if (matchedTargetDimensionFromSearch && matchedTargetDimensionFromApi) {\n dimension.DimensionValue = matchedTargetDimensionFromApi.DimensionValue;\n }\n }\n }\n\n if (!hasUnmatchedDimension && ArrayExtensions.hasElements(matchingDimensionValues) && productVariant) {\n return productVariant;\n }\n\n const selectedProduct: ISelectedProduct = product;\n selectedProduct.productVariant = productVariant;\n return selectedProduct;\n}\n\n/**\n * The complete getSelectedVariant data action.\n */\nexport const getSelectedVariantActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-selected-variant',\n action: getSelectedVariantAction as IAction,\n input: createInput\n});\n\nexport default getSelectedVariantActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n getCatalogId,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IDictionary,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core';\nimport { getByIdsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport { SimpleProduct } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { ArrayExtensions } from './utilities';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { buildCacheKey, generateProductImageUrl } from './utilities/utils';\n\n/**\n * Product Input.\n */\nexport class ProductInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public warehouseId?: string;\n\n public catalogId?: number;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n public constructor(\n productId: number | string,\n apiSettings: ICommerceApiSettings,\n channelId?: number,\n warehouseId?: string,\n requestContext?: IRequestContext,\n catalogId?: number\n ) {\n this.apiSettings = apiSettings;\n this.productId = +productId;\n this.channelId = channelId || apiSettings.channelId;\n this.warehouseId = warehouseId;\n this.catalogId = catalogId;\n\n if (requestContext && catalogId === undefined) {\n this.catalogId = getCatalogId(requestContext);\n }\n }\n\n public getCacheKey = () =>\n buildCacheKey(\n `RecordId-${this.productId.toString()}-ChannelId-${this.channelId.toString()}-WahehouseId-${this.warehouseId ?? ''}-${this\n .catalogId ?? 0}`,\n this.apiSettings\n );\n\n public getCacheObjectType = () => 'SimpleProduct';\n\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData\n */\nexport const createSimpleProductsInput = (inputData: ICreateActionContext>): IActionInput[] => {\n let productIds = inputData.config && inputData.config.productIds;\n if (!productIds) {\n return [];\n }\n\n productIds = typeof productIds === 'string' ? productIds.split(',') : productIds;\n return !Array.isArray(productIds)\n ? []\n : productIds.map((productId: string) => {\n return new ProductInput(productId, inputData.requestContext.apiSettings, undefined, undefined, inputData.requestContext);\n });\n};\n\n/**\n * Calls the Retail API and returns the product based on the passed ProductInput.\n * @param inputs\n * @param ctx\n */\nexport async function getSimpleProductsAction(inputs: ProductInput[], ctx: IActionContext): Promise {\n if (!ArrayExtensions.hasElements(inputs)) {\n ctx.trace('[getSimpleProductsAction] Invalid or empty inputs passed.');\n return [];\n }\n\n const productIdMapping: IDictionary = {};\n\n for (let index = 0; index < inputs.length; ++index) {\n productIdMapping[inputs[index].productId] = index;\n }\n\n const getProductPromises: Promise[] = [];\n const catalogIds = ArrayExtensions.unique(inputs.map(input => input.catalogId));\n for (const catalogId of catalogIds) {\n const productInputs = inputs.filter(input => input.catalogId === catalogId);\n getProductPromises.push(\n getByIdsAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n inputs[0].channelId,\n productInputs.map(input => input.productId),\n inputs[0].warehouseId ?? null,\n catalogId ?? 0\n )\n );\n }\n\n const products = ArrayExtensions.flatten(await Promise.all(getProductPromises));\n const mappedProducts = products\n .map(product => {\n try {\n const newImageUrl = generateProductImageUrl(product, ctx.requestContext.apiSettings);\n\n if (newImageUrl) {\n product.PrimaryImageUrl = newImageUrl;\n }\n\n return product;\n } catch {\n ctx.trace('[getSimpleProductsAction] Unable to update ImageURL for Product');\n return undefined;\n }\n })\n .reduce((memo: SimpleProduct[], product: SimpleProduct | undefined) => {\n if (!product) {\n return memo;\n }\n const index = productIdMapping[product.RecordId];\n memo[index] = product;\n return memo;\n }, []);\n\n // NOTE: This is not an ideal fix, but will resolve all current issues\n return inputs.map(input => {\n const foundProduct = mappedProducts.find(product => product && product.RecordId === input.productId);\n return foundProduct || {};\n });\n}\n\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-simple-products',\n action: >getSimpleProductsAction,\n input: createSimpleProductsInput,\n isBatched: true\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport {\n ChannelDeliveryOption,\n FeatureState,\n OrgUnitAvailability,\n OrgUnitLocation,\n SearchArea,\n StoreHours\n} from '@msdyn365-commerce/retail-proxy';\nimport {\n getChannelDeliveryOptionsAsync,\n getOrgUnitLocationsByAreaAsync,\n getStoreHoursAsync\n} from '@msdyn365-commerce/retail-proxy/dist/DataActions/OrgUnitsDataActions.g';\n\nimport { FeatureStateInput, getFeatureStateActionDataAction } from './get-feature-state';\nimport { IFullOrgUnitAvailability } from './utilities/full-org-unit-availability';\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * Get selected variant action input class.\n */\nexport class GetOrgUnitLocationsByAreaInput implements IActionInput {\n public Latitude?: number;\n\n public Longitude?: number;\n\n public Radius?: number;\n\n public DistanceUnitValue?: number;\n\n public IgnoreLocation?: boolean;\n\n constructor(_Latitude?: number, _Longitude?: number, _Radius?: number, _DistanceUnitValue?: number, _IgnoreLocation?: boolean) {\n this.Latitude = _Latitude;\n this.Longitude = _Longitude;\n this.Radius = _Radius;\n this.DistanceUnitValue = _DistanceUnitValue;\n this.IgnoreLocation = _IgnoreLocation;\n }\n\n public getCacheKey = () => 'GetOrgUnitLocationsByAreaInput';\n\n public getCacheObjectType = () => 'GetOrgUnitLocationsByAreaInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the getSelectedVariant data action.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createGetOrgUnitLocationsByAreaInput = (inputData: ICreateActionContext>): GetOrgUnitLocationsByAreaInput => {\n return new GetOrgUnitLocationsByAreaInput();\n};\n\n/**\n * Calls the Retail Feature State API and returns a list of feature with isEnabled flag.\n * @param context\n */\nexport async function getFeatureState(context: IActionContext): Promise {\n return getFeatureStateActionDataAction(new FeatureStateInput(), context);\n}\n\n/**\n * Action method for the getSelectedVariant data action.\n * @param input The action input class.\n * @param ctx The action context.\n */\nexport async function getOrgUnitLocationsByArea(\n input: GetOrgUnitLocationsByAreaInput,\n ctx: IActionContext\n): Promise {\n if ((input.Radius === undefined || !input.Latitude || !input.Longitude) && !input.IgnoreLocation) {\n // No valid location we want to return empty array so module can show no locations message\n return [];\n }\n\n const searchArea: SearchArea = {\n Latitude: input.Latitude,\n Longitude: input.Longitude,\n Radius: input.Radius,\n DistanceUnitValue: input.DistanceUnitValue || 0 // 0 is miles\n };\n\n const featureState = await getFeatureState(ctx);\n const retailMulitplePickupMFeatureState = featureState?.find(\n item => item.Name === 'Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature'\n )?.IsEnabled;\n\n return getOrgUnitLocationsByAreaAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n searchArea\n )\n .then(async (stores: OrgUnitLocation[]) => {\n let locationDeliveryOptions: ChannelDeliveryOption[] | undefined = [];\n\n // If mulitple pickup mode is enable then call getchanneldeliveryoption\n if (retailMulitplePickupMFeatureState) {\n const orgUnitChannel = stores.map(store => store.ChannelId);\n locationDeliveryOptions = await _getLocationPickUpDeliveryModes(orgUnitChannel, ctx);\n }\n const locationPromiseList = stores.map(store => {\n const locationDeliveryOption = locationDeliveryOptions?.find(\n _channeldeliveryoption => _channeldeliveryoption.ChannelId === store.ChannelId\n );\n return _getLocationWithHours(store, locationDeliveryOption, ctx);\n });\n return Promise.all(locationPromiseList);\n })\n .catch((error: Error) => {\n ctx.trace('[GetOrgUnitLocationsByArea] error getting Locations');\n ctx.trace(error.message);\n ctx.telemetry.error(error.message);\n ctx.telemetry.debug('[GetOrgUnitLocationsByArea] error getting Locations');\n return [];\n });\n}\n\n/**\n * Action method that obtains the store information.\n * @param orgUnitLocation The org unit location.\n * @param storeMap A map that contains store information group by the inventory location id.\n * @param channelDeleiveryOptions\n * @param ctx The action context.\n */\nasync function _getLocationWithHours(\n orgUnitLocation: OrgUnitLocation,\n channelDeleiveryOptions: ChannelDeliveryOption | undefined,\n ctx: IActionContext\n): Promise {\n if (!orgUnitLocation || !orgUnitLocation.OrgUnitNumber) {\n return { OrgUnitAvailability: undefined };\n }\n\n return getStoreHoursAsync({ callerContext: ctx }, orgUnitLocation.OrgUnitNumber)\n .then((hours: StoreHours) => {\n const availability: OrgUnitAvailability = {\n OrgUnitLocation: orgUnitLocation\n };\n\n if (hours && !(hours instanceof Error)) {\n return { OrgUnitAvailability: availability, StoreHours: hours, OrgUnitPickUpDeliveryModes: channelDeleiveryOptions };\n }\n\n return { OrgUnitAvailability: availability, OrgUnitPickUpDeliveryModes: channelDeleiveryOptions };\n })\n .catch((error: Error) => {\n ctx.trace('[GetFullAvailableInventoryNearby] error getting availability with hours');\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[GetFullAvailableInventoryNearby] error getting availability with hours');\n return { OrgUnitAvailability: {} };\n });\n}\n\n/**\n * Action method that obtains the store information.\n * @param channelCollection The org unit channel Id list.\n * @param ctx The action context.\n */\nasync function _getLocationPickUpDeliveryModes(\n channelCollection: (number | undefined)[],\n ctx: IActionContext\n): Promise {\n if (channelCollection?.length === 0 || channelCollection === undefined) {\n return undefined;\n }\n\n const channelIdList: number[] = [];\n channelCollection?.map(id => {\n if (id !== undefined) {\n return channelIdList.push(id);\n }\n });\n\n // To get all channel pickup delivery mode filterOption should be 4\n return getChannelDeliveryOptionsAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n channelIdList,\n 4\n )\n .then((channelDeliveryOptions: ChannelDeliveryOption[]) => {\n if (channelDeliveryOptions && !(channelDeliveryOptions instanceof Error)) {\n return channelDeliveryOptions;\n }\n\n return undefined;\n })\n .catch((error: Error) => {\n ctx.trace(\n '[GetFullAvailableInventoryNearby][getChannelDeliveryOptionsAsync] error getting availability with channel delivery options'\n );\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug(\n '[GetFullAvailableInventoryNearby] [getChannelDeliveryOptionsAsync] error getting availability with channel delivery options'\n );\n return [];\n });\n}\n\n/**\n * The complete getOrgUnitLocationsByArea data action.\n */\nexport const getOrgUnitLocationsByAreaDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-store-location-information',\n action: >getOrgUnitLocationsByArea,\n input: createGetOrgUnitLocationsByAreaInput\n});\n\nexport default getOrgUnitLocationsByAreaDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { createObservableDataAction, IAction, ICreateActionContext } from '@msdyn365-commerce/core';\nimport { retailAction } from '@msdyn365-commerce/retail-proxy/dist';\nimport { createGetByCustomerInput } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CommerceListsDataActions.g';\nimport { CommerceList } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nconst createWishlistInput = (inputData: ICreateActionContext) => {\n if (inputData.requestContext && inputData.requestContext.user && inputData.requestContext.user.isAuthenticated) {\n return createGetByCustomerInput({}, null);\n }\n\n throw new Error('[get-wishlist-by-customer-id] Unable to create input for getWishlists');\n};\n\n/**\n * Get Org Unit Configuration Data Action.\n */\nexport const retailActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-wishlist-by-customer-id',\n action: >retailAction,\n input: createWishlistInput\n});\n\nexport default retailActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { InvoiceDetailsSearchCriteria, SalesInvoice, SalesOrdersDataActions } from '@msdyn365-commerce/retail-proxy';\n\n/**\n * Input class for get invoice details data action.\n */\nexport class GetInvoiceDetailsInput implements IActionInput {\n public invoiceId: string;\n\n constructor(invoiceId: string) {\n this.invoiceId = invoiceId;\n }\n\n public getCacheKey = () => `GetInvoiceDetails|${this.invoiceId}`;\n\n public getCacheObjectType = () => 'SalesInvoice';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\nexport const CreateGetInvoiceDetailsInput = (inputData: ICreateActionContext): IActionInput => {\n const { requestContext } = inputData;\n\n // Check if the user is authenticated.\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to get invoice details as User is not logged in.');\n }\n if (!inputData?.requestContext?.query?.invoiceId) {\n throw new Error('Unable to get invoice details as no valid invoice id found.');\n }\n\n return new GetInvoiceDetailsInput(inputData.requestContext.query.invoiceId);\n};\n\nexport async function getInvoiceDetails(input: GetInvoiceDetailsInput, context: IActionContext): Promise {\n if (!context?.requestContext?.user?.isAuthenticated) {\n throw new Error('Unable to get details for the invoice. User is not authenticated.');\n }\n\n if (!input.invoiceId) {\n throw new Error('Unable to get invoice details as no valid invoice id found.');\n }\n\n const invoiceId = input.invoiceId;\n\n const searchCriteria: InvoiceDetailsSearchCriteria = {\n InvoiceId: invoiceId\n };\n\n return SalesOrdersDataActions.getInvoiceDetailsAsync({ callerContext: context }, searchCriteria);\n}\n\nexport const getInvoiceDetailsDataAction = createObservableDataAction({\n id: 'get-invoice-details',\n action: >getInvoiceDetails,\n input: CreateGetInvoiceDetailsInput\n});\n\nexport default getInvoiceDetailsDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport {\n InvoicePaidStatus,\n InvoiceSearchCriteria,\n InvoiceType,\n IQueryResultSettings,\n OrderInvoice,\n SalesOrdersDataActions\n} from '@msdyn365-commerce/retail-proxy';\nimport { getCurrentAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/BusinessPartnersDataActions.g';\n\nimport getCustomer, { GetCustomerInput } from '../get-customer';\nimport { QueryResultSettingsProxy } from '../utilities/QueryResultSettingsProxy';\n\nconst getDefaultSearchCriteria = (): InvoiceSearchCriteria => {\n return {\n InvoicePaidStatusValues: [InvoicePaidStatus.None]\n };\n};\n\n/**\n * Input class for get invoice data action.\n */\nexport class GetInvoicesInput implements IActionInput {\n public readonly searchCriteria: InvoiceSearchCriteria;\n\n public readonly queryResultSettings: IQueryResultSettings;\n\n constructor(searchCriteria: InvoiceSearchCriteria, queryResultSettings: IQueryResultSettings) {\n this.searchCriteria = searchCriteria;\n this.queryResultSettings = queryResultSettings;\n }\n\n public getCacheKey = () => 'BusinessPartnerInvoices';\n\n public getCacheObjectType = () => 'OrderInvoice';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\nexport const CreateGetInvoicesInput = (inputData: ICreateActionContext): IActionInput => {\n const { requestContext } = inputData;\n\n // Check if the user is authenticated.\n if (!requestContext.user.isAuthenticated) {\n throw new Error('User is not logged in.');\n }\n\n const queryResultSettings: IQueryResultSettings = QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings;\n\n return new GetInvoicesInput(getDefaultSearchCriteria(), queryResultSettings);\n};\n\nexport async function getInvoices(input: GetInvoicesInput, context: IActionContext): Promise {\n if (!context?.requestContext?.user?.isAuthenticated) {\n throw new Error('Unable to get list of invoices. User is not authenticated.');\n }\n\n input.searchCriteria.InvoiceTypeValues = [InvoiceType.SalesOrderInvoice];\n\n const businessPartner = await getCurrentAsync({ callerContext: context });\n input.searchCriteria.BusinessPartnerId = businessPartner.BusinessPartnerId;\n\n const customer = await getCustomer(new GetCustomerInput(context.requestContext.apiSettings), context);\n input.searchCriteria.CustomerId = customer.AccountNumber;\n\n return SalesOrdersDataActions.getInvoicesAsync(\n { callerContext: context, queryResultSettings: input.queryResultSettings },\n input.searchCriteria\n );\n}\n\nexport const getInvoicesDataAction = createObservableDataAction({\n id: 'get-invoices',\n action: >getInvoices,\n input: CreateGetInvoicesInput\n});\n\nexport default getInvoicesDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { getCartState, ICartState } from '@msdyn365-commerce/global-state';\nimport { LoyaltyCard } from '@msdyn365-commerce/retail-proxy';\nimport { issueLoyaltyCardAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\n\nimport { buildCacheKey } from '.';\nimport { getLoyaltyAction, GetLoyaltyCardInput } from './get-loyalty-card';\n\n/**\n * Input class for the issueLoyalty data action.\n */\nexport class IssueLoyaltyInput implements IActionInput {\n public userAccountNumber?: string;\n\n public apiSettings: ICommerceApiSettings;\n\n constructor(apiSettings: ICommerceApiSettings, userAccountNumber?: string) {\n this.userAccountNumber = userAccountNumber;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey(`IssueLoyalty-${this.userAccountNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'GetIssueLoyalty';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the issueLoyalty method.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createIssueLoyaltyInput = (inputData: ICreateActionContext): IActionInput => {\n const { requestContext } = inputData;\n\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create issue loyalty input. User is not authenticated.');\n }\n\n return new IssueLoyaltyInput(inputData.requestContext.apiSettings);\n};\n\n/**\n * The action method for the issueLoyalty data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function issueLoyaltyAction(input: IssueLoyaltyInput, ctx: IActionContext): Promise {\n const promises: [Promise, Promise] = [getCartState(ctx), _getLoyalty(input, ctx)];\n return Promise.all(promises)\n .then(result => {\n const cartState = result[0];\n const card = result[1];\n if (card && card.CardNumber) {\n updateCart(cartState, card);\n return card;\n }\n\n // @ts-expect-error\n // TO-DO: Remove after SDK bug fix https://msdyneng.visualstudio.com/FinOps/_workitems/edit/473891\n return issueLoyaltyCardAsync({ callerContext: ctx }, { CustomerAccount: input.userAccountNumber || null })\n .then((issuedCard: LoyaltyCard) => {\n updateCart(cartState, issuedCard);\n return issuedCard;\n })\n .catch(error => {\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('Issuing loyalty card failed');\n throw new Error('Issuing loyalty card failed');\n });\n })\n .catch((error: Error) => {\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('Unable to issue loyalty card');\n throw new Error('Unable to issue loyalty card');\n });\n}\n\nasync function _getLoyalty(input: IssueLoyaltyInput, ctx: IActionContext): Promise {\n const loyaltyCardInput = new GetLoyaltyCardInput(input.apiSettings);\n return getLoyaltyAction(loyaltyCardInput, ctx);\n}\n\nfunction updateCart(cartState: ICartState, card: LoyaltyCard): void {\n cartState.updateLoyaltyCardId({ loyaltyCardNumber: card.CardNumber });\n}\n\n/**\n * The getLoyaltyCard data action\n * Returns the loyalty card belonging to the customer.\n */\nexport const issueLoyaltyActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/issue-loyalty',\n action: >issueLoyaltyAction,\n input: <(args: ICreateActionContext) => IActionInput>createIssueLoyaltyInput\n});\n\nexport default issueLoyaltyActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { addProductListLinesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductListsDataActions.g';\nimport { ProductListLine } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\n/**\n * Input class for the AddItemToOrderTemplate data action.\n */\nexport class AddItemToOrderTemplateInput implements IActionInput {\n public readonly orderTemplateId: string;\n\n public readonly productId: number;\n\n public readonly quantity: number;\n\n public readonly unitOfMeasure: string;\n\n constructor(orderTemplateId: string, productId: number, quantity: number, unitOfMeasure: string) {\n this.orderTemplateId = orderTemplateId;\n this.productId = productId;\n this.quantity = quantity;\n this.unitOfMeasure = unitOfMeasure || 'ea';\n }\n\n public getCacheKey = () => 'AddItemToOrderTemplateInput';\n\n public getCacheObjectType = () => 'AddItemToOrderTemplateInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the AddItemToOrderTemplate method.\n * @param {ICreateActionContext} inputData The input data passed to the createInput method.\n * @param {string} orderTemplateId The id of order template to update.\n * @param {number} productId The id of a product to add.\n * @param {number} quantity How many items of this product to add.\n * @param unitOfMeasure\n */\nexport const addItemToOrderTemplateInput = (\n inputData: ICreateActionContext,\n orderTemplateId: string,\n productId: number,\n quantity: number,\n unitOfMeasure: string\n): AddItemToOrderTemplateInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create order template. User is not authenticated.');\n }\n return new AddItemToOrderTemplateInput(orderTemplateId, productId, quantity, unitOfMeasure);\n};\n\n/**\n * The action method for the AddItemToOrderTemplate data action.\n * @param {AddItemToOrderTemplateInput} input The action input.\n * @param {IActionContext} ctx The action context.\n */\nexport async function addItemToOrderTemplateAction(input: AddItemToOrderTemplateInput, ctx: IActionContext): Promise {\n try {\n const productListLineToAdd: ProductListLine = {\n ProductListId: input.orderTemplateId,\n ProductId: input.productId,\n Quantity: input.quantity,\n UnitOfMeasure: input.unitOfMeasure\n };\n\n const productListLine: ProductListLine[] = await addProductListLinesAsync(\n {\n callerContext: ctx\n },\n input.orderTemplateId,\n [productListLineToAdd]\n );\n\n if (productListLine && productListLine.length === 1 && productListLine[0] && productListLine[0].ProductListId) {\n return productListLine[0];\n }\n ctx.telemetry.error('Product list line was not returned when adding it to order template');\n throw new Error('Product list line was not returned when adding it to order template');\n } catch (error) {\n ctx.telemetry.error('Not able to add an item to order template', error);\n throw error;\n }\n}\n\n/**\n * The AddItemToOrderTemplate Data Action.\n * Returns product list line that was added to the order template.\n */\nexport const addItemToOrderTemplateActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/add-item-to-order-template',\n action: >addItemToOrderTemplateAction,\n input: addItemToOrderTemplateInput\n});\n\nexport default addItemToOrderTemplateActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { CartLine, QueryResultSettings } from '@msdyn365-commerce/retail-proxy';\nimport { addCartLinesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CartsDataActions.g';\n\nimport { getPaginatedOrderTemplateLinesAction, GetPaginatedOrderTemplateLinesInput } from './get-paginated-order-template-lines';\n\n/**\n * Input class for the AddOrderTemplateToCart data action.\n */\nexport class AddOrderTemplateToCartInput implements IActionInput {\n public readonly orderTemplateId: string;\n\n constructor(orderTemplateId: string) {\n this.orderTemplateId = orderTemplateId;\n }\n\n public getCacheKey = () => 'AddOrderTemplateToCartInput';\n\n public getCacheObjectType = () => 'AddOrderTemplateToCartInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the AddOrderTemplateToCart method.\n * @param {ICreateActionContext} inputData The input data passed to the createInput method.\n * @param {string} orderTemplateId The id of template.\n */\nexport const addOrderTemplateToCartInput = (inputData: ICreateActionContext, orderTemplateId: string): AddOrderTemplateToCartInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create order template. User is not authenticated.');\n }\n return new AddOrderTemplateToCartInput(orderTemplateId);\n};\n\n/**\n * The action method for the AddOrderTemplateToCart data action.\n * @param {AddOrderTemplateToCartInput} input The action input.\n * @param {IActionContext} ctx The action context.\n * @param context\n */\nexport async function addOrderTemplateToCartAction(input: AddOrderTemplateToCartInput, context: IActionContext): Promise {\n const cartState = await getCartState(context);\n const chunkCount = 1000;\n const queryResultSettings: QueryResultSettings = {\n Paging: {\n Top: chunkCount,\n Skip: 0\n }\n };\n const getPaginatedOrderTemplateLinesInput = new GetPaginatedOrderTemplateLinesInput(input.orderTemplateId, queryResultSettings);\n let orderTemplateLines = await getPaginatedOrderTemplateLinesAction(getPaginatedOrderTemplateLinesInput, context);\n let addedCartLines: CartLine[] = [];\n for (let skip = chunkCount; orderTemplateLines.lines.length > 0; skip += chunkCount) {\n const cartLines: CartLine[] = orderTemplateLines.lines.map(productLine => {\n const cartLine: CartLine = {\n ItemId: productLine.fullProduct?.ProductDetails.ItemId,\n ProductId: productLine.productListLine.ProductId,\n Quantity: productLine.productListLine.Quantity,\n TrackingId: '',\n UnitOfMeasureSymbol: productLine.productListLine.UnitOfMeasure\n };\n return cartLine;\n });\n await addCartLinesAsync({ callerContext: context }, cartState.cart.Id, cartLines, cartState.cart.Version).catch(error => {\n context.telemetry.trace(error.data?.ValidationResults);\n context.telemetry.trace('Unable to add order template to cart.');\n throw error.data?.ValidationResults;\n });\n addedCartLines = addedCartLines.concat(cartLines);\n getPaginatedOrderTemplateLinesInput.queryResultSettings.Paging!.Skip = skip;\n orderTemplateLines = await getPaginatedOrderTemplateLinesAction(getPaginatedOrderTemplateLinesInput, context);\n }\n await cartState.refreshCart({});\n return addedCartLines;\n}\n\n/**\n * The AddOrderTemplateToCart Data Action.\n * Returns created order template.\n */\nexport const addOrderTemplateToCartActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/add-order-template-to-cart',\n action: >addOrderTemplateToCartAction,\n input: addOrderTemplateToCartInput\n});\nexport default addOrderTemplateToCartActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { ProductList, ProductListType } from '@msdyn365-commerce/retail-proxy';\nimport { createProductListAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductListsDataActions.g';\n\n/**\n * Input class for the CreateOrderTemplate data action.\n */\nexport class CreateOrderTemplateInput implements IActionInput {\n public readonly templateName: string;\n\n constructor(templateName: string) {\n this.templateName = templateName;\n }\n\n public getCacheKey = () => 'CreateOrderTemplateInput';\n\n public getCacheObjectType = () => 'CreateOrderTemplateInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the CreateOrderTemplate method.\n * @param {ICreateActionContext} inputData The input data passed to the createInput method.\n * @param {string} templateName The name of template.\n */\nexport const createOrderTemplateInput = (inputData: ICreateActionContext, templateName: string): CreateOrderTemplateInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create order template. User is not authenticated.');\n }\n return new CreateOrderTemplateInput(templateName);\n};\n\n/**\n * The action method for the CreateOrderTemplate data action.\n * @param {CreateOrderTemplateInput} input The action input.\n * @param {IActionContext} ctx The action context.\n */\nexport async function createOrderTemplateAction(input: CreateOrderTemplateInput, ctx: IActionContext): Promise {\n try {\n const orderTemplate: ProductList = {\n Id: '',\n Name: input.templateName,\n ProductListTypeValue: ProductListType.OrderTemplate\n };\n const createdProductList = await createProductListAsync(\n {\n callerContext: ctx\n },\n orderTemplate\n );\n if (createdProductList && createdProductList.Id !== '') {\n return createdProductList;\n }\n ctx.telemetry.error('Created product list was null');\n throw new Error('Created product list was null');\n } catch (error) {\n ctx.telemetry.error('Not able to create order template', error);\n throw error;\n }\n}\n\n/**\n * The CreateOrderTemplate Data Action.\n * Returns created order template.\n */\nexport const createOrderTemplateActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/create-order-template',\n action: >createOrderTemplateAction,\n input: createOrderTemplateInput\n});\n\nexport default createOrderTemplateActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { IQueryResultSettings } from '@msdyn365-commerce/retail-proxy';\nimport { ProductList } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport {\n getOrderTemplates,\n GetOrderTemplatesInput,\n getPaginatedOrderTemplateLinesAction,\n GetPaginatedOrderTemplateLinesInput,\n QueryResultSettingsProxy\n} from '..';\nimport { OrderTemplate } from '../utilities/order-templates';\n\n/**\n * Input class for the GetOrderTemplates data action.\n */\nexport class GetFullOrderTemplateInput implements IActionInput {\n public orderTemplateId: string;\n\n public queryResultSettings: IQueryResultSettings;\n\n constructor(orderTemplateId: string, queryResultSettings: IQueryResultSettings) {\n this.orderTemplateId = orderTemplateId;\n this.queryResultSettings = queryResultSettings;\n }\n\n public getCacheKey = () => `GetFullOrderTemplate|${this.orderTemplateId}`;\n\n public getCacheObjectType = () => 'GetFullOrderTemplate';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the GetOrderTemplate method.\n * @param inputData The input data passed to the createInput method.\n * @param orderTemplateId\n */\nexport const createGetFullOrderTemplateInput = (inputData: ICreateActionContext, orderTemplateId: string): GetFullOrderTemplateInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to get full order templates. User is not authenticated.');\n }\n const queryResultSettings: IQueryResultSettings = QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings;\n queryResultSettings.count = true;\n\n return new GetFullOrderTemplateInput(orderTemplateId, queryResultSettings);\n};\n\n/**\n * The action method for the GetFullOrderTemplate data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function getFullOrderTemplateAction(input: GetFullOrderTemplateInput, ctx: IActionContext): Promise {\n if (!ctx.requestContext.user.isAuthenticated) {\n throw new Error('Unable to get full order template. User is not authenticated.');\n }\n\n const inputParams = new GetOrderTemplatesInput(input.orderTemplateId);\n const productLists: ProductList[] = await getOrderTemplates(inputParams, ctx);\n\n if (!productLists || productLists.length !== 1) {\n throw new Error('Unable to get full order template. Order template was not found.');\n }\n\n const inputLines = new GetPaginatedOrderTemplateLinesInput(productLists[0].Id, input.queryResultSettings);\n const linesState = await getPaginatedOrderTemplateLinesAction(inputLines, ctx);\n return new OrderTemplate(productLists[0], linesState.lines, linesState.totalCount);\n}\n\n/**\n * The GetFullOrderTemplate Data Action\n * Returns order templates.\n */\nexport const getFullOrderTemplateActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/get-full-order-template',\n action: >getFullOrderTemplateAction,\n input: createGetFullOrderTemplateInput\n});\n\nexport default getFullOrderTemplateActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n AsyncResult,\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { IQueryResultSettings } from '@msdyn365-commerce/retail-proxy';\nimport { ProductList } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport {\n getOrderTemplates,\n GetOrderTemplatesInput,\n getPaginatedOrderTemplateLinesAction,\n GetPaginatedOrderTemplateLinesInput,\n QueryResultSettingsProxy\n} from '..';\nimport { IOrderTemplateLinesState, OrderTemplate } from '../utilities/order-templates';\n\n/**\n * Input class for the GetOrderTemplates data action.\n */\nexport class GetFullOrderTemplatesInput implements IActionInput {\n public queryResultSettings: IQueryResultSettings;\n public getPrice?: boolean;\n public getRating?: boolean;\n\n constructor(queryResultSettings: IQueryResultSettings, getPrices = true, getRatings = true) {\n this.queryResultSettings = queryResultSettings;\n this.getPrice = getPrices;\n this.getRating = getRatings;\n }\n\n public getCacheKey = () => 'GetFullOrderTemplates';\n\n public getCacheObjectType = () => 'GetFullOrderTemplates';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the GetOrderTemplate method.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createGetFullOrderTemplatesInput = (inputData: ICreateActionContext): GetFullOrderTemplatesInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to get full order templates. User is not authenticated.');\n }\n\n const queryResultSettings: IQueryResultSettings = QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings;\n queryResultSettings.count = true;\n\n return new GetFullOrderTemplatesInput(queryResultSettings);\n};\n\n/**\n * The action method for the GetFullOrderTemplates data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function getFullOrderTemplatesAction(input: GetFullOrderTemplatesInput, ctx: IActionContext): Promise {\n if (!ctx.requestContext.user.isAuthenticated) {\n throw new Error('Unable to get full order templates. User is not authenticated.');\n }\n\n const orderTemplates: OrderTemplate[] = [];\n\n const inputParams = new GetOrderTemplatesInput();\n const productLists: ProductList[] = await getOrderTemplates(inputParams, ctx);\n\n if (!productLists || productLists.length === 0) {\n return orderTemplates;\n }\n\n const inputLinesRequests: AsyncResult[] = [];\n\n // Preparing requests for parallel queries.\n for (const list of productLists) {\n const inputLines = new GetPaginatedOrderTemplateLinesInput(\n list.Id,\n input.queryResultSettings,\n undefined,\n input.getPrice,\n input.getRating\n );\n\n inputLinesRequests.push(getPaginatedOrderTemplateLinesAction(inputLines, ctx));\n }\n\n const inputLinesResponses = await Promise.all(inputLinesRequests);\n\n for (const list of productLists) {\n const productLinesResponse = inputLinesResponses.filter(\n x => x.lines.length > 0 && x.lines[0].productListLine.ProductListId === list.Id\n );\n\n // Lines exist for this product\n if (productLinesResponse.length > 0) {\n orderTemplates.push(new OrderTemplate(list, productLinesResponse[0].lines, productLinesResponse[0].totalCount));\n } else {\n // Add empty order template\n orderTemplates.push(new OrderTemplate(list, [], 0));\n }\n }\n\n ctx.trace(orderTemplates.length.toString());\n return orderTemplates;\n}\n\n/**\n * The GetFullOrderTemplates Data Action\n * Returns order templates.\n */\nexport const getFullOrderTemplatesActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/get-full-order-templates',\n action: >getFullOrderTemplatesAction,\n input: createGetFullOrderTemplatesInput\n});\n\nexport default getFullOrderTemplatesActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { IQueryResultSettings } from '@msdyn365-commerce/retail-proxy';\n\nimport { OrderTemplate } from '../utilities/order-templates';\nimport { QueryResultSettingsProxy } from '../utilities/QueryResultSettingsProxy';\nimport getFullOrderTemplates, { GetFullOrderTemplatesInput } from './get-full-order-templates';\n\n/**\n * Input class for the GetOrderTemplates data action.\n */\nexport class GetOrderTemplatesPreviewInput implements IActionInput {\n public queryResultSettings: IQueryResultSettings;\n\n constructor(queryResultSettings: IQueryResultSettings) {\n this.queryResultSettings = queryResultSettings;\n this.queryResultSettings.count = true;\n this.queryResultSettings.Paging!.Top = 4;\n }\n\n public getCacheKey = () => 'GetOrderTemplatesPreview';\n\n public getCacheObjectType = () => 'GetOrderTemplatesPreview';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the GetOrderTemplate method.\n * @param inputData The input data passed to the createInput method.\n */\nexport const createGetOrderTemplatesPreviewInput = (inputData: ICreateActionContext): GetOrderTemplatesPreviewInput => {\n const queryResultSettings: IQueryResultSettings = QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings;\n return new GetOrderTemplatesPreviewInput(queryResultSettings);\n};\n\n/**\n * The action method for the GetOrderTemplatesPreview data action.\n * @param input The action input.\n * @param context The action context.\n */\nexport async function getOrderTemplatesPreview(input: GetOrderTemplatesPreviewInput, context: IActionContext): Promise {\n const response: OrderTemplate[] = [];\n if (!context.requestContext.user.isAuthenticated) {\n context.trace('Unable to get order templates preview. User is not authenticated.');\n return Promise.resolve(response);\n }\n return getFullOrderTemplates(new GetFullOrderTemplatesInput(input.queryResultSettings, false, false), context);\n}\n\n/**\n * The GetOrderTemplatesPreview Data Action\n * Returns order templates.\n */\nexport const getOrderTemplatesPreviewDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/get-order-templates-preview',\n action: >getOrderTemplatesPreview,\n input: createGetOrderTemplatesPreviewInput\n});\n\nexport default getOrderTemplatesPreviewDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { QueryResultSettings } from '@msdyn365-commerce/retail-proxy';\nimport { searchAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductListsDataActions.g';\nimport { ProductList, ProductListSearchCriteria, ProductListType } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { QueryResultSettingsProxy } from '../utilities/QueryResultSettingsProxy';\n\n/**\n * Input class for the GetOrderTemplates data action.\n */\nexport class GetOrderTemplatesInput implements IActionInput {\n public readonly productListId: string;\n\n public readonly queryResultSettings?: QueryResultSettings;\n\n constructor(productListId?: string, queryResultSettings?: QueryResultSettings) {\n this.productListId = productListId || '';\n this.queryResultSettings = queryResultSettings;\n }\n\n public getCacheKey = (): string =>\n `${this.productListId}|${this.queryResultSettings?.Paging?.Top}|${this.queryResultSettings?.Paging?.Skip}`;\n\n public getCacheObjectType = () => 'ProductList';\n\n public dataCacheType = (): CacheType => 'instance';\n\n public shouldCacheOutput = () => false;\n}\n\n/**\n * CreateInput method for the GetOrderTemplate method.\n * @param inputData The input data passed to the createInput method.\n * @param productListId? The product list identifier.\n * @param queryResultSettings? The query result setting required for pagination/ordering.\n * @param productListId\n * @param queryResultSettings\n */\nexport const createGetOrderTemplatesInput = (\n inputData: ICreateActionContext,\n productListId?: string,\n queryResultSettings?: QueryResultSettings\n): GetOrderTemplatesInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create get order template. User is not authenticated.');\n }\n\n return new GetOrderTemplatesInput(productListId || '', queryResultSettings);\n};\n\n/**\n * The action method for the GetOrderTemplates data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function getOrderTemplatesAction(input: GetOrderTemplatesInput, ctx: IActionContext): Promise {\n try {\n const productListSearchCriteria: ProductListSearchCriteria = {\n ProductListId: input.productListId,\n ProductListType: `${ProductListType.OrderTemplate}`\n };\n return await searchAsync(\n {\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n productListSearchCriteria\n );\n } catch (error) {\n ctx.telemetry.error('Not able to get order template(s)', error);\n throw error;\n }\n}\n\n/**\n * The GetOrderTemplates Data Action\n * Returns order templates.\n */\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/get-order-templates',\n action: >getOrderTemplatesAction,\n input: createGetOrderTemplatesInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { convertToString, IQueryResultSettings } from '@msdyn365-commerce/retail-proxy';\nimport { getProductListLinesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductListsDataActions.g';\n\nimport { FullProductInput, getFullProducts, ProductDetailsCriteria, QueryResultSettingsProxy } from '..';\nimport { ArrayExtensions } from '../utilities';\nimport { IOrderTemplateLinesState, OrderTemplateLine } from '../utilities/order-templates';\n\n/**\n * Input class for the GetOrderTemplates data action.\n */\nexport class GetPaginatedOrderTemplateLinesInput implements IActionInput {\n public orderTemplateId: string;\n public queryResultSettings: IQueryResultSettings;\n public searchText: string;\n public getPrice: boolean = true;\n public getRating: boolean = true;\n\n constructor(\n orderTemplateId: string,\n queryResultSettings: IQueryResultSettings,\n searchText?: string,\n getPrice: boolean = true,\n getRating: boolean = true\n ) {\n this.orderTemplateId = orderTemplateId;\n this.queryResultSettings = queryResultSettings;\n this.searchText = searchText || '';\n this.getPrice = getPrice;\n this.getRating = getRating;\n }\n\n public getCacheKey = () =>\n `GetPaginatedOrderTemplateLines|${this.orderTemplateId}|${convertToString(this.queryResultSettings)}|${\n this.searchText\n }|${convertToString(this.getPrice)}|${convertToString(this.getRating)}`;\n\n public getCacheObjectType = () => 'GetPaginatedOrderTemplateLines';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the GetOrderTemplate method.\n * @param inputData The input data passed to the createInput method.\n * @param orderTemplateId\n * @param searchText\n */\nexport const createGetPaginatedOrderTemplateLinesInput = (\n inputData: ICreateActionContext,\n orderTemplateId: string,\n searchText?: string\n): GetPaginatedOrderTemplateLinesInput => {\n const queryResultSettings: IQueryResultSettings = QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings;\n queryResultSettings.count = true;\n return new GetPaginatedOrderTemplateLinesInput(orderTemplateId, queryResultSettings, searchText);\n};\n\nexport const getProductDetailsCriteriaFromActionInput = (inputData: GetPaginatedOrderTemplateLinesInput): ProductDetailsCriteria => {\n return {\n getPrice: inputData.getPrice ?? true,\n getRating: inputData.getRating ?? true\n };\n};\n\n/**\n * The action method for the GetPaginatedOrderTemplateLines data action.\n * @param input The action input.\n * @param context The action context.\n */\nexport async function getPaginatedOrderTemplateLinesAction(\n input: GetPaginatedOrderTemplateLinesInput,\n context: IActionContext\n): Promise {\n if (!context.requestContext.user.isAuthenticated) {\n throw new Error('Unable to get full order templates. User is not authenticated.');\n }\n\n const orderTemplateLinesState: IOrderTemplateLinesState = {\n lines: [],\n totalCount: 0\n };\n const promise = getProductListLinesAsync(\n {\n callerContext: context,\n queryResultSettings: input.queryResultSettings\n },\n input.orderTemplateId,\n input.searchText\n );\n const productListLines = await promise;\n const productInputs: FullProductInput[] = [];\n if (ArrayExtensions.hasElements(productListLines)) {\n orderTemplateLinesState.totalCount = promise.metadata.count || productListLines.length;\n productListLines.forEach(listLine => {\n if (listLine.ProductId) {\n orderTemplateLinesState.lines.push(new OrderTemplateLine(listLine));\n productInputs.push(\n new FullProductInput(\n listLine.ProductId,\n context.requestContext.apiSettings,\n getProductDetailsCriteriaFromActionInput(input),\n context.requestContext\n )\n );\n }\n });\n if (ArrayExtensions.hasElements(productInputs)) {\n const fullProductsInfo = await getFullProducts(productInputs, context)\n .then((products: FullProduct[]) => {\n if (products) {\n return products;\n }\n return [];\n })\n .catch(error => {\n context.trace(error);\n context.telemetry.error(error.message);\n context.telemetry.error('[getPaginatedOrderTemplateLinesAction] Unable to retrieve product info.');\n });\n if (fullProductsInfo) {\n orderTemplateLinesState.lines.forEach(line => {\n const fullProduct = fullProductsInfo.find(\n product => product.ProductDetails.RecordId === line.productListLine.ProductId\n );\n if (!fullProduct) {\n context.telemetry.error(\n '[getPaginatedOrderTemplateLinesAction] Unable to find product info for an order template line.'\n );\n return;\n }\n line.fullProduct = fullProduct;\n });\n }\n return orderTemplateLinesState;\n }\n context.trace(orderTemplateLinesState.lines.length.toString());\n return orderTemplateLinesState;\n }\n return orderTemplateLinesState;\n}\n\n/**\n * The GetPaginatedOrderTemplateLines Data Action\n * Returns order templates.\n */\nexport const getPaginatedOrderTemplateLinesActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/get-paginated-order-template-lines',\n action: getPaginatedOrderTemplateLinesAction as IAction,\n input: createGetPaginatedOrderTemplateLinesInput\n});\n\nexport default getPaginatedOrderTemplateLinesActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { updateAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductListsDataActions.g';\nimport { ProductList } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\n/**\n * Input class for the UpdateOrderTemplate data action.\n */\nexport class UpdateOrderTemplateHeaderInput implements IActionInput {\n public readonly orderTemplate: ProductList;\n\n constructor(orderTemplate: ProductList) {\n this.orderTemplate = orderTemplate;\n }\n\n public getCacheKey = () => 'UpdateOrderTemplateHeaderInput';\n\n public getCacheObjectType = () => 'UpdateOrderTemplateHeaderInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the UpdateOrderTemplateHeader method.\n * @param {ICreateActionContext} inputData The input data passed to the createInput method.\n * @param {ProductList} orderTemplate The template header.\n */\nexport const updateOrderTemplateHeaderInput = (\n inputData: ICreateActionContext,\n orderTemplate: ProductList\n): UpdateOrderTemplateHeaderInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to update order template. User is not authenticated.');\n }\n return new UpdateOrderTemplateHeaderInput(orderTemplate);\n};\n\n/**\n * The action method for the UpdateOrderTemplate data action.\n * @param {UpdateOrderTemplateHeaderInput} input The action input.\n * @param {IActionContext} ctx The action context.\n */\nexport async function updateOrderTemplateHeaderAction(input: UpdateOrderTemplateHeaderInput, ctx: IActionContext): Promise {\n try {\n const { orderTemplate } = input;\n const updatedProductList = await updateAsync(\n {\n callerContext: ctx\n },\n orderTemplate\n );\n if (updatedProductList) {\n return updatedProductList;\n }\n ctx.telemetry.error(`Updated product list ${orderTemplate.Id} came back as null.`);\n throw new Error('Updated product list was null.');\n } catch (error) {\n ctx.telemetry.error('Not able to update order template', error);\n throw error;\n }\n}\n\n/**\n * The UpdateOrderTemplate Data Action.\n * Returns updated order template.\n */\nexport const updateOrderTemplateHeaderActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/update-order-template-header',\n action: >updateOrderTemplateHeaderAction,\n input: updateOrderTemplateHeaderInput\n});\n\nexport default updateOrderTemplateHeaderActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { updateProductListLinesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductListsDataActions.g';\nimport { ProductListLine } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport getPaginatedOrderTemplateLines, { GetPaginatedOrderTemplateLinesInput } from './get-paginated-order-template-lines';\n\n/**\n * Input class for the UpdateOrderTemplate data action.\n */\nexport class UpdateOrderTemplateInput implements IActionInput {\n public readonly orderTemplateId: string;\n\n public readonly productId: number;\n\n public readonly quantity: number;\n\n public readonly unitOfMeasure: string;\n\n constructor(orderTemplateId: string, productId: number, quantity: number, unitOfMeasure: string) {\n this.orderTemplateId = orderTemplateId;\n this.productId = productId;\n this.quantity = quantity;\n this.unitOfMeasure = unitOfMeasure || 'ea';\n }\n\n public getCacheKey = () => 'UpdateOrderTemplateInput';\n\n public getCacheObjectType = () => 'UpdateOrderTemplateInput';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * CreateInput method for the UpdateOrderTemplate method.\n * @param {ICreateActionContext} inputData The input data passed to the createInput method.\n * @param {string} orderTemplateId The id of order template to update.\n * @param {number} productId The id of a product to add.\n * @param {number} quantity How many items of this product to add.\n * @param unitOfMeasure\n */\nexport const updateOrderTemplateInput = (\n inputData: ICreateActionContext,\n orderTemplateId: string,\n productId: number,\n quantity: number,\n unitOfMeasure: string\n): UpdateOrderTemplateInput => {\n const { requestContext } = inputData;\n if (!requestContext.user.isAuthenticated) {\n throw new Error('Unable to create order template. User is not authenticated.');\n }\n return new UpdateOrderTemplateInput(orderTemplateId, productId, quantity, unitOfMeasure);\n};\n\n/**\n * The action method for the UpdateOrderTemplate data action.\n * @param {UpdateOrderTemplateInput} input The action input.\n * @param {IActionContext} ctx The action context.\n */\nexport async function updateOrderTemplateAction(input: UpdateOrderTemplateInput, ctx: IActionContext): Promise {\n try {\n if (!ctx.requestContext.user.isAuthenticated) {\n throw new Error('User token was not found when updating the order template');\n }\n const getLinesInput = new GetPaginatedOrderTemplateLinesInput(input.orderTemplateId, {}, input.productId.toString());\n const linesState = await getPaginatedOrderTemplateLines(getLinesInput, ctx);\n if (!linesState) {\n throw new Error('Order template was not found when updating the order template');\n }\n\n const linesToUpdate = linesState.lines.filter(line => line.productListLine.ProductId === input.productId);\n if (linesToUpdate.length !== 1) {\n throw new Error('Unable to find the line to update when updating the order template');\n }\n\n const lineToUpdate = linesToUpdate[0].productListLine;\n\n lineToUpdate.UnitOfMeasure = input.unitOfMeasure;\n lineToUpdate.Quantity = input.quantity;\n\n const updatedLines: ProductListLine[] = await updateProductListLinesAsync(\n {\n callerContext: ctx\n },\n input.orderTemplateId,\n [lineToUpdate]\n );\n\n if (!updatedLines || updatedLines.length !== 1) {\n throw new Error('Server returned invalid lines when updating order template');\n }\n const updatedLine = updatedLines.filter(line => line.ProductId === input.productId);\n if (\n updatedLine.length !== 1 ||\n updatedLine[0].Quantity !== input.quantity ||\n updatedLine[0].UnitOfMeasure !== input.unitOfMeasure\n ) {\n throw new Error('Server did not update the line when updating order template');\n }\n return updatedLine[0];\n } catch (error) {\n ctx.telemetry.error('Not able to add an item to order template', error);\n throw error;\n }\n}\n\n/**\n * The UpdateOrderTemplate Data Action.\n * Returns product list line that was added to the order template.\n */\nexport default createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/order-templates/update-order-template-line',\n action: >updateOrderTemplateAction,\n input: updateOrderTemplateInput\n});\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core';\nimport { ProductRefinerValue, ProductSearchResult } from '@msdyn365-commerce/retail-proxy';\nimport { createRefineSearchByCategoryInput } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport { retailAction } from '@msdyn365-commerce/retail-proxy/dist/retail-action';\n\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Action Input class for the refineSearchByCategory data action.\n */\nexport class RefineSearchByCriteriaInput implements IActionInput {\n public readonly categoryId?: number;\n\n public readonly channelId?: number;\n\n public readonly refinementCriteria: ProductRefinerValue[];\n\n public readonly catalogId: number;\n\n public readonly queryResultSettingsProxy: QueryResultSettingsProxy;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(\n queryResultSettingsProxy: QueryResultSettingsProxy,\n apiSettings: ICommerceApiSettings,\n categoryId?: number,\n channelId?: number,\n refinementCriteria?: ProductRefinerValue[],\n catalogId?: number\n ) {\n this.categoryId = categoryId;\n this.channelId = channelId;\n this.refinementCriteria = refinementCriteria || [];\n this.queryResultSettingsProxy = queryResultSettingsProxy;\n this.catalogId = catalogId || 0;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey('RefineSearchByCriteriaInputCache', this.apiSettings);\n\n public getCacheObjectType = () => 'RefineSearchByCriteriaInput';\n\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * CreateInput method for the refineSearchByCategory data action.\n * @param inputData\n */\nexport const createInput = (inputData: ICreateActionContext>): IActionInput => {\n const refinementCriteria = inputData.config && inputData.config.refinementCriteria;\n\n if (inputData && inputData.requestContext && inputData.requestContext.query && inputData.requestContext.query.categoryId) {\n return createRefineSearchByCategoryInput(\n QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings,\n +inputData.requestContext.apiSettings.channelId,\n inputData.config ? Number(inputData.config.catalogId) : 0,\n +inputData.requestContext.query.categoryId,\n !Array.isArray(refinementCriteria)\n ? []\n : refinementCriteria.map((refinementCriterion: ProductRefinerValue) => refinementCriterion)\n );\n }\n\n throw new Error('Please specify categoryId, refinerId, and refinerSourceValue query string in request.');\n};\n\n/**\n * The RefineSearchByCategory data action\n * Uses categoryId query string parameter to call the RefinerSearchByCategory\n * RetailServer API to get information about products.\n */\nexport const retailActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/regin-search-by-category',\n action: >retailAction,\n input: createInput\n});\n\nexport default retailActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { createObservableDataAction, IAction, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { IDataServiceRequest, retailAction } from '@msdyn365-commerce/retail-proxy/dist';\nimport { createSearchByTextInput } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport { ProductSearchResult } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { QueryResultSettingsProxy } from './utilities/QueryResultSettingsProxy';\n\n/**\n * CreateInput method for the searchByText data action.\n * @param inputData\n */\nexport function createSearchByTextInputFunc(inputData: ICreateActionContext, IGeneric>): IDataServiceRequest {\n const {\n requestContext: {\n query,\n apiSettings: { channelId }\n }\n } = inputData;\n\n const search = query && query.q;\n\n if (!search) {\n throw new Error(\n 'Unable to preform search without search text. Query string ?q={searchText} must be present or should be configued in module data.'\n );\n }\n\n const querySettingsProxy = QueryResultSettingsProxy.fromInputData(inputData);\n return createSearchByTextInput(querySettingsProxy.QueryResultSettings, Number(channelId), 0, search);\n}\n\n/**\n * The searchByText data action\n * Queries RetailServers product searchByText API using a\n * query string parameter and returns a list of ProductSearchResults.\n */\nexport const retailActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/search-by-text',\n action: >retailAction,\n input: createSearchByTextInputFunc\n});\n\nexport default retailActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext } from '@msdyn365-commerce/core';\nimport { Address, Customer } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { createAddressManagementInput, doAddressManagementOperation, IAddressManagementInput } from './add-address';\n\n// TODO: Centralize this logic in a common utility area\nexport function updateAddressHandler(customer: Customer, address: Address): Customer {\n customer.Addresses = customer.Addresses || [];\n if (address.IsPrimary) {\n customer.Addresses.forEach(cur => (cur.IsPrimary = false));\n }\n customer.Addresses = [...customer.Addresses.filter(cur => cur.RecordId !== address.RecordId), address];\n return customer;\n}\n\nexport async function updateAddressAction(input: IAddressManagementInput, ctx: IActionContext): Promise {\n return doAddressManagementOperation(input, ctx, updateAddressHandler);\n}\n\n/**\n * The updateAddress data action\n * Calls the read RetailServer API to get information about a customer\n * Merge the passed address information with the address information from\n * the retireved customer, and then updates that customer via the update RetailServer API.\n */\nexport const updateAddressActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/update-address',\n action: >updateAddressAction,\n input: <(args: ICreateActionContext) => IActionInput>(createAddressManagementInput)\n});\n\nexport default updateAddressActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings\n} from '@msdyn365-commerce/core';\nimport { Customer, CustomerAttribute } from '@msdyn365-commerce/retail-proxy';\nimport { readAsync, updateAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g';\n\nimport { buildCacheKey } from '.';\nimport { GetCustomerInput } from './get-customer';\n\nexport interface IUpdateCustomerAttributesInput extends IActionInput {\n phone?: string;\n vatNumber?: string;\n customerAttributes: CustomerAttribute[];\n userAccountNumber: string;\n apiSettings: ICommerceApiSettings;\n}\n\n/**\n * Input class for the updateCustomerAttributes.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class updateCustomerAttributesInput implements IUpdateCustomerAttributesInput {\n public userAccountNumber: string;\n\n public customerAttributes: CustomerAttribute[];\n\n public apiSettings: ICommerceApiSettings;\n\n public phone?: string;\n\n public vatNumber?: string;\n\n constructor(\n userAccountNumber: string,\n customerAttributes: CustomerAttribute[],\n apiSettings: ICommerceApiSettings,\n phone?: string,\n vatNumber?: string\n ) {\n this.userAccountNumber = userAccountNumber;\n this.apiSettings = apiSettings;\n this.customerAttributes = customerAttributes;\n this.phone = phone;\n this.vatNumber = vatNumber;\n }\n\n public getCacheKey = (): string => buildCacheKey(`${this.userAccountNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'Customer';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * The action method for the updateCustomerAttributes data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function updateCustomerAttributesAction(input: IUpdateCustomerAttributesInput, ctx: IActionContext): Promise {\n const { customerAttributes, phone, vatNumber, userAccountNumber } = input;\n\n const customer = await readAsync({ callerContext: ctx, bypassCache: 'get' }, userAccountNumber);\n\n if (!customer) {\n ctx.telemetry.debug('[update-customer-attributes] Unable to find customer');\n throw new Error('Unable to find customer');\n }\n\n const newCustomer = { ...customer };\n newCustomer.Phone = phone;\n newCustomer.VatNumber = vatNumber;\n newCustomer.Attributes = customerAttributes;\n\n const updatedCustomer = await updateAsync({ callerContext: ctx }, newCustomer);\n\n if (!updatedCustomer) {\n ctx.telemetry.debug('[update-customer-attributes] Unable to update customer attributes');\n throw new Error('Unable to update customer attributes');\n }\n\n ctx.update(new GetCustomerInput(ctx.requestContext.apiSettings), updatedCustomer);\n\n return updatedCustomer;\n}\n\n/**\n * The updateCustomerAttributes data action\n * Returns the updated customer.\n */\nexport const updateCustomerAttributesActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/update-customer-attributes',\n action: >updateCustomerAttributesAction\n});\n\nexport default updateCustomerAttributesActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICommerceApiSettings\n} from '@msdyn365-commerce/core';\nimport { Customer } from '@msdyn365-commerce/retail-proxy';\nimport { readAsync, updateAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g';\n\nimport { buildCacheKey } from '.';\nimport { GetCustomerInput } from './get-customer';\n\nexport interface IUpdateCustomerPersonalizationInput extends IActionInput {\n isOptOut: boolean;\n userAccountNumber: string;\n apiSettings: ICommerceApiSettings;\n preferenceType?: string;\n}\n\n/**\n * Input class for the updateCustomerPersonalization.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class updateCustomerPersonalizationInput implements IUpdateCustomerPersonalizationInput {\n public userAccountNumber: string;\n\n public isOptOut: boolean;\n\n public apiSettings: ICommerceApiSettings;\n\n public preferenceType: string | undefined;\n\n constructor(userAccountNumber: string, isOptOut: boolean, apiSettings: ICommerceApiSettings, preferenceType?: string) {\n this.userAccountNumber = userAccountNumber;\n this.apiSettings = apiSettings;\n this.isOptOut = isOptOut;\n this.preferenceType = preferenceType;\n }\n\n public getCacheKey = (): string => buildCacheKey(`${this.userAccountNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'Customer';\n\n public dataCacheType = (): CacheType => 'none';\n}\n\n/**\n * The action method for the updateCustomerPersonalization data action.\n * @param input The action input.\n * @param ctx The action context.\n */\nexport async function updateCustomerPersonalizationAction(\n input: IUpdateCustomerPersonalizationInput,\n ctx: IActionContext\n): Promise {\n const { userAccountNumber, isOptOut, preferenceType } = input;\n const customer = await readAsync({ callerContext: ctx, bypassCache: 'get' }, userAccountNumber);\n if (!customer) {\n throw new Error('Unable to find customer');\n }\n\n const newCustomer = { ...customer };\n\n switch (preferenceType) {\n case 'web-tracking':\n newCustomer.OptOutWebActivityTracking = isOptOut;\n break;\n case undefined:\n case 'personalization':\n default:\n newCustomer.OptOutPersonalization = isOptOut;\n }\n\n const updatedCustomer = await updateAsync({ callerContext: ctx }, newCustomer);\n\n if (!updatedCustomer) {\n throw new Error('Unable to update customer');\n }\n\n ctx.update(new GetCustomerInput(ctx.requestContext.apiSettings), updatedCustomer);\n\n return updatedCustomer;\n}\n\n/**\n * The updateCustomerPersonalization data action\n * Returns the updated customer.\n */\nexport const updateCustomerPersonalizationActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/update-customer-personalization',\n action: >updateCustomerPersonalizationAction\n});\n\nexport default updateCustomerPersonalizationActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext } from '@msdyn365-commerce/core';\nimport { readAsync, updateAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g';\nimport { Address, Customer } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { createAddressManagementInput, IAddressManagementInput } from './add-address';\nimport { GetCustomerInput } from './get-customer';\n\nexport function updatePrimaryAddressHandler(customer: Customer, address: Address): Customer {\n customer.Addresses = setPrimaryAddress({ ...address }, [...(customer.Addresses || [])]);\n return customer;\n}\n\nexport async function updatePrimaryAddressAction(input: IAddressManagementInput, ctx: IActionContext): Promise {\n const { address } = input;\n\n const customer = await readAsync({ callerContext: ctx, bypassCache: 'get' }, '');\n\n if (!customer) {\n throw new Error('Unable to find customer');\n }\n\n customer.Addresses = setPrimaryAddress({ ...address }, [...(customer.Addresses ?? [])]);\n const updatedCustomer = await updateAsync({ callerContext: ctx }, customer);\n\n if (!updatedCustomer) {\n throw new Error('Unable to update customer');\n }\n\n ctx.update(new GetCustomerInput(ctx.requestContext.apiSettings), updatedCustomer);\n\n return updatedCustomer.Addresses || [];\n}\n\n/**\n * The updatePrimaryAddress data action\n * Calls the read RetailServer API to get information about a customer\n * Merge the passed address information with the address information from\n * the retireved customer, and then updates that customer via the update RetailServer API.\n */\nexport const updatePrimaryAddressActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/update-primary-address',\n action: >updatePrimaryAddressAction,\n input: <(args: ICreateActionContext) => IActionInput>(createAddressManagementInput),\n isBatched: false\n});\nexport default updatePrimaryAddressActionDataAction;\n\nconst setPrimaryAddress = (primaryAddresses: Address, addresses: Address[]): Address[] => {\n return addresses.map(addr => {\n if (addr.RecordId === primaryAddresses.RecordId) {\n addr.IsPrimary = true;\n } else {\n addr.IsPrimary = false;\n }\n return addr;\n });\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport msdyn365Commerce, { IParameterizeFeatureFlags } from '@msdyn365-commerce/core';\n\nexport function parameterize(\n name: string = '',\n sep = '-',\n parameterizeFeatureFlags: IParameterizeFeatureFlags = {},\n neutralizedName?: string\n) {\n // If neutralizedName flag enabled, we use neutralizedName to construct string\n const candidateName =\n (msdyn365Commerce.platformSettings && msdyn365Commerce.platformSettings.enableUrlLocalization) ||\n parameterizeFeatureFlags.enableUrlLocalization\n ? name\n : neutralizedName || name;\n\n /*\n 1\t‘ ‘ (space)\t-> (single dash)\n 3\tAny character disallowed in URLs -> URL-encode\n 5\t‘ & ‘ (space ampersand space) -> (single dash)\n 6\t‘ - ‘ (space dash space) -> (single dash)\n 7\t‘ ‘ (2+ spaces) -> (single dash)\n 10\t[A-Z] (capital letters) -> [a-z] (lower-case)\n 12\tAny non-ASCII character outside of the set of disallowed characters -> URL-encode\n */\n if (\n parameterizeFeatureFlags.enableUrlEncoding ||\n (msdyn365Commerce.platformSettings && msdyn365Commerce.platformSettings.enableUrlEncoding)\n ) {\n // Replace url reserved characters with dash, and remove front and end dash;\n // &*!() reserved characters that can not be encoded by encodeURIComponent()\n return encodeURIComponent(\n candidateName\n .toLowerCase()\n .replace(/[\\s!&'()*]+/g, '-')\n .trim()\n .replace(/-+/g, '-')\n .replace(/^-+|-+$/g, '')\n );\n }\n return name\n .toLowerCase()\n .replace(/[^\\d_a-z\\-]+/g, ' ')\n .trim()\n .replace(/\\s+/g, sep);\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport { getParameterizeFeatureFlags, getUrlSync, IActionContext, IParameterizeFeatureFlags } from '@msdyn365-commerce/core';\n\nimport { parameterize } from './parameterize';\n\ninterface ICategoryMap {\n [RecordId: number]: CategoryHierarchy;\n}\n\n/**\n * Builds slugs for category.\n * @param category\n * @param categoryMap\n * @param parameterizeFeatureFlags\n */\nexport function getCategorySlug(\n category: CategoryHierarchy,\n categoryMap: ICategoryMap,\n parameterizeFeatureFlags?: IParameterizeFeatureFlags\n): string {\n if (!category || !category.Name) {\n // Invalid category\n return '';\n }\n const categoryName = parameterize(category.Name, undefined, parameterizeFeatureFlags, category.NeutralizedName);\n if (!category.ParentCategory || category.ParentCategory === 0) {\n // Base case assign url\n category.Slug = category.Slug || `/${categoryName}`;\n } else if (category.ParentCategory) {\n category.Slug =\n category.Slug ||\n `${getCategorySlug(categoryMap[category.ParentCategory], categoryMap, parameterizeFeatureFlags)}/${categoryName}`;\n }\n\n return category.Slug || '';\n}\n\n/**\n * Gets Url for category hierarchy. Returns string and adds url to Url property of category hierarchy.\n * @param category Category to generate URL for.\n * @param ctx\n * @param categoryMap Dictionary of all categories.\n */\nexport function getCategoryUrl(category: CategoryHierarchy, ctx?: IActionContext, categoryMap?: ICategoryMap): string | undefined {\n if (!category.Url && ctx && categoryMap) {\n if (!category.Slug) {\n const parameterizeFeatureFlags: IParameterizeFeatureFlags = ctx.requestContext ? getParameterizeFeatureFlags(ctx) : {};\n category.Slug = getCategorySlug(category, categoryMap, parameterizeFeatureFlags);\n }\n category.Url = getUrlSync('category', ctx, { category });\n }\n return category.Url;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { getUrlSync, IActionContext } from '@msdyn365-commerce/core';\n\n/**\n * Syncronously creates an invoice detail page url.\n * @param invoiceId Invoice Id.\n * @param ctx\n */\nexport function getInvoiceDetailsPageUrlSync(invoiceId: string, ctx: IActionContext): string {\n let url = getUrlSync('invoice-details', ctx) || '';\n url = url.includes('?') ? url.substr(0, url.indexOf('?')) : url;\n return `${url}?invoiceId=${invoiceId}`;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport { getUrlSync, IActionContext } from '@msdyn365-commerce/core';\nimport { SimpleProduct } from '@msdyn365-commerce/retail-proxy';\n\n/**\n * Syncronously creates a product url.\n * @param product Simple product to get url from.\n * @param ctx\n * @param category Category to add to product url.\n */\nexport function getProductUrlSync(product: SimpleProduct, ctx: IActionContext, category?: CategoryHierarchy): string {\n const selectedProduct = { ...product, RecordId: product.MasterProductId || product.RecordId };\n\n return getProductPageUrlSync(selectedProduct.Name || '', selectedProduct.RecordId, ctx, category)!;\n}\n\n/**\n * Syncronously creates a product detail page url.\n * @param name Simple product name.\n * @param recordId Record id of product.\n * @param ctx\n * @param category\n */\nexport function getProductPageUrlSync(name: string, recordId: number, ctx: IActionContext, category?: CategoryHierarchy): string {\n return getUrlSync('product', ctx, {\n product: { Name: name || '', RecordId: recordId },\n category\n })!;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/**\n * Represents a pair of two fields: key and value.\n * Used to initialize a dictionary.\n */\nexport interface IKeyValuePair {\n readonly key: Key;\n readonly value: Value;\n}\n\n/**\n * Represents a dictionary in memory storage.\n */\nexport class Dictionary {\n /**\n * Values stored in the dictionary.\n */\n private _values: { [eventName: string]: Value };\n\n /**\n * The number of values stored in the dictionary (does not include keys).\n */\n private _length: number;\n\n /**\n * Initializes an empty dictionary or a dictionary with the given key value pairs.\n * @param {IKeyValuePair[]} entries The key value pairs which should be stored in the dictionary initially.\n */\n public constructor(...entries: IKeyValuePair[]) {\n this._values = {};\n this._length = 0;\n entries.forEach(keyValuePair => {\n this.setValue(keyValuePair.key, keyValuePair.value);\n });\n }\n\n /**\n * Removes value from the dictionary for the given key.\n * @param {Key} key The key to retrieve the value.\n * @remark Does nothing in case the key is not present in the dictionary.\n */\n public removeValue(key: Key): void {\n if (!this.hasValue(key)) {\n return;\n }\n\n --this._length;\n delete this._values[key];\n }\n\n /**\n * Retrieves a value from the dictionary or returns undefined in case it's not found.\n * @param {Key} key The key to retrieve the value.\n * @returns {Value | undefined} The value stored in the dictionary or undefined in case it's not found.\n */\n public getValue(key: Key): Value | undefined {\n return this._values[key];\n }\n\n /**\n * Retrieves a value from the dictionary.\n * In case it's not found, adds the default value to the dictionary and returns it.\n * @param {Key} key The key to retrieve the value.\n * @param defaultValue\n * @returns {Value} The value stored in the dictionary or the default value in case it's not found.\n */\n public getValueWithDefaultValue(key: Key, defaultValue: Value): Value {\n if (!this.hasValue(key)) {\n this.setValue(key, defaultValue);\n }\n return this.getValue(key)!;\n }\n\n /**\n * Sets the value to the dictionary for the given key.\n * @remarks In case undefined was passed, removes the value from the dictionary instead.\n * @param {Key} key The key under which the value should be stored.\n * @param {Value} value The value which should be stored in the dictionary.\n */\n public setValue(key: Key, value: Value): void {\n if (value === undefined) {\n this.removeValue(key);\n return;\n }\n\n if (!this.hasValue(key)) {\n ++this._length;\n }\n\n this._values[key] = value;\n }\n\n /**\n * Checks if the dictionary stores some value (except undefined) for the given key.\n * @param {Key} key The key to retrieve the value.\n * @returns {boolean} True in case the value is present, false otherwise or if it's undefined.\n */\n public hasValue(key: Key): boolean {\n return this._values[key] !== undefined;\n }\n\n /**\n * Checks if the dictionary is empty.\n * @returns {boolean} True if the dictionary is empty, false otherwise.\n */\n public isEmpty(): boolean {\n return this.length === 0;\n }\n\n /**\n * Retrieves the number of values stored in the dictionary.\n * @remark Use `isEmpty` to check if the dictionary has any elements.\n * @returns {number} The number of values stored.\n */\n public get length(): number {\n return this._length;\n }\n\n /**\n * Clears the dictionary by removing all elements from the storage.\n */\n public clear(): void {\n this._values = {};\n this._length = 0;\n }\n\n /**\n * Returns all values stored in the dictionary.\n * @returns {Value[]} List of values.\n */\n public getValues(): Value[] {\n return this.getKeys().map(key => this._values[key]);\n }\n\n /**\n * Returns all keys stored in the dictionary.\n * @returns {string[]} List of keys.\n */\n public getKeys(): Key[] {\n return Object.keys(this._values);\n }\n\n /**\n * Returns all key value pairs stored in the dictionary.\n * @returns {IKeyValuePair[]} List of key value pairs.\n */\n public getKeyValuePairs(): IKeyValuePair[] {\n return this.getKeys().map(key => {\n return { key, value: this._values[key] };\n });\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IEventSubscriber } from './event-subscriber';\n\n/**\n * Represents a simple event with subscribers. Notifies the subscribers once the event is triggered.\n */\nexport class Event {\n /**\n * The list of subscribers.\n */\n private _subscribers: IEventSubscriber[];\n\n /**\n * Initializes the event with a empty subscribers list.\n */\n public constructor() {\n this._subscribers = [];\n }\n\n /**\n * Subscribes given instance to the event.\n * @param {IEventSubscriber} instance The info about the subscriber.\n */\n public subscribe(instance: IEventSubscriber): void {\n this._subscribers.push(instance);\n }\n\n /**\n * Removes the subscriber from the list of subscribers watching the event.\n * @param {string} instanceId The unique identifier of the subscriber which was earlier passed in `subscribe` method in `IEventSubscriber`.\n */\n public unsubscribe(instanceId: string): void {\n this._subscribers = this._subscribers.filter(element => element.instanceId !== instanceId);\n }\n\n /**\n * Clears the list of subscriber removing all instances watching the event.\n */\n public unsubscribeAll(): void {\n this._subscribers = [];\n }\n\n /**\n * Triggers the event.\n * Notifies the subscribers that the event is triggered by calling `handler` method.\n */\n public trigger(): void {\n this._subscribers.forEach(subscriber => {\n subscriber.handler();\n });\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IActionContext, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\n\nexport const getRnrPartnerId = (args: ICreateActionContext> | IActionContext): string => {\n return args.requestContext.apiSettings.rnr.id || '';\n};\n\nexport const getRnrEndpointId = (args: ICreateActionContext> | IActionContext): string => {\n return args.requestContext.apiSettings.rnr.url || '';\n};\n\nexport const getRnrAuthEndpointId = (args: ICreateActionContext> | IActionContext): string => {\n const endpoint = args.requestContext.apiSettings.rnr.proxyUrl\n ? args.requestContext.apiSettings.rnr.proxyUrl\n : args.requestContext.apiSettings.rnr.url || '';\n if (endpoint.length > 0 && endpoint.endsWith('/')) {\n return endpoint.substring(0, endpoint.length - 1);\n }\n return endpoint;\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport { ProductList, ProductListLine } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\n/**\n * OrderTemplateLine state information.\n */\nexport class OrderTemplateLine {\n public productListLine: ProductListLine;\n\n public fullProduct?: FullProduct;\n\n constructor(productListLine: ProductListLine, fullProduct?: FullProduct) {\n this.productListLine = productListLine;\n this.fullProduct = fullProduct;\n }\n}\n\nexport interface IOrderTemplateLinesState {\n lines: OrderTemplateLine[];\n totalCount: number;\n}\n\n/**\n * Order template class.\n */\nexport class OrderTemplate {\n public productList: ProductList;\n\n public orderTemplateLines: OrderTemplateLine[];\n\n public totalLines: number;\n\n constructor(productList: ProductList, orderTemplateLines: OrderTemplateLine[], totalLines: number) {\n this.productList = productList;\n this.orderTemplateLines = orderTemplateLines;\n this.totalLines = totalLines;\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n ProductAvailableQuantity,\n ProductDimensionValueInventoryAvailability,\n ProductInventoryAvailability\n} from '@msdyn365-commerce/retail-proxy';\n\n/**\n * This setting defines the delivery modes supported.\n */\nexport enum DeliveryMode {\n allWareHouses = 0,\n shipping = 1,\n pickup = 2\n}\n\n/**\n * This setting defines the inventory levels supported.\n */\nexport enum InventoryLevels {\n physicalAvailable = 'physicalAvailable',\n totalAvailable = 'totalAvailable',\n threshold = 'inventoryThreshold'\n}\n\n/**\n * Product inventory information class.\n */\nexport interface IProductInventoryInformation {\n ProductAvailableQuantity: ProductAvailableQuantity;\n StockLevelCode?: string;\n StockLevelLabel?: string;\n IsProductAvailable: boolean;\n InventLocationId?: string;\n deliveryType?: DeliveryMode;\n}\n\n/**\n * This setting defines the inventory level values return by the API.\n */\nexport enum InventoryLevelValues {\n outOfStock = 'OOS',\n available = 'AVAIL'\n}\n\n/**\n * Retrieves inventory level code from the dimension based on the app config setting.\n * @param dimensionValuesWithInventory - The dimension info.\n * @param inventoryLevel - App config setting for inventory level.\n * @returns Inventory level code value.\n */\nexport const getInventoryLevelCodeFromDimensionValue = (\n dimensionValuesWithInventory: ProductDimensionValueInventoryAvailability,\n inventoryLevel?: InventoryLevels | undefined\n): InventoryLevelValues | undefined => {\n if (inventoryLevel === InventoryLevels.totalAvailable) {\n return dimensionValuesWithInventory.TotalAvailableInventoryLevelCode as InventoryLevelValues | undefined;\n }\n if (inventoryLevel === InventoryLevels.physicalAvailable) {\n return dimensionValuesWithInventory.PhysicalAvailableInventoryLevelCode as InventoryLevelValues | undefined;\n }\n return undefined;\n};\n\n/**\n * Retrieves inventory level code from the product availability based on the app config setting.\n * @param productAvailability - The product availability info.\n * @param inventoryLevel - App config setting for inventory level.\n * @returns Inventory level code value.\n */\nexport const getInventoryLevelCodeFromProductAvailability = (\n productAvailability: ProductInventoryAvailability,\n inventoryLevel?: InventoryLevels | undefined\n): InventoryLevelValues | undefined => {\n if (inventoryLevel === InventoryLevels.totalAvailable) {\n return productAvailability.TotalAvailableInventoryLevelCode as InventoryLevelValues | undefined;\n }\n if (inventoryLevel === InventoryLevels.physicalAvailable) {\n return productAvailability.PhysicalAvailableInventoryLevelCode as InventoryLevelValues | undefined;\n }\n return undefined;\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IActionContext } from '@msdyn365-commerce/core';\nimport {\n InventoryAvailabilitySearchCriteria,\n ProductAvailableQuantity,\n ProductWarehouseInventoryAvailability,\n ProductWarehouseInventoryInformation,\n SearchArea\n} from '@msdyn365-commerce/retail-proxy';\n\nimport { DeliveryMode, InventoryLevels, InventoryLevelValues, IProductInventoryInformation } from './product-inventory-information';\n\n/**\n * The function defines whether the inventory label should be displayed or not.\n * @param context - The action context.\n * @param inventoryCode - The inventory code.\n * @returns Boolean.\n */\nexport function displayLabelEnabled(context: IActionContext, inventoryCode?: string): boolean {\n if (!inventoryCode) {\n return false;\n }\n\n // eslint-disable-next-line default-case\n switch (context.requestContext.app.config.inventoryRanges) {\n case 'lowAndOutofStock':\n if (inventoryCode !== InventoryLevelValues.available) {\n return true;\n }\n break;\n case 'outOfStock':\n if (inventoryCode === InventoryLevelValues.outOfStock) {\n return true;\n }\n break;\n case 'all':\n return true;\n }\n return false;\n}\n\n/**\n * The function that maps a ProductWareHouse object into a ProductAvailabilityQuantity.\n * @param context - The action context.\n * @param productsWarehouseInventory - The product warehouse inventory information.\n * @returns IProductInventoryInformation[].\n */\nexport function mapProductInventoryInformation(\n context: IActionContext,\n productsWarehouseInventory?: ProductWarehouseInventoryAvailability[]\n): IProductInventoryInformation[] {\n const productInventoryInformation: IProductInventoryInformation[] = [];\n\n if (context.requestContext.app.config.enableStockCheck === undefined || context.requestContext.app.config.enableStockCheck === false) {\n return productInventoryInformation;\n }\n\n if (productsWarehouseInventory && productsWarehouseInventory.length > 0) {\n for (const product of productsWarehouseInventory) {\n switch (context.requestContext.app.config.inventoryLevel) {\n case InventoryLevels.physicalAvailable:\n // Inventory level is enabled with Physical inventory\n const physicalProductMap = mapInventoryWithPhysicalBufferEnabled(context, product);\n if (physicalProductMap) {\n productInventoryInformation.push(physicalProductMap);\n }\n break;\n case InventoryLevels.totalAvailable:\n // Inventory level is enabled with Total available inventory\n const totalAvailableProductMap = mapInventoryWithTotalAvailableBufferEnabled(context, product);\n if (totalAvailableProductMap) {\n productInventoryInformation.push(totalAvailableProductMap);\n }\n break;\n default:\n // When inventory level is inventoryThreshold or not defined\n const productMap = mapInventoryWithThresholdEnabled(context, product);\n if (productMap) {\n productInventoryInformation.push(productMap);\n }\n break;\n }\n }\n }\n\n return productInventoryInformation;\n}\n\n/**\n * The function that maps inventory for when threshold is selected.\n * @param context - The action context.\n * @param productWarehouseInventoryAvailability - The product warehouse inventory information.\n * @returns IProductInventoryInformation.\n */\nexport function mapInventoryWithThresholdEnabled(\n context: IActionContext,\n productWarehouseInventoryAvailability: ProductWarehouseInventoryAvailability\n): IProductInventoryInformation | null {\n if (productWarehouseInventoryAvailability.ProductId && productWarehouseInventoryAvailability.TotalAvailable !== undefined) {\n const productQty = productWarehouseInventoryAvailability.TotalAvailable - context.requestContext.app.config.outOfStockThreshold;\n const productAvailableQuantity: ProductAvailableQuantity = {\n ProductId: productWarehouseInventoryAvailability.ProductId,\n AvailableQuantity: productQty > 0 ? productQty : 0\n };\n\n return {\n ProductAvailableQuantity: productAvailableQuantity,\n IsProductAvailable: !!(productAvailableQuantity.AvailableQuantity && productAvailableQuantity.AvailableQuantity > 0),\n InventLocationId: productWarehouseInventoryAvailability.InventLocationId\n };\n }\n\n return null;\n}\n\n/**\n * The function that maps inventory for when physical available is selected.\n * @param context - The action context.\n * @param productWarehouseInventoryAvailability - The product warehouse inventory information.\n * @returns IProductInventoryInformation.\n */\nexport function mapInventoryWithPhysicalBufferEnabled(\n context: IActionContext,\n productWarehouseInventoryAvailability: ProductWarehouseInventoryAvailability\n): IProductInventoryInformation | null {\n const shouldRenderLabel = displayLabelEnabled(context, productWarehouseInventoryAvailability.PhysicalAvailableInventoryLevelCode);\n\n if (productWarehouseInventoryAvailability.ProductId && productWarehouseInventoryAvailability.TotalAvailable !== undefined) {\n // As per the new buffer logic from RS,\n // if code is out of stock then we set the available quantity to 0 regardless of the actual value from API\n let productQuantity: number | undefined = 0;\n if (productWarehouseInventoryAvailability.PhysicalAvailableInventoryLevelCode !== InventoryLevelValues.outOfStock) {\n productQuantity =\n productWarehouseInventoryAvailability.MaximumPurchasablePhysicalAvailableQuantity ??\n productWarehouseInventoryAvailability.PhysicalAvailable;\n }\n\n const productAvailableQuantity: ProductAvailableQuantity = {\n ProductId: productWarehouseInventoryAvailability.ProductId,\n AvailableQuantity: productQuantity\n };\n return {\n ProductAvailableQuantity: productAvailableQuantity,\n StockLevelCode: shouldRenderLabel ? productWarehouseInventoryAvailability.PhysicalAvailableInventoryLevelCode : undefined,\n StockLevelLabel: shouldRenderLabel ? productWarehouseInventoryAvailability.PhysicalAvailableInventoryLevelLabel : undefined,\n IsProductAvailable: productAvailableQuantity.AvailableQuantity !== undefined && productAvailableQuantity.AvailableQuantity > 0,\n InventLocationId: productWarehouseInventoryAvailability.InventLocationId\n };\n }\n\n return null;\n}\n\n/**\n * The function that maps inventory for when total available is selected.\n * @param context - The action context.\n * @param productWarehouseInventoryAvailability - The product warehouse inventory information.\n * @returns IProductInventoryInformation.\n */\nexport function mapInventoryWithTotalAvailableBufferEnabled(\n context: IActionContext,\n productWarehouseInventoryAvailability: ProductWarehouseInventoryAvailability\n): IProductInventoryInformation | null {\n const shouldRenderLabel = displayLabelEnabled(context, productWarehouseInventoryAvailability.TotalAvailableInventoryLevelCode);\n if (productWarehouseInventoryAvailability.ProductId && productWarehouseInventoryAvailability.TotalAvailable !== undefined) {\n // As per the new buffer logic from RS,\n // if code is out of stock then we set the available quantity to 0 regardless of the actual value from API\n let productQuantity: number | undefined = 0;\n if (productWarehouseInventoryAvailability.TotalAvailableInventoryLevelCode !== InventoryLevelValues.outOfStock) {\n productQuantity =\n productWarehouseInventoryAvailability.MaximumPurchasableTotalAvailableQuantity ??\n productWarehouseInventoryAvailability.TotalAvailable;\n }\n\n const productAvailableQuantity: ProductAvailableQuantity = {\n ProductId: productWarehouseInventoryAvailability.ProductId,\n AvailableQuantity: productQuantity\n };\n return {\n ProductAvailableQuantity: productAvailableQuantity,\n StockLevelCode: shouldRenderLabel ? productWarehouseInventoryAvailability.TotalAvailableInventoryLevelCode : undefined,\n StockLevelLabel: shouldRenderLabel ? productWarehouseInventoryAvailability.TotalAvailableInventoryLevelLabel : undefined,\n // eslint-disable-next-line eqeqeq\n IsProductAvailable: productAvailableQuantity.AvailableQuantity != undefined && productAvailableQuantity.AvailableQuantity > 0,\n InventLocationId: productWarehouseInventoryAvailability.InventLocationId\n };\n }\n\n return null;\n}\n\n/**\n * The function created a InventoryAvailabilitySearchCriteria object for getEstimatedAvailability API.\n * @param context - The action context.\n * @returns Boolean.\n */\nexport function isAggregatedInventory(context: IActionContext): boolean {\n // If warehouse aggregated is true then query inventory from multiple warehouses\n // else query from single warehouse\n return (\n (context.requestContext.app.config.inventoryLevel === InventoryLevels.totalAvailable ||\n context.requestContext.app.config.inventoryLevel === InventoryLevels.physicalAvailable) &&\n context.requestContext.app.config.warehouseAggregation === 'multiple'\n );\n}\n\n/**\n * The function created a InventoryAvailabilitySearchCriteria object for getEstimatedAvailability API.\n * @param context - The action context.\n * @param productWarehouseInventoryInformation - The product ware house inventory information.\n * @returns ProductWarehouseInventoryInformation.\n */\nexport function mapAggregatedProductInventoryInformation(\n context: IActionContext,\n productWarehouseInventoryInformation: ProductWarehouseInventoryInformation\n): IProductInventoryInformation[] {\n if (isAggregatedInventory(context)) {\n const productInventoryMapping:\n | ProductWarehouseInventoryAvailability[]\n | undefined = productWarehouseInventoryInformation.AggregatedProductInventoryAvailabilities?.map(product => {\n return {\n DataAreaId: product.DataAreaId,\n MaximumPurchasablePhysicalAvailableQuantity:\n product.MaximumPurchasablePhysicalAvailableQuantity ?? product.PhysicalAvailableQuantity,\n MaximumPurchasableTotalAvailableQuantity:\n product.MaximumPurchasableTotalAvailableQuantity ?? product.TotalAvailableQuantity,\n ProductId: product.ProductId,\n PhysicalAvailable: product.PhysicalAvailableQuantity,\n PhysicalAvailableInventoryLevelCode: product.PhysicalAvailableInventoryLevelCode,\n PhysicalAvailableInventoryLevelLabel: product.PhysicalAvailableInventoryLevelLabel,\n TotalAvailable: product.TotalAvailableQuantity,\n TotalAvailableInventoryLevelCode: product.TotalAvailableInventoryLevelCode,\n TotalAvailableInventoryLevelLabel: product.TotalAvailableInventoryLevelLabel\n };\n });\n return mapProductInventoryInformation(context, productInventoryMapping);\n }\n\n return mapProductInventoryInformation(context, productWarehouseInventoryInformation.ProductWarehouseInventoryAvailabilities);\n}\n\n/**\n * The function created a InventoryAvailabilitySearchCriteria object for getEstimatedAvailability API.\n * @param context - The action context.\n * @param productIds - The product id collection.\n * @param isDefaultWareHouse - Flag to define whether inventory is from default warehouse or not.\n * @param isFilterByChannelFulfillmentGroup - Filter by fulfillment group.\n * @param searchArea - The search area.\n * @param defaultDeliveryMode - The delivery mode.\n * @returns InventoryAvailabilitySearchCriteria.\n */\nexport function createInventoryAvailabilitySearchCriteria(\n context: IActionContext,\n productIds: number[],\n isDefaultWareHouse?: boolean,\n isFilterByChannelFulfillmentGroup?: boolean,\n searchArea?: SearchArea,\n defaultDeliveryMode?: DeliveryMode\n): InventoryAvailabilitySearchCriteria {\n const salesUnitType = 2;\n const deliveryMode = defaultDeliveryMode ? defaultDeliveryMode : DeliveryMode.shipping;\n\n const inventoryAvailabilitySearchCriteria: InventoryAvailabilitySearchCriteria = {\n ProductIds: productIds,\n QuantityUnitTypeValue: salesUnitType,\n SearchArea: searchArea\n };\n\n if (isAggregatedInventory(context)) {\n inventoryAvailabilitySearchCriteria.FilterByChannelFulfillmentGroup = true;\n inventoryAvailabilitySearchCriteria.DeliveryModeTypeFilterValue = deliveryMode;\n } else {\n inventoryAvailabilitySearchCriteria.DefaultWarehouseOnly = isDefaultWareHouse;\n inventoryAvailabilitySearchCriteria.FilterByChannelFulfillmentGroup = isFilterByChannelFulfillmentGroup;\n }\n\n return inventoryAvailabilitySearchCriteria;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { PromiseBodyWrapper } from './base-promise-queue';\nimport { PromiseQueue } from './promise-queue';\n\nexport enum FinitePromiseQueueError {\n InvalidMaxQueueLengthPassed = 'Invalid maxQueueLength value passed to FinitePromiseQueue. maxQueueLength should be more or equal to 2.',\n ProcessWasDiscardedFromTheQueue = 'The process was discarded from FinitePromiseQueue.'\n}\n\n/**\n * Represents a FIFO queue over promises with a limited number of elements waiting for execution.\n * @remark\n * In case the queue reaches the limit,\n * before adding a new element the queue discards the oldest added element which is waiting to be processed.\n * Does not discard elements which are in progress under execution.\n * The discarded element will not be processed and executed.\n * @author Bohdan Yevchenko \n */\nexport class FinitePromiseQueue extends PromiseQueue {\n /**\n * @see constructor\n */\n private readonly _maxQueueLength: number;\n\n /**\n * Initializes the queue with the given limit.\n * @param {number} maxQueueLength\n * Defines the limit of maximum number of elements in the queue.\n * @remarks Includes both the number of elements waiting for the execution\n * and the element processed by the queue at the moment (in case there is some).\n * Value can't be less than 2.\n */\n public constructor(maxQueueLength: number) {\n if (maxQueueLength < 2) {\n throw new Error(FinitePromiseQueueError.InvalidMaxQueueLengthPassed);\n }\n\n super();\n this._maxQueueLength = maxQueueLength;\n }\n\n /**\n * Adds promise to the queue and automatically starts the queue execution.\n * @remarks In case the queue has reached the limit, also discards the oldest added element.\n * @param {PromiseBodyWrapper} promiseBody\n * The body of a function which contains a call to the promise which has to be executed in the queue.\n */\n public async enqueue(promiseBody: PromiseBodyWrapper): Promise {\n let totalElementsCount = this._queue.length;\n\n // If queue hasn't finished processing an element,\n // consider this element as pending.\n if (this._isBusy) {\n ++totalElementsCount;\n }\n\n // Discards the oldest added element from the queue to meet the given limitations.\n // The very first element in the queue is considered as oldest added.\n // Can't discard the element which is under execution as the promise can't be cancelled.\n if (totalElementsCount === this._maxQueueLength) {\n const element = this._queue.shift();\n if (element) {\n element.reject(FinitePromiseQueueError.ProcessWasDiscardedFromTheQueue);\n }\n }\n\n return super.enqueue(promiseBody);\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IPromiseQueue, PromiseBodyWrapper, PromiseRejectType, PromiseResolveType } from './base-promise-queue';\n\n/**\n * Represents an inner node which is stored in a promise queue.\n * Used internally in the PromiseQueue implementation.\n * @author Bohdan Yevchenko \n */\nclass PromiseQueueElement {\n /**\n * The body of a wrapper-function which contains a call to the promise which has to be executed in the queue.\n */\n public readonly body: PromiseBodyWrapper;\n\n /**\n * Method that resolves the promise after the promise from the body is resolved.\n */\n public readonly resolve: PromiseResolveType;\n\n /**\n * Method that rejects the promise after the promise from the body is rejected.\n */\n public readonly reject: PromiseRejectType;\n\n /**\n * Initializes queue element with the given data.\n * @param {PromiseBodyWrapper} body The body of a wrapper-function which contains a call to the promise which has to be executed in the queue.\n * @param {PromiseResolveType} resolve Method that resolves the promise after the promise from the body is resolved.\n * @param {PromiseRejectType} reject Method that rejects the promise after the promise from the body is rejected.\n */\n public constructor(\n body: PromiseBodyWrapper,\n resolve: PromiseResolveType,\n reject: PromiseRejectType\n ) {\n this.body = body;\n this.resolve = resolve;\n this.reject = reject;\n }\n}\n\n/**\n * Represents a FIFO basic queue over promises.\n * @author Bohdan Yevchenko \n */\nexport class PromiseQueue implements IPromiseQueue {\n /**\n * A list of promises waiting for execution.\n */\n protected readonly _queue: PromiseQueueElement[];\n\n /**\n * Defines whether the queue is processing some element.\n */\n protected _isBusy: boolean;\n\n /**\n * Defines whether the queue can start processing new element.\n */\n private get _canProcess(): boolean {\n return !this._isBusy && this._queue.length > 0;\n }\n\n /**\n * Creates a new instance of PromiseQueue.\n */\n public constructor() {\n this._queue = [];\n this._isBusy = false;\n }\n\n /**\n * Adds promise to the queue and automatically starts the queue execution.\n * @param {PromiseBodyWrapper} promiseBody\n * The body of a function which contains a call to the promise which has to be executed in the queue.\n */\n public async enqueue(promiseBody: PromiseBodyWrapper): Promise {\n return new Promise(async (resolve, reject) => {\n this._queue.push(new PromiseQueueElement(promiseBody, resolve, reject));\n await this._dequeue();\n });\n }\n\n /**\n * If the queue is free, starts processing the first element in the queue and waits until all the elements are processed.\n * Otherwise (if busy or has no elements to process), does nothing.\n */\n private async _dequeue(): Promise {\n // Skip if queue is not able to process any elements.\n if (!this._canProcess) {\n return;\n }\n\n // Lock queue to prevent parallel execution.\n this._isBusy = true;\n\n // Retrieve an element from the waiting queue and start processing.\n const element: PromiseQueueElement = this._queue.shift()!;\n await this._processElement(element);\n\n // Continue executing the subsequent queue elements.\n await this._processNext();\n }\n\n /**\n * Executes the given wrapper over the promise and calls initial resolve/reject correspondingly.\n * @param {PromiseQueueElement} element The queue element which should be processed now.\n */\n private async _processElement(element: PromiseQueueElement): Promise {\n try {\n await element\n .body()\n .then(element.resolve)\n .catch(element.reject);\n } catch (error) {\n element.reject(error);\n }\n }\n\n /**\n * Unlocks the queue and tries to process the next element in the queue.\n */\n private async _processNext(): Promise {\n this._isBusy = false;\n await this._dequeue();\n }\n}\n","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nvar getRandomValues;\nvar rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation. Also,\n // find the complete implementation of crypto (msCrypto) on IE11.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nvar byteToHex = [];\n\nfor (var i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).substr(1));\n}\n\nfunction stringify(arr) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import rng from './rng.js';\nimport stringify from './stringify.js';\n\nfunction v4(options, buf, offset) {\n options = options || {};\n var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (var i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return stringify(rnds);\n}\n\nexport default v4;","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { v4 as uuidv4 } from 'uuid';\n\n/**\n * Namespace which provides functionality for GUID.\n */\nexport namespace Guid {\n export function generateGuid(): string {\n return uuidv4();\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { Guid as _guid } from './guid';\n\nexport namespace Random {\n export import Guid = _guid;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/**\n * Regular expressions to validate emails.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport abstract class EmailRegex {\n /**\n * Represents a HTML5 Validation Regex.\n *\n * A valid email address is a string that matches the email production of the following ABNF, the character set for which is Unicode.\n * This ABNF implements the extensions described in RFC 1123.\n *\n * For more info: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address.\n */\n public static readonly html5EmailRegex = /^[a-zA-Z0-9.!#$%&'*+=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z])?)+$/;\n\n /**\n * Returns a default regex which should be used for most email validation cases.\n *\n * As of now, the default regex is HTML5 email regex standard.\n * @see EmailRegex.html5EmailRegex - The regex which is set to be default right now.\n *\n * @returns Regular expression for email validation.\n */\n public static get defaultRegex(): RegExp {\n return EmailRegex.html5EmailRegex;\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/**\n * Regular expressions to validate passwords.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport abstract class PasswordRegex {\n // eslint-disable-next-line max-len\n public static readonly defaultRegex = /^((?=.*[a-z])(?=.*[A-Z])(?=.*\\d)|(?=.*[a-z])(?=.*[A-Z])(?=.*[^A-Za-z0-9])|(?=.*[a-z])(?=.*\\d)(?=.*[^A-Za-z0-9])|(?=.*[A-Z])(?=.*\\d)(?=.*[^A-Za-z0-9]))([A-Za-z\\d@#$%^&*\\-_+=[\\]{}|\\\\:',?/`~'();!]|\\.(?!@)){8,16}$/;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/**\n * Regular expressions to validate phone number.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport abstract class PhoneRegex {\n public static readonly defaultRegex = '^$|^[- +()]*[0-9][- +()0-9]*$';\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IActionContext } from '@msdyn365-commerce/core';\nimport { CartLine } from '@msdyn365-commerce/retail-proxy';\nimport { SimpleProduct } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { ArrayExtensions } from './extensions/array-extensions';\nimport { IProductInventoryInformation } from './product-inventory-information';\n\n/**\n * Cart line inventory validation result interface.\n */\nexport interface ICartLineInventoryValidationResult {\n /**\n * Define whether the cart lines inventory is valid across multiple cart lines.\n */\n readonly isValid: boolean;\n\n /**\n * Defines the list of product id with invalid inventory.\n */\n readonly productIdWithErrors: number[];\n}\n\n/**\n * Validates inventory across cart lines.\n * @param cartLines - The cart lines.\n * @param productAvailabilities - The product availability collection.\n * @param actionContext - The action context.\n * @param products - The products.\n * @param emailDeliveryModeCode - The emailDeliveryModeCode.\n * @returns True if all product quantity are available, false otherwise.\n */\n// eslint-disable-next-line complexity -- existing code.\nexport function validateCartLinesInventory(\n cartLines: CartLine[],\n productAvailabilities: IProductInventoryInformation[],\n actionContext: IActionContext,\n products?: SimpleProduct[],\n emailDeliveryModeCode?: string | undefined\n): ICartLineInventoryValidationResult {\n const cartLineMap = new Map();\n const defaultCartLineQuantity = 1;\n if (!actionContext.requestContext.app.config.enableStockCheck) {\n return {\n isValid: true,\n productIdWithErrors: []\n };\n }\n const productIdWithErrors = [];\n let isValid = true;\n\n if (ArrayExtensions.hasElements(cartLines) && ArrayExtensions.hasElements(productAvailabilities)) {\n // Consolidate products in different cart lines into single entry with the total cart quantity\n for (const cartLine of cartLines) {\n // Skip validation if is an invoice inline.\n if (cartLine.ProductId && !cartLine.IsInvoiceLine && !cartLine.IsGiftCardLine) {\n if (!cartLineMap.has(cartLine.ProductId)) {\n cartLineMap.set(cartLine.ProductId, cartLine.Quantity ?? defaultCartLineQuantity);\n } else {\n const cartLineTotal = cartLineMap.get(cartLine.ProductId) ?? 0;\n cartLineMap.delete(cartLine.ProductId);\n cartLineMap.set(cartLine.ProductId, cartLineTotal + (cartLine.Quantity ?? defaultCartLineQuantity));\n }\n }\n }\n\n // Hashing product availability object by product ID.\n const productAvailabilityMap = new Map();\n for (const productAvailability of productAvailabilities) {\n if (\n productAvailability.ProductAvailableQuantity.ProductId &&\n !productAvailabilityMap.has(productAvailability.ProductAvailableQuantity.ProductId)\n ) {\n productAvailabilityMap.set(productAvailability.ProductAvailableQuantity.ProductId, productAvailability);\n }\n }\n\n // Compare total quantity with the available quantity from the inventory API, also validate that the product is available.\n for (const productId of Array.from(cartLineMap.keys())) {\n const cartLineQty = cartLineMap.get(productId) ?? defaultCartLineQuantity;\n const productAvailability = productAvailabilityMap.get(productId);\n const availableQuantity = productAvailability?.ProductAvailableQuantity.AvailableQuantity ?? undefined;\n\n // If product is non-stocked or cartLine is electronic delivery, then no inventory check\n const cartLine = cartLines.find(line => line.ProductId === productId);\n const cartLineProduct = products?.find(product => product.RecordId === productId);\n let isStockedItem = true;\n if (cartLineProduct) {\n isStockedItem = !!cartLineProduct.Behavior?.IsStockedProduct;\n }\n const isEmailDelivery =\n cartLine?.DeliveryMode && cartLine.DeliveryMode !== '' ? cartLine.DeliveryMode === emailDeliveryModeCode : false;\n const shouldSkipInventoryCheck = !isStockedItem || isEmailDelivery;\n\n // If product is non-stocked or cartLine is electronic delivery, then no inventory check\n if (shouldSkipInventoryCheck) {\n continue;\n }\n if (!productAvailability?.IsProductAvailable || (availableQuantity && cartLineQty > availableQuantity)) {\n productIdWithErrors.push(productId);\n isValid = false;\n }\n }\n }\n return {\n isValid,\n productIdWithErrors\n };\n}\n"],"names":["AddressManagementInput","constructor","address","userAccountNumber","getCacheKey","getCacheObjectType","dataCacheType","this","createAddressManagementInput","inputData","requestContext","user","isAuthenticated","Error","data","undefined","async","doAddressManagementOperation","input","ctx","operationHandler","customerInput","GetCustomerInput","apiSettings","customer","getCustomer","newCustomer","updatedCustomer","updateAsync","callerContext","update","createReadAsync","AccountNumber","Addresses","addAddressHandler","push","createObservableDataAction","id","action","isBatched","AddItemToProductListInput","productListId","productId","quantity","unitOfMeasure","context","productListLineToAdd","ProductListId","ProductId","Quantity","UnitOfMeasure","productListLine","ProductListsDataActions","ArrayExtensions","hasElements","telemetry","error","AddOrganizationUserInput","newUser","getCurrentAsync","then","businessPartner","BusinessPartnerId","createBusinessPartnerUserAsync","catch","debug","exception","requestUrl","baseUrl","cartId","requestOptions","headers","oun","token","Authorization","cartTenderLines","length","map","cartTenderLineItem","TokenizedPaymentCard","House","CardTokenInfo","billingAddress","Phone","ThreeLetterISORegionName","Street","City","State","ZipCode","Country","toUpperCase","Address1","Zip","requestBody","receiptEmail","cartVersion","sendCommerceRequest","response","status","CreateProductListInput","templateName","templateType","orderTemplate","Id","Name","ProductListTypeValue","createdProductList","deleteAddressHandler","filter","cur","RecordId","DeleteOrganizationUserInput","deleteAsync","console","log","EditOrganizationUserInput","updatedUser","GenericInput","cacheKey","result","cacheObjectType","getGenericAction","AddressInput","buildCacheKey","createGetAddressInput","getAddressAction","getAddressActionDataAction","GetAttributeDefinitionsInput","attributeDefinitionCriteria","getAttributeDefinitionsActionDataAction","channel","CustomerAttributeGroupId","getAttributeDefinitionsAsync","trace","AttributeGroupIdentifier","AttributesForSelectedVariantInput","channelId","selectedProduct","catalogId","getAttributesForSelectedVariantAction","Promise","resolve","activeProduct","selectedVariantInput","SelectedVariantInput","getSelectedVariantActionDataAction","productResult","getAttributeValuesAsync","queryResultSettings","QueryResultSettingsProxy","getPagingFromInputDataOrDefaultValue","attributeValues","message","getSelectedProductIdFromActionInput","getCatalogId","ProductAvailabilitiesForCartLineItems","getDeliveryMode","cartLine","featureSate","channelDeliveryOptionConfig","pickupDeliveryMode","DeliveryMode","PickupDeliveryModeCodes","find","deliveryMode","getAvailabilitiesForCartLineItems","shippingItems","bopisItems","productAvailabilities","cart","getCartState","channelConfiguration","getOrgUnitConfigurationAsync","products","getActiveCartProductsAction","ActiveCartProductsInput","featureState","getFeatureStateActionDataAction","FeatureStateInput","getFeatureState","retailMultiplePickUpOptionEnabled","item","IsEnabled","getChannelDeliveryOptionConfigurationAsync","PickupDeliveryModeCode","EmailDeliveryModeCode","CartLines","productIds","x","unique","searchCriteria","createInventoryAvailabilitySearchCriteria","shippingProductAvailabilities","getEstimatedAvailabilityAsync","bypassCache","ProductWarehouseInventoryAvailabilities","mapAggregatedProductInventoryInformation","productWarehouses","bopisItem","productWarehouse","InventLocationId","WarehouseId","InventLocationDataAreaId","DataAreaId","quantityUnitTypeSales","getProductWarehouseAvail","getEstimatedProductWarehouseAvailabilityAsync","productWarehouseMapping","mapProductInventoryInformation","getAvailabilitiesForCartLineItemsDataAction","CatalogsInput","customerAccountNumber","locale","Number","createCatalogsInput","getCatalogAction","CatalogsDataActions","getCatalogActionDataAction","CategoriesInput","mappedToHierarchy","maxItems","sitePath","_mappedToHierarchy","getLocale","mapCategoryToHierarchy","categoryList","categoryMap","reduce","memo","category","localName","nameTranslations","nameTranslation","Language","toLowerCase","Text","getFriendlyName","NameTranslations","categoryHierarchy","NeutralizedName","zeroCategory","Object","keys","forEach","element","parentId","ParentCategory","Url","getCategoryUrl","parent","Children","createCategoriesHierarchyInput","topItems","config","topCategories","parseInt","getCategoryHierarchyAction","categories","getCategoryAction","RawCategoriesInput","getCategoryHierarchyActionDataAction","CategoriesDataActions","GetCategoryPathsInput","categoryPathLooksups","constructedCacheKey","ChannelId","CatalogId","categoryPath","toString","createGetCategoryPathsInput","getCategoryPathsAction","categoryPathResults","getCategoryPathsAsync","CategoryPath","categoryUrl","getCategoriesUrlSync","slice","getCategoryPathsActionDataAction","GetChannelDeliveryConfigurationInput","accountNumber","GetCheckoutCartInput","CartCookieName","msdyn365Commerce","CartCookie","Cookie","activeCart","checkoutCart","copyAsync","Array","isArray","CurrentCategoryHierarchyInput","activeCategoryId","super","urlTokens","pageType","itemId","query","categoryId","activeCategoryParsedId","findCategoryHierarchy","innerCategoryHierarchy","getCurrentCategoryHierarchyAction","fullCategoryHierarchy","getCategoriesHierarchy","reverse","getCurrentCategoryHierarchyActionDataAction","CurrentCategoryInput","categorySlug","isNaN","recordId","tempActionContext","parameterizeFeatureFlags","getParameterizeFeatureFlags","parameterize","join","createGetCurrentCategoryInput","searchCategory","foundCategory","cat","Slug","matchingChild","getCurrentCategoryAction","categoryInput","getCategoryHierarchy","getCurrentCategoryActionDataAction","GetCustomerBalanceInput","createGetCustomerBalanceInput","getCustomerBalanceAction","getCustomerBalanceAsync","InvoiceAccount","getCustomerBalanceActionDataAction","retailAction","createGetCustomerLoyaltyCardsInput","ProductDeliveryOptionsForCartLineItems","getDeliveryOptionsForCartLineItems","ProductsDataActions","getDeliveryOptionsForCartLineItemsDataAction","GetDeliveryOptionsForSelectedVariantInput","customerId","createDeliveryOptionsForSelectedVariantInput","getDeliveryOptionsForSelectedVariantAction","getSelectedVariant","getDeliveryOptionsAsync","ItemTypeValue","ReleasedProductType","Service","FilterDeliveryModeOption","FilterOutNonPickupDeliveryMode","getDeliveryOptionsForSelectedVariantActionDataAction","DimensionAvailabilitiesForProductSearchResultInput","dimensionContext","displayType","product","productsDimensionInputs","inventoryLevel","app","filteredProductAttributes","AttributeValues","attributeValue","checkIfShouldDisplayAsSwatch","toLocaleLowerCase","productionDimensionType","ProductDimensionType","ProductsDimensionAvailabilitiesInput","MasterProductId","dimensionForProducts","getDimensionAvailabilitiesForProductsAction","productsDimensionAvailabilities","dimensionInput","index","dimensionValuesWithInventory","inventoryLevelCode","getInventoryLevelCodeFromDimensionValue","value","DimensionValue","Value","isDisabled","InventoryLevelValues","outOfStock","masterProductId","warning","requestDimensionType","inputs","promise","shippingInventoryConfiguration","RequestedDimensionTypeValue","MatchingDimensionValues","DefaultWarehouseOnly","FilterByChannelFulfillmentGroup","DeliveryModeTypeFilterValue","all","productsDimensions","productDimension","GetDimensionsForSelectedVariantInput","matchingDimensionValues","getDimensionsForSelectedVariantAction","activeProducts","validValues","Dimensions","promises","dimension","DimensionTypeValue","dimensionValues","dimensionValuesResults","newDimension","oldDimension","DimensionValues","getDimensionsForSelectedVariantActionDataAction","getDimensionValuesFromQuery","url","featureNames","createGetFeatureStateInput","getFeatureStateAction","StoreOperationsDataActions","GetFullAvailableInventoryNearbyInput","_productId","_latitude","_longitude","_radius","_DistanceUnitValue","_IgnoreLocation","latitude","longitude","radius","DistanceUnitValue","IgnoreLocation","createGetFullAvailableInventoryNearbyInput","getFullAvailableInventoryNearbyAction","searchArea","Latitude","Longitude","Radius","retailMulitplePickupMFeatureState","pickup","productInventoryInformation","productWarehouseInformation","getOrgUnitLocationsByAreaAsync","DeliveryModeTypeFilter","Pickup","storeMap","Map","stores","store","InventoryLocationId","set","locationDeliveryOptions","orgUnitChannel","channelCollection","channelIdList","getChannelDeliveryOptionsAsync","channelDeliveryOptions","_getLocationPickUpDeliveryModes","availabilityPromiseList","locationDeliveryOption","_channeldeliveryoption","orgUnitLocation","channelDeleiveryOptions","OrgUnitNumber","OrgUnitAvailability","getStoreHoursAsync","hours","itemAvailabilities","has","AvailableQuantity","ProductAvailableQuantity","availability","OrgUnitLocation","ItemAvailabilities","ProductInventoryInformation","OrgUnitPickUpDeliveryModes","StoreHours","_getAvailabilityWithHours","getFullAvailableInventoryNearbyActionDataAction","QuickOrderTemplate","productList","quickOrderTemplateLines","totalLines","GetFullProductListInput","inputParameters","GetProductListInput","getProductList","productLists","inputLines","GetProductListLinesInput","getProductListLines","linesState","lines","totalCount","FullProductsRefineSearchByCategoryInput","queryResultSettingsProxy","refinementCriteria","criteria","ProductDetailsCriteria","hasSortingColumn","QueryResultSettings","Sorting","Columns","fullProductInputs","refineSearchByCategoryAsync","searchResults","FullProductInput","productSearchResult","getFullProducts","fromInputData","productDetailsCriteria","getProductDetailsCriteriaFromActionInput","FullProductsRefineSearchByTextInput","searchText","getRefinedProducts","getRefinedFullProducts","refineSearchByTextAsync","searchInputData","parseSearchData","q","getPrice","getRating","generateKey","getFullProductsAction","productInputs","ProductInput","getSimpleProducts","ProductDetails","productCollection","validProductIds","Set","ratingsAndPricePromises","_getActivePrices","_getProductRatings","projectDomain","validInputs","Boolean","affiliations","getCartFromCustomer","AffiliationLines","getActivePricesAsync","Date","productPrice","fullProduct","versionLt","retailServerProxyVersion","CustomerContextualPrice","AdjustedPrice","ProductPrice","getProductRatingsAsync","productRating","ProductRating","split","ActiveWishlistInput","getActiveWishlistItems","wishlists","getByCustomerAsync","CommerceListLines","commerceListLine","ListItemType","ListInput","documentId","title","description","shortDescription","backgroundColor","foregroundColor","images","items","productItems","itemsCount","itemsPerPage","skipCount","shouldCacheOutput","DocumentId","ItemsCount","ItemsPerPage","SkipCount","Title","Description","ShortDescription","BackgroundColor","ForegroundColor","Images","Items","ProductItems","getImages","resultImageList","image","href","imageItem","altText","width","height","getSubListItem","sitePathOfRequest","imageList","fields","content","sublistHref","listName","_name","Href","getSitePath","inputArray","GetProducts","productMap","listitem","listData","pageData","list","_id","getInutListData","listItems","parentImageList","getItemsPerPage","getSkipCount","sum","type","clonedList","productItem","GetLoyaltyCardInput","createGetLoyaltyCardInput","getLoyaltyAction","getCustomerLoyaltyCardsAsync","cards","firstCard","getLoyaltyCardAsync","CardNumber","card","LoyaltyEnrollmentDate","LoyaltyEnrollmentDateLocal","getLoyaltyActionDataAction","GetLoyaltyTransactionEstimationInput","createGetLoyaltyTransactionEstimationInput","getLoyaltyTransactionEstimationAction","_getCart","_getLoyalty","_getOrgUnits","getMaxLoyaltyPointsToRedeemForTransactionBalanceAsync","Currency","points","loyaltyCardInput","getLoyalty","getLoyaltyTransactionEstimationActionDataAction","MediaLocationsByIdInput","createMediaLocationsByIdInput","getMediaLocationsByIdAction","getMediaLocationsAsync","mediaLocation","Uri","generateImageUrl","AltText","getMediaLocationsByIdActionDataAction","MediaLocationsForSelectedVariantInput","createMediaLocationsForSelectedVariantInput","getMediaLocationsForSelectedVariantAction","AsyncResult","productVariant","getMediaLocationsForSelectedVariantActionDataAction","createGetOrderShipmentsHistoryInput","Paging","Top","Skip","createGetOrgUnitConfigurationInput","OrganizationUsersCountInput","createGetOrganizationUsersCountInput","getOrganizationUsersCount","getUsersAsync","users","OrganizationUsersInput","createGetOrganizationUsersInput","getOrganizationUsers","getOrganizationUsersDataAction","GetOrganizationWideOrderHistoryInput","convertToString","getOrderHistoryAsync","ProductPickUpOptionsForCartLineItems","getPickUpOptionsForCartLineItems","getPickUpOptionsForCartLineItemsDataAction","PriceForProductSearchResultInput","JSON","stringify","getPriceForProductSearchResultDataAction","productRecIds","affiliation","productPrices","productResults","activePrice","price","Price","BasePrice","Math","max","TradeAgreementPrice","PriceForSelectedVariantInput","createActivePriceForSelectedVariantInput","getPriceForSelectedVariantAction","featureStates","ProductTypeValue","ProductType","Master","KitMaster","getPriceForSelectedVariantActionDataAction","ProductAvailabilitiesForSelectedVariantInput","createProductAvailabilitiesForSelectedVariantInput","getProductAvailabilitiesForSelectedVariantAction","enableStockCheck","shippingSearchCriteria","shipping","pickupSearchCriteria","shippingAvailability","shippingInventory","deliveryType","pickupAvailability","pickupInventory","mergeProductWarehouseToProductAvailabities","productsWarehouseInventory","productAvailable","TotalAvailable","getProductAvailabilitiesForSelectedVariantActionDataAction","ProductDimensionsWithAvailabilitiesInput","createProductDimensionsWithAvailabilitiesInput","getProductDimensionsWithAvailabilitiesAction","getProductDimensionsWithAvailabilities","QuickOrderTemplateLine","quickOrderTemplateLinesState","productListLines","metadata","count","listLine","fullProductsInfo","line","productListSearchCriteria","ProductListType","QuickOrder","ProductsByCategoryInput","cacheKeyHint","currentCategory","getCurrentCategory","searchByCategoryAsync","productSearchResults","getProducts","cartState","defaultOrderQuantityLimitsFeatureConfig","platform","enableDefaultOrderQuantityLimits","isQuantityLimitsFeatureEnabledInHq","customerInfo","IsB2b","isOrderQuantityLimitsFeatureEnabled","productIdsByWarehouseId","resultProducts","get","entryWarehouseId","entryProductIds","accum","getActiveCartProductsActionWhenQuantityLimitsFeatureIsOn","hasInvoiceLine","getActiveCartProductsActionDataAction","PromotionOptionsForCartLineItems","cartLineIds","c","LineId","getAvailablePromotionsAsync","GetRatingsSummaryInput","tenantId","serviceEndpoint","createInput","getRnrPartnerId","getRnrEndpointId","getRatingsSummary","inputIsValid","sendRequest","getRatingsSummaryDataAction","RefinersByCategoryInput","getRefinersByCategoryAsync","RefinersByTextInput","getRefinersByTextAsync","GetRelatedProductsInput","relationType","querySettings","productRelationTypes","getRelationTypesAsync","productRelationTypeId","_productRelationType","foundProductRelationTypeId","productRelationType","searchProductRelationType","getRelatedProductsAsync","stack","GetScanResultInput","sku","skuNumber","readAsync","scanResults","Product","getDimensionsForSelectedVariant","ScanResult","ProductDimensionFull","SearchConfigurationInput","getSearchConfigurationAsync","hasUnmatchedDimension","matchedTargetDimension","targetDimension","checkIfHasUnmatchedDimensions","newImageUrl","generateProductImageUrl","PrimaryImageUrl","fullDimensions","fullDimensionPromises","getFullDimensions","ProductIds","variantProductId","variantImageUrl","getProductVariant","matchedTargetDimensionFromApi","warehouseId","getSimpleProductsAction","productIdMapping","getProductPromises","catalogIds","getByIdsAsync","mappedProducts","flatten","GetOrgUnitLocationsByAreaInput","_Latitude","_Longitude","_Radius","createGetOrgUnitLocationsByAreaInput","getOrgUnitLocationsByArea","locationPromiseList","_getLocationWithHours","getOrgUnitLocationsByAreaDataAction","retailActionDataAction","createGetByCustomerInput","GetInvoiceDetailsInput","invoiceId","CreateGetInvoiceDetailsInput","getInvoiceDetails","InvoiceId","SalesOrdersDataActions","getInvoiceDetailsDataAction","GetInvoicesInput","CreateGetInvoicesInput","InvoicePaidStatusValues","InvoicePaidStatus","None","getInvoices","InvoiceTypeValues","InvoiceType","SalesOrderInvoice","CustomerId","getInvoicesDataAction","IssueLoyaltyInput","updateCart","updateLoyaltyCardId","loyaltyCardNumber","issueLoyaltyCardAsync","CustomerAccount","issuedCard","AddItemToOrderTemplateInput","orderTemplateId","addProductListLinesAsync","AddOrderTemplateToCartInput","chunkCount","getPaginatedOrderTemplateLinesInput","GetPaginatedOrderTemplateLinesInput","orderTemplateLines","getPaginatedOrderTemplateLinesAction","addedCartLines","skip","cartLines","productLine","ItemId","TrackingId","UnitOfMeasureSymbol","addCartLinesAsync","Version","ValidationResults","concat","refreshCart","CreateOrderTemplateInput","OrderTemplate","createProductListAsync","GetFullOrderTemplateInput","inputParams","GetOrderTemplatesInput","getOrderTemplates","GetFullOrderTemplatesInput","getPrices","getRatings","orderTemplates","inputLinesRequests","inputLinesResponses","productLinesResponse","GetOrderTemplatesPreviewInput","createGetOrderTemplatesPreviewInput","getOrderTemplatesPreview","getFullOrderTemplates","getOrderTemplatesPreviewDataAction","createGetOrderTemplatesInput","getOrderTemplatesAction","searchAsync","orderTemplateLinesState","getProductListLinesAsync","OrderTemplateLine","UpdateOrderTemplateHeaderInput","updatedProductList","UpdateOrderTemplateInput","getLinesInput","getPaginatedOrderTemplateLines","linesToUpdate","lineToUpdate","updatedLines","updateProductListLinesAsync","updatedLine","createRefineSearchByCategoryInput","refinementCriterion","search","querySettingsProxy","createSearchByTextInput","updateAddressHandler","IsPrimary","updateCustomerAttributesInput","customerAttributes","phone","vatNumber","VatNumber","Attributes","updateCustomerPersonalizationInput","isOptOut","preferenceType","OptOutWebActivityTracking","OptOutPersonalization","setPrimaryAddress","primaryAddresses","addresses","addr","name","sep","neutralizedName","candidateName","platformSettings","enableUrlLocalization","enableUrlEncoding","encodeURIComponent","replace","trim","getCategorySlug","categoryName","getUrlSync","getInvoiceDetailsPageUrlSync","includes","substr","indexOf","getProductUrlSync","getProductPageUrlSync","Dictionary","_values","_length","entries","keyValuePair","setValue","key","removeValue","hasValue","getValue","getValueWithDefaultValue","defaultValue","isEmpty","clear","getValues","getKeys","getKeyValuePairs","Event","_subscribers","subscribe","instance","unsubscribe","instanceId","unsubscribeAll","trigger","subscriber","handler","args","rnr","getRnrAuthEndpointId","endpoint","proxyUrl","endsWith","substring","InventoryLevels","totalAvailable","TotalAvailableInventoryLevelCode","physicalAvailable","PhysicalAvailableInventoryLevelCode","getInventoryLevelCodeFromProductAvailability","productAvailability","displayLabelEnabled","inventoryCode","inventoryRanges","available","physicalProductMap","mapInventoryWithPhysicalBufferEnabled","totalAvailableProductMap","mapInventoryWithTotalAvailableBufferEnabled","mapInventoryWithThresholdEnabled","productWarehouseInventoryAvailability","productQty","outOfStockThreshold","productAvailableQuantity","IsProductAvailable","shouldRenderLabel","productQuantity","MaximumPurchasablePhysicalAvailableQuantity","PhysicalAvailable","StockLevelCode","StockLevelLabel","PhysicalAvailableInventoryLevelLabel","MaximumPurchasableTotalAvailableQuantity","TotalAvailableInventoryLevelLabel","isAggregatedInventory","warehouseAggregation","productWarehouseInventoryInformation","AggregatedProductInventoryAvailabilities","PhysicalAvailableQuantity","TotalAvailableQuantity","isDefaultWareHouse","isFilterByChannelFulfillmentGroup","defaultDeliveryMode","inventoryAvailabilitySearchCriteria","QuantityUnitTypeValue","SearchArea","FinitePromiseQueueError","FinitePromiseQueue","PromiseQueue","maxQueueLength","InvalidMaxQueueLengthPassed","_maxQueueLength","promiseBody","totalElementsCount","_queue","_isBusy","shift","reject","ProcessWasDiscardedFromTheQueue","enqueue","PromiseQueueElement","body","_dequeue","_canProcess","_processElement","_processNext","getRandomValues","rnds8","Uint8Array","rng","crypto","bind","msCrypto","uuid","REGEX","test","byteToHex","i","arr","offset","arguments","validate","TypeError","options","buf","rnds","random","Guid","Random","uuidv4","_guid","EmailRegex","html5EmailRegex","PasswordRegex","PhoneRegex","validateCartLinesInventory","actionContext","emailDeliveryModeCode","cartLineMap","isValid","productIdWithErrors","IsInvoiceLine","IsGiftCardLine","cartLineTotal","delete","productAvailabilityMap","from","cartLineQty","availableQuantity","cartLineProduct","isStockedItem","Behavior","IsStockedProduct","isEmailDelivery"],"sourceRoot":""}