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MAAMqjB,KAAuB50B,EAE1B40B,EAAoB7hB,yBAAyBlZ,YAC5CskC,EAAuBtrB,IAAI+hB,EAAoB7hB,yBAAyBlZ,YACzEskC,EAAuBxsB,IAAIijB,EAAoB7hB,yBAAyBlZ,UAAW+6B,GAK3F,IAAK,MAAMr7B,KAAaoO,MAAMirB,KAAKgL,EAAYh5B,QAAS,CAAC,IAAD,IACpD,MAAMw5B,EAAW,UAAGR,EAAY7Z,IAAIxqB,UAAnB,QAtCO,EAuClBq7B,EAAsBuJ,EAAuBpa,IAAIxqB,GACjD8kC,EAAiB,UAAGzJ,MAAAA,OAAH,EAAGA,EAAqB7hB,yBAAyBD,yBAAjD,aAAsElb,EAGvFyH,EAAW8rB,EAAUxrB,MAAKgjB,GAAQA,EAAK9oB,YAAcN,IACrD+kC,EAAkBj+B,MAAAA,OAAH,EAAGA,EAAUV,MAAKwM,GAAWA,EAAQzO,WAAanE,IACvE,IAAIglC,GAAgB,EACE,IAAD,EAArB,GAAID,EACAC,IAAiB,UAACD,EAAgBE,gBAAjB,QAAC,EAA0BC,kBAEhD,MAAMC,IAAmBr/B,MAAAA,IAAAA,EAAUI,cAA0C,KAA1BJ,EAASI,eAAuBJ,EAASI,eAAiBk+B,GAC3EY,GAAiBG,IAM9C9J,MAAAA,IAAAA,EAAqBa,oBAAuB4I,GAAqBD,EAAcC,KAChFP,EAAoB9kC,KAAKO,GACzBskC,GAAU,IAItB,MAAO,CACHA,QAAAA,EACAC,oBAAAA,K","sources":["webpack://mattressfirm/../../src/add-address.ts?fb17","webpack://mattressfirm/../../src/add-item-to-product-list.ts?580e","webpack://mattressfirm/../../src/add-organization-user.ts?ed86","webpack://mattressfirm/../../src/checkout.ts?57e0","webpack://mattressfirm/../../src/create-product-list.ts?7367","webpack://mattressfirm/../../src/delete-address.ts?f9a3","webpack://mattressfirm/../../src/delete-organization-user.ts?7f5d","webpack://mattressfirm/../../src/edit-organization-user.ts?d2ac","webpack://mattressfirm/../../src/generic-data-action.ts?f887","webpack://mattressfirm/../../src/get-address.ts?20a3","webpack://mattressfirm/../../src/get-attribute-definitions.ts?cc6b","webpack://mattressfirm/../../src/get-availabilities-cartlines.ts?b8e8","webpack://mattressfirm/../../src/get-catalogs.ts?7332","webpack://mattressfirm/../../src/get-categories-hierarchy.ts?acde","webpack://mattressfirm/../../src/get-categories.ts?8dc6","webpack://mattressfirm/../../src/get-category-paths.ts?b007","webpack://mattressfirm/../../src/get-channel-delivery-option-configuration.ts?a716","webpack://mattressfirm/../../src/get-checkout-cart.ts?79bc","webpack://mattressfirm/../../src/get-current-category-hierarchy.ts?d48e","webpack://mattressfirm/../../src/get-current-category.ts?354d","webpack://mattressfirm/../../src/get-customer-balance.ts?d165","webpack://mattressfirm/../../src/get-customer-loyalty-cards.ts?2466","webpack://mattressfirm/../../src/get-customer.ts?8319","webpack://mattressfirm/../../src/get-delivery-options-for-cartlines.ts?4dfe","webpack://mattressfirm/../../src/get-delivery-options-for-selected-variant.ts?3f6c","webpack://mattressfirm/../../src/get-dimension-availabilities-for-product-search-result.ts?5259","webpack://mattressfirm/../../src/get-dimension-availabilities-for-products.ts?f656","webpack://mattressfirm/../../src/get-dimensions-for-selected-variant.ts?6bf4","webpack://mattressfirm/../../src/get-feature-state.ts?1a1d","webpack://mattressfirm/../../src/get-full-available-inventory-nearby.ts?20be","webpack://mattressfirm/../../../src/utilities/quick-order-templates.ts?0ea6","webpack://mattressfirm/../../src/get-full-product-list.ts?ccfb","webpack://mattressfirm/../../src/get-full-products-by-refine-search-category.ts?30ab","webpack://mattressfirm/../../src/get-full-products-by-refine-search-text.ts?2ad7","webpack://mattressfirm/../../../src/utilities/refiner-utils.ts?1e61","webpack://mattressfirm/../../src/get-full-products.ts?ba9a","webpack://mattressfirm/../../src/get-items-in-wishlist.ts?0d27","webpack://mattressfirm/../../src/get-list.ts?4fd5","webpack://mattressfirm/../../src/get-loyalty-card.ts?7213","webpack://mattressfirm/../../src/get-loyalty-transaction-estimation.ts?e254","webpack://mattressfirm/../../src/get-media-locations-by-id.ts?8462","webpack://mattressfirm/../../src/get-media-locations-for-selected-variant.ts?fd54","webpack://mattressfirm/../../src/get-order-history.ts?76fd","webpack://mattressfirm/../../src/get-org-unit-configuration.ts?4793","webpack://mattressfirm/../../src/get-organization-users-count.ts?b5f7","webpack://mattressfirm/../../src/get-organization-users.ts?b72e","webpack://mattressfirm/../../src/get-organization-wide-order-history.ts?92b8","webpack://mattressfirm/../../src/get-pickup-options-for-cartlines.ts?843b","webpack://mattressfirm/../../src/get-price-for-product-search-result.ts?36f8","webpack://mattressfirm/../../src/get-price-for-selected-variant.ts?9e79","webpack://mattressfirm/../../src/get-product-availabilities-for-selected-variant.ts?0abd","webpack://mattressfirm/../../src/get-product-dimensions-with-availabilities.ts?347b","webpack://mattressfirm/../../../src/utilities/quick-order-template-line.ts?56d5","webpack://mattressfirm/../../src/get-product-list-lines.ts?ae74","webpack://mattressfirm/../../src/get-product-list.ts?ef13","webpack://mattressfirm/../../src/get-products-by-category.ts?accf","webpack://mattressfirm/../../src/get-products-in-active-cart.ts?3376","webpack://mattressfirm/../../src/get-promotion-options-for-cartlines.ts?1a35","webpack://mattressfirm/../../src/get-ratings-summary-input.ts?3ccb","webpack://mattressfirm/../../src/get-ratings-summary.ts?49bc","webpack://mattressfirm/../../src/get-refiners-by-category.ts?6d4e","webpack://mattressfirm/../../src/get-refiners-by-text.ts?c52a","webpack://mattressfirm/../../src/get-related-products.ts?6f93","webpack://mattressfirm/../../src/get-scan-results.ts?6b44","webpack://mattressfirm/../../src/get-search-configuration.ts?acd1","webpack://mattressfirm/../../src/get-selected-variant.ts?f0c0","webpack://mattressfirm/../../src/get-simple-products.ts?fed7","webpack://mattressfirm/../../src/get-store-location-information.ts?1df0","webpack://mattressfirm/../../src/get-wishlist-by-customer-id.ts?e873","webpack://mattressfirm/../../../src/invoices/get-invoice-details.ts?66a9","webpack://mattressfirm/../../../src/invoices/get-invoices.ts?22cb","webpack://mattressfirm/../../src/issue-loyalty.ts?f8fa","webpack://mattressfirm/../../../src/order-templates/add-item-to-order-template.ts?fff3","webpack://mattressfirm/../../../src/order-templates/add-order-template-to-cart.ts?6ee4","webpack://mattressfirm/../../../src/order-templates/create-order-template.ts?03c1","webpack://mattressfirm/../../../src/order-templates/get-full-order-template.ts?72c6","webpack://mattressfirm/../../../src/order-templates/get-full-order-templates.ts?b553","webpack://mattressfirm/../../../src/order-templates/get-order-templates-preview.ts?b8c3","webpack://mattressfirm/../../../src/order-templates/get-order-templates.ts?a3b1","webpack://mattressfirm/../../../src/order-templates/get-paginated-order-template-lines.ts?9b12","webpack://mattressfirm/../../../src/order-templates/update-order-template-header.ts?1f77","webpack://mattressfirm/../../../src/order-templates/update-order-template-line.ts?527b","webpack://mattressfirm/../../src/refine-search-by-category.ts?3e65","webpack://mattressfirm/../../src/search-by-text.ts?ebe1","webpack://mattressfirm/../../src/update-address.ts?3e4d","webpack://mattressfirm/../../src/update-customer-attributes.ts?8d49","webpack://mattressfirm/../../src/update-customer-personalization.ts?4aa9","webpack://mattressfirm/../../src/update-primary-address.ts?83fa","webpack://mattressfirm/../../../src/utilities/QueryResultSettingsProxy.ts?5e44","webpack://mattressfirm/../../../../src/utilities/Url-builder/parameterize.ts?f5a5","webpack://mattressfirm/../../../../src/utilities/Url-builder/category-url-builder.ts?e564","webpack://mattressfirm/../../../../src/utilities/Url-builder/invoice-url-builder.ts?d542","webpack://mattressfirm/../../../../src/utilities/Url-builder/product-url-builder.ts?baf1","webpack://mattressfirm/../../../../src/utilities/data-structures/dictionary.ts?bab3","webpack://mattressfirm/../../../../src/utilities/events/event.ts?15a9","webpack://mattressfirm/../../../../src/utilities/extensions/array-extensions.ts?1a2a","webpack://mattressfirm/../../../../src/utilities/extensions/enum-extensions.ts?cf51","webpack://mattressfirm/../../../../src/utilities/extensions/string-extensions.ts?ab9f","webpack://mattressfirm/../../../../src/utilities/extensions/object-extensions.ts?6388","webpack://mattressfirm/../../../src/utilities/getRnrKeys.ts?700f","webpack://mattressfirm/../../../src/utilities/input-data-parser.ts?027a","webpack://mattressfirm/../../../src/utilities/order-templates.ts?d593","webpack://mattressfirm/../../../src/utilities/product-inventory-information.ts?0ec6","webpack://mattressfirm/../../../src/utilities/product-inventory-utils.ts?58b5","webpack://mattressfirm/../../../../src/utilities/promise-queue/finite-promise-queue.ts?77bf","webpack://mattressfirm/../../../../src/utilities/promise-queue/promise-queue.ts?e362","webpack://mattressfirm/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/rng.js?b47d","webpack://mattressfirm/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/regex.js?08ba","webpack://mattressfirm/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/validate.js?acea","webpack://mattressfirm/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/stringify.js?6cb1","webpack://mattressfirm/./node_modules/@msdyn365-commerce-modules/retail-actions/node_modules/uuid/dist/esm-browser/v4.js?0101","webpack://mattressfirm/../../../../src/utilities/random/guid.ts?1947","webpack://mattressfirm/../../../../src/utilities/random/index.ts?1f9d","webpack://mattressfirm/../../../../src/utilities/regex/email-regex.ts?6a6a","webpack://mattressfirm/../../../../src/utilities/regex/password-regex.ts?456d","webpack://mattressfirm/../../../../src/utilities/regex/phone-regex.ts?9ada","webpack://mattressfirm/../../../src/utilities/utils.ts?fbc0","webpack://mattressfirm/../../../src/utilities/validate-cartlines-inventory.ts?8b82"],"sourcesContent":["/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport {\n CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny,\n ICreateActionContext, IGeneric\n} from '@msdyn365-commerce/core';\nimport { Address, Customer } from '@msdyn365-commerce/retail-proxy';\nimport {\n createReadAsync, updateAsync\n} 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } 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, productListId: string, productId: number, quantity: number, unitOfMeasure: string): AddItemToProductListInput => {\n\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 callerContext: context\n }, input.productListId, [productListLineToAdd]);\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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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 = (inputData: ICreateActionContext>, newUser: BusinessPartnerUser): 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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt 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 = (inputData: ICreateActionContext, templateName: string, templateType: number): 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 callerContext: context\n }, orderTemplate);\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\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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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 = (inputData: ICreateActionContext>, newUser: BusinessPartnerUser): 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)\n .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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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 = (inputData: ICreateActionContext>, newUser: BusinessPartnerUser): 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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICommerceApiSettings, ICreateActionContext } 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport {\n getAttributeDefinitionsAsync\n} 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. All rights reserved.\n * See License.txt 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 = (cartLine: CartLine, featureSate: boolean = false, channelDeliveryOptionConfig: ChannelDeliveryOptionConfiguration, pickupDeliveryMode?: string) => {\n if (!featureSate) {\n return cartLine.DeliveryMode === pickupDeliveryMode;\n }\n return cartLine.DeliveryMode === 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 */\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 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 (cartLine.DeliveryMode && cartLine.DeliveryMode !== '' && getDeliveryMode(cartLine, retailMultiplePickUpOptionEnabled, channelDeliveryOptionConfig, PickupDeliveryModeCode)) {\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 (shippingProductAvailabilities &&\n shippingProductAvailabilities.ProductWarehouseInventoryAvailabilities &&\n shippingProductAvailabilities.ProductWarehouseInventoryAvailabilities.length > 0) {\n\n productAvailabilities = mapAggregatedProductInventoryInformation(\n ctx,\n shippingProductAvailabilities\n );\n }\n }\n\n if (bopisItems && bopisItems.length > 0) {\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 const quantityUnitTypeSales: number = 2;\n const getProductWarehouseAvail = await getEstimatedProductWarehouseAvailabilityAsync(\n { callerContext: ctx, bypassCache: 'get', queryResultSettings: {} },\n [productWarehouse],\n quantityUnitTypeSales\n );\n\n if (getProductWarehouseAvail &&\n getProductWarehouseAvail.ProductWarehouseInventoryAvailabilities &&\n getProductWarehouseAvail.ProductWarehouseInventoryAvailabilities.length > 0) {\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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput,\n IAny, ICommerceApiSettings, ICreateActionContext, IGeneric, IRequestContext } 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\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({ callerContext: context }, input.channelId, true);\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","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric, IRequestContext } 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 = () => buildCacheKey(`${this.channelId}|${this.sitePath}|top-${this.maxItems || 250} | ${this.catalogId}`,\n 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(\n new RawCategoriesInput(ctx.requestContext, false, input.maxItems),\n ctx\n );\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext,\n IActionInput, IAny, ICreateActionContext, IGeneric, IRequestContext } 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/**\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 callerContext: ctx\n },\n input.channelId, input.catalogId) 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, getCatalogId, getCategoriesUrlSync, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric, IRequestContext } 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/**\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 callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n }, input.ChannelId, input.CatalogId, input.categoryPathLooksups);\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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 (input: GetChannelDeliveryConfigurationInput, ctx: IActionContext): 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICommerceApiSettings, ICreateActionContext, msdyn365Commerce } 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport {\n createObservableDataAction, IAction, IActionContext,\n IActionInput, IAny, ICreateActionContext, IGeneric, 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 = 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(input: CurrentCategoryHierarchyInput, ctx: IActionContext): 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType, createObservableDataAction, getParameterizeFeatureFlags, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric, IParameterizeFeatureFlags, IRequestContext } 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport {\n CacheType, createObservableDataAction, IAction, IActionContext, IActionInput,\n ICommerceApiSettings, ICreateActionContext\n} from '@msdyn365-commerce/core';\nimport { CustomerBalances } from '@msdyn365-commerce/retail-proxy';\nimport {\n getCustomerBalanceAsync\n} 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. All rights reserved.\n * See License.txt 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 (\n inputData.requestContext &&\n inputData.requestContext.user &&\n inputData.requestContext.user.isAuthenticated\n ) {\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny,\n ICommerceApiSettings, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { Customer, CustomersDataActions } from '@msdyn365-commerce/retail-proxy';\n\nimport { buildCacheKey } from './utilities/utils';\n\n/**\n * Input class for get customer data action.\n */\nexport class GetCustomerInput implements IActionInput {\n public customerAccountNumber?: string;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n private readonly cacheType?: CacheType;\n\n public constructor(apiSettings: ICommerceApiSettings, accountNumber?: string, cacheType?: CacheType) {\n this.customerAccountNumber = accountNumber;\n this.apiSettings = apiSettings;\n this.cacheType = cacheType;\n }\n\n /**\n * GetCacheKey.\n * @returns - Returns string.\n */\n public getCacheKey = (): string => buildCacheKey(`Customer-${this.customerAccountNumber}`, this.apiSettings);\n\n /**\n * GetCacheObjectType.\n * @returns - Cache Object Type string.\n */\n public getCacheObjectType = (): string => 'Customer';\n\n /**\n * DataCacheType.\n * @returns - CacheType string.\n */\n public dataCacheType = (): CacheType => {\n return this.cacheType ? this.cacheType : 'request';\n };\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 * @returns - ProductAvailabilitiesForSelectedVariant or error.\n */\nconst createInput = (inputData: ICreateActionContext>): GetCustomerInput => {\n const { user, apiSettings } = inputData.requestContext;\n if (!user.token || !user.isAuthenticated) {\n throw new Error('[getCustomer][createInput]: User is not Authenticated.');\n }\n\n return new GetCustomerInput(apiSettings);\n};\n\n/**\n * GetCustomerAction.\n * @param input - GetCustomerInput.\n * @param ctx - Action Context.\n * @returns - Customer information.\n */\nconst getCustomerAction = async (input: GetCustomerInput, ctx: IActionContext): Promise => {\n if (input && ctx.requestContext.user.isAuthenticated) {\n // TO-DO- Need to clean up this code once SDK releases new proxy that handles null.\n return CustomersDataActions.readAsync({ callerContext: ctx, bypassCache: 'get' }, input.customerAccountNumber || '').then(response => {\n return Array.isArray(response) ? response[0] : response;\n });\n }\n\n ctx.trace('[getCustomer]Invalid input passed to action');\n return {};\n};\n\n/**\n * The customer data action.\n */\nexport const getCustomerActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-customer',\n action: >getCustomerAction,\n input: createInput\n});\n\nexport default getCustomerActionDataAction;\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput,\n IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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(input: ProductDeliveryOptionsForCartLineItems, ctx: IActionContext): 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 callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n },\n products.map(x => x.RecordId), {}, null)\n .then(result => {\n return result;\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { FeatureState } from '@msdyn365-commerce/retail-proxy';\nimport { getDeliveryOptionsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\nimport { FilterDeliveryModeOption, ProductDeliveryOptions, ReleasedProductType, SimpleProduct } 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 = (inputData: ICreateActionContext>): 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/**\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(item => item.Name === 'Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature')?.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(input.productId, input.channelId,\n undefined, undefined, ctx.requestContext);\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) ? FilterDeliveryModeOption.FilterOutNonPickupDeliveryMode : 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. All rights reserved.\n * See License.txt 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 { getDimensionAvailabilitiesForProductsAction, ProductsDimensionAvailabilitiesInput } from './get-dimension-availabilities-for-products';\nimport { ArrayExtensions, checkIfShouldDisplayAsSwatch, DimensionTypes, getInventoryLevelCodeFromDimensionValue,\n IDimensionsApp, InventoryLevelValues } 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 constructor(products: ProductSearchResult[], dimensionContext: ICoreContext) {\n this.products = products;\n this.dimensionContext = dimensionContext;\n }\n\n /**\n * Get the cache key.\n * @returns The cache key.\n */\n public getCacheKey = (): string => `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): DimensionAvailabilitiesForProductSearchResultInput => {\n\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\n for (const product of products) {\n const filteredProductAttributes = product.AttributeValues?.filter(attributeValue => {\n return checkIfShouldDisplayAsSwatch(\n (attributeValue.Name?.toLocaleLowerCase() ?? '') as DimensionTypes, input.dimensionContext);\n });\n\n if (ArrayExtensions.hasElements(filteredProductAttributes)) {\n for (const attributeValue of filteredProductAttributes) {\n if (attributeValue.Name) {\n const productionDimensionType: ProductDimensionType = ProductDimensionType[attributeValue.Name as keyof typeof ProductDimensionType];\n\n productsDimensionInputs.push(new ProductsDimensionAvailabilitiesInput(\n // eslint-disable-next-line inclusive-language/use-inclusive-words -- existing property.\n product.MasterProductId ?? product.RecordId,\n productionDimensionType,\n context.requestContext));\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, context);\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 // eslint-disable-next-line inclusive-language/use-inclusive-words, woke/all -- existing property.\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction,\n IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric, IRequestContext\n} from '@msdyn365-commerce/core';\nimport {\n ProductDimensionAvailabilitySearchCriteria, ProductDimensionType, ProductDimensionValueInventoryAvailability, 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/* eslint-disable inclusive-language/use-inclusive-words -- disabling inclusive words for this file. */\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\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.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 = (inputData: ICreateActionContext>): 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(productDimension.masterProductId, productDimension.requestDimensionType,\n inputData.requestContext);\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(context, [input.masterProductId], true, undefined, undefined);\n\n const searchCriteria: ProductDimensionAvailabilitySearchCriteria =\n {\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\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/* eslint-enable inclusive-language/use-inclusive-words -- enabling it back. */\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { IProductDimensionsWithAvailabilitiesFull, ProductDimensionFull } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext, IActionInput,\n IAny, ICreateActionContext, IGeneric, IRequestContext\n} from '@msdyn365-commerce/core';\nimport {\n ProductDimension, ProductDimensionAvailabilitySearchCriteria,\n ProductDimensionValue, ProductDimensionValueInventoryAvailability, 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/* eslint-disable inclusive-language/use-inclusive-words -- disabling inclusive words for this file. */\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(productId: number, channelId: number, matchingDimensionValues?: ProductDimension[], requestContext?: IRequestContext) {\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 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(newDimension.dimensionValuesWithInventory?.map(value => value.DimensionValue));\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 callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\n }, input.channelId, [input.productId], null, input.catalogId ?? 0));\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 {\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/* eslint-enable inclusive-language/use-inclusive-words -- enabling it back. */\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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 ];\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({ callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) }, input.featureNames);\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport {\n ChannelDeliveryOption,\n DeliveryModeTypeFilter,\n FeatureState,\n ItemAvailability,\n OrgUnitAvailability,\n OrgUnitLocation,\n ProductWarehouseInventoryInformation,\n SearchArea,\n StoreHours } from '@msdyn365-commerce/retail-proxy';\nimport {\n getChannelDeliveryOptionsAsync,\n getOrgUnitLocationsByAreaAsync,\n getStoreHoursAsync } 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(_productId?: number, _latitude?: number, _longitude?: number, _radius?: number, _DistanceUnitValue?: number, _IgnoreLocation?: boolean) {\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 = (inputData: ICreateActionContext>): 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(item => item.Name === 'Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature')?.IsEnabled;\n const searchCriteria = createInventoryAvailabilitySearchCriteria(ctx, [input.productId], false, true, searchArea, DeliveryMode.pickup);\n return getEstimatedAvailabilityAsync(\n { callerContext: ctx }, searchCriteria)\n .then(async (productWarehouseInformation: ProductWarehouseInventoryInformation) => {\n // For store selector, inventory should always come from an individual store\n const productInventoryInformation = mapProductInventoryInformation(ctx, productWarehouseInformation.ProductWarehouseInventoryAvailabilities);\n return getOrgUnitLocationsByAreaAsync({\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n }, searchArea, DeliveryModeTypeFilter.Pickup)\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(_channeldeliveryoption => _channeldeliveryoption.ChannelId === store.ChannelId);\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('[GetFullAvailableInventoryNearby][getEstimatedAvailabilityAsync] error getting availability product warehouse information.');\n ctx.trace(error.message);\n ctx.telemetry.error(error.message);\n ctx.telemetry.debug('[GetFullAvailableInventoryNearby][getEstimatedAvailabilityAsync] error getting availability product warehouse information.');\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, channelDeleiveryOptions: ChannelDeliveryOption | undefined): 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 &&\n storeMap) {\n productInventoryInformation.forEach(element => {\n if (element.InventLocationId && storeMap.has(element.InventLocationId) &&\n element.InventLocationId === orgUnitLocation.InventoryLocationId) {\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 return {\n OrgUnitAvailability: availability,\n ProductInventoryInformation: productInventoryInformation,\n 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 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): 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 callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n }, channelIdList, 4)\n .then((channelDeliveryOptions: ChannelDeliveryOption[]) => {\n\n if (channelDeliveryOptions && !(channelDeliveryOptions instanceof Error)) {\n return channelDeliveryOptions;\n }\n\n return undefined;\n })\n .catch((error: Error) => {\n ctx.trace('[GetFullAvailableInventoryNearby][getChannelDeliveryOptionsAsync] error getting availability with channel delivery options');\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[GetFullAvailableInventoryNearby] [getChannelDeliveryOptionsAsync] error getting availability with channel delivery options');\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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } 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)\n .then(productLists => {\n const inputLines = new GetProductListLinesInput(productLists[0].Id);\n // eslint-disable-next-line promise/no-nesting -- existing code.\n return getProductListLines(inputLines, context)\n .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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { FullProduct, IRefineFullProductSearchOutput } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction,\n IActionContext, IActionInput, IAny, ICreateActionContext, 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 ) {\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 = 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(product.RecordId, apiSettings, input.ProductDetailsCriteria || new ProductDetailsCriteria(), ctx.requestContext);\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}\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { IRefineFullProductSearchOutput } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext,\n IActionInput, IAny, ICreateActionContext, 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(\n input,\n ctx,\n () => {\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. All rights reserved.\n * See License.txt 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\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 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","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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 ) {\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\n if (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 return getActivePricesAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n projectDomain,\n validInputs,\n new Date(),\n null,\n affiliations,\n true\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 return getProductRatingsAsync({\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n }, validInputs)\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICreateActionContext } 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 callerContext: ctx,\n queryResultSettings: {}\n }, null);\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(new FullProductInput(\n commerceListLine.ProductId,\n ctx.requestContext.apiSettings,\n getProductDetailsCriteriaFromActionInput(ctx),\n ctx.requestContext));\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 })\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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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(item => new ProductInput(+item.RecordId, apiSettings, undefined, undefined, ctx.requestContext));\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 ? Number(inputData.requestContext.query.skipCount) : 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICommerceApiSettings, ICreateActionContext } from '@msdyn365-commerce/core';\nimport { LoyaltyCard } from '@msdyn365-commerce/retail-proxy';\nimport { getCustomerLoyaltyCardsAsync, getLoyaltyCardAsync } 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\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 callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n }, input.userAccountNumber || null)\n .then(cards => {\n if (!cards || cards.length === 0) {\n return {};\n }\n\n const firstCard = cards[0];\n\n return getLoyaltyCardAsync({\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n }, firstCard.CardNumber)\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICommerceApiSettings, ICreateActionContext } 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(input: GetLoyaltyTransactionEstimationInput, ctx: IActionContext): Promise {\n\n if (!ctx.requestContext.user.isAuthenticated) {\n return {};\n }\n\n const promises: [Promise, Promise, Promise] = [_getCart(ctx), _getLoyalty(input, ctx), _getOrgUnits(ctx)];\n return Promise.all(promises)\n .then((result) => {\n if (result && result.length >= 2 && result[1].CardNumber) {\n return getMaxLoyaltyPointsToRedeemForTransactionBalanceAsync(\n { callerContext: ctx }, result[0].Id, result[1].CardNumber, result[2].Currency || '')\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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 = () => 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({ callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx) },\n input.productId, input.channelId, input.catalogId).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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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/**\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(input.productId, input.channelId,\n undefined, undefined, ctx.requestContext);\n return getSelectedVariant(selectedVariantInput, ctx);\n }\n\n return activeProduct;\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, input.channelId, input.catalogId).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. All rights reserved.\n * See License.txt 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 (\n inputData.requestContext &&\n inputData.requestContext.user &&\n inputData.requestContext.user.isAuthenticated\n ) {\n return createGetOrderShipmentsHistoryInput({\n Paging: {\n Top: 100,\n Skip: 0\n }\n },\n\n // @ts-expect-error\n null);\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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICreateActionContext } 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICommerceApiSettings, ICreateActionContext } 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. All rights reserved.\n * See License.txt 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 = (\n inputData: ICreateActionContext): GetOrganizationWideOrderHistoryInput => {\n\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(input: GetOrganizationWideOrderHistoryInput, context: IActionContext): 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({ callerContext: context, queryResultSettings: input.queryResultSettings }, businessPartner.BusinessPartnerId);\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput,\n IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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, context: IActionContext): 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 callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\n },\n products.map(product => product.RecordId), {}, filterOption);\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. All rights reserved.\n * See License.txt 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';\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\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\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,\n 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 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(activePrice.BasePrice ?? priceZero,\n activePrice.TradeAgreementPrice ?? priceZero,\n activePrice.AdjustedPrice ?? priceZero);\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext,\n IActionInput, IAny, ICreateActionContext, 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(\n +productId,\n +inputData.requestContext.apiSettings.channelId,\n undefined);\n }\n throw new Error('Unable to create PriceForSelectedVariantInput, no productId found on module config or query');\n\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(input.productId, input.channelId,\n undefined, undefined, ctx.requestContext);\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')?.IsEnabled &&\n // eslint-disable-next-line inclusive-language/use-inclusive-words -- Existing property name.\n (activeProduct.ProductTypeValue === ProductType.Master || activeProduct.ProductTypeValue === ProductType.KitMaster),\n featureStates.find(featureState => featureState.Name === 'Dynamics.AX.Application.RetailSalesAgreementPriceSupportFeature')?.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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { ProductAvailableQuantity, ProductsDataActions, ProductType,\n ProductWarehouseInventoryAvailability, ReleasedProductType } 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/**\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,\n undefined, undefined, ctx.requestContext);\n const productInventoryInformation: IProductInventoryInformation[] = [];\n\n try {\n\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 (ctx.requestContext.app.config.enableStockCheck && productResult && productResult.ItemTypeValue !== ReleasedProductType.Service &&\n productResult.ProductTypeValue !== ProductType.Master) {\n const shippingSearchCriteria = createInventoryAvailabilitySearchCriteria(\n ctx,\n [productResult.RecordId],\n true,\n undefined,\n undefined,\n DeliveryMode.shipping);\n const pickupSearchCriteria = createInventoryAvailabilitySearchCriteria(ctx, [input.productId], false, true, undefined, DeliveryMode.pickup);\n const shippingAvailability = await ProductsDataActions.getEstimatedAvailabilityAsync({ callerContext: ctx }, shippingSearchCriteria);\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({ callerContext: ctx }, pickupSearchCriteria);\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(productsWarehouseInventory: ProductWarehouseInventoryAvailability[]): 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { IProductDimensionsWithAvailabilitiesFull } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction,\n IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric, 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\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 = (inputData: ICreateActionContext>): ProductDimensionsWithAvailabilitiesInput => {\n const productId = getSelectedProductIdFromActionInput(inputData);\n\n if (productId) {\n return new ProductDimensionsWithAvailabilitiesInput(+productId, +inputData.requestContext.apiSettings.channelId, inputData.requestContext);\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 callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\n }, input.channelId, [input.productId], null, input.catalogId ?? 0));\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 {\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 // eslint-disable-next-line inclusive-language/use-inclusive-words -- notation used in commerce\n activeProduct.MasterProductId ? activeProduct.MasterProductId : activeProduct.RecordId,\n searchCriteria\n );\n // eslint-disable-next-line promise/prefer-await-to-then -- Existing pattern to execute promises\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 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. All rights reserved.\n * See License.txt 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","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n 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(input: GetProductListLinesInput, context: IActionContext): 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 callerContext: context\n }, input.productListId, input.searchText);\n\n const productListLines = await promise;\n const productInputs: FullProductInput[] = [];\n\n if (ArrayExtensions.hasElements(productListLines)) {\n // eslint-disable-next-line length-extensions-check -- Need to check length.\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(new FullProductInput(listLine.ProductId,\n context.requestContext.apiSettings, getProductDetailsCriteriaFromActionInput(context),\n context.requestContext));\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(product => product.ProductDetails.RecordId === line.productListLine.ProductId);\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } from '@msdyn365-commerce/core';\nimport { ProductList, ProductListsDataActions, ProductListSearchCriteria, ProductListType, QueryResultSettings } 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 = (inputData: ICreateActionContext,\n productListId?: string, queryResultSettings?: QueryResultSettings): 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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 = () => buildCacheKey(`${this.categoryId || this.categorySlug}|${this.catalogId}|${this.queryResultSettingsProxy.cacheKeyHint}`, this.apiSettings);\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(\n currentCategory,\n inputData.requestContext.apiSettings,\n queryResultSettingsProxy\n );\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 return await getProducts(productInputs, ctx);\n }\n return [];\n\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICreateActionContext } 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, ctx.requestContext.apiSettings, undefined, undefined, ctx.requestContext, cartLine.CatalogId);\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 })\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([...productIdsByWarehouseId].map(([entryWarehouseId, entryProductIds]) => {\n return getSimpleProducts(\n entryProductIds.map(cartLine => {\n if (cartLine.ProductId) {\n return new ProductInput(cartLine.ProductId,\n ctx.requestContext.apiSettings,\n undefined,\n entryWarehouseId,\n ctx.requestContext,\n cartLine.CatalogId);\n }\n return undefined;\n }).filter(Boolean),\n ctx\n )\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 })).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 = featureStates\n .find((featureState: FeatureState) => featureState.Name === 'Dynamics.AX.Application.RetailDefaultOrderQuantityLimitsFeature')?.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 !!customerInfo &&\n ((defaultOrderQuantityLimitsFeatureConfig === 'b2b' && customerInfo.IsB2b) ||\n (defaultOrderQuantityLimitsFeatureConfig === 'b2c' && !customerInfo.IsB2b));\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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(input: PromotionOptionsForCartLineItems, ctx: IActionContext): 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 }).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. All rights reserved.\n * See License.txt 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(\n productId: string,\n tenantId: string,\n serviceEndpoint: string\n ) {\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { RatingsSummary } from '@msdyn365-commerce/commerce-entities';\nimport { createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric, sendRequest } 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 */\nasync 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?` +\n `tenantId=${input.tenantId}`;\n return sendRequest(requestUrl, 'get').then((response) => {\n return response.data;\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { createObservableDataAction, getCatalogId, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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(\n currentCategory,\n QueryResultSettingsProxy.fromInputData(inputData),\n catalogId\n );\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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 this.catalogId = catalogId;\n this.searchText = searchText;\n this.queryResultSettingsProxy = queryResultSettingsProxy;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => 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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction,\n IActionContext, IActionInput, IAny, ICreateActionContext, 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 = () => `${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(\n product.RecordId,\n apiSettings,\n input.ProductDetailsCriteria,\n 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/**\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICommerceApiSettings, ICreateActionContext } 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 = (inputData: ICreateActionContext, skuNumber: string, channelId: number, matchingDimensionValues?: ProductDimension[]) => {\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(new GetDimensionsForSelectedVariantInput(\n scanResults.Product.MasterProductId ? scanResults.Product.MasterProductId : scanResults.Product.RecordId, input.channelId, input.matchingDimensionValues,\n ctx.requestContext), ctx)\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } 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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { IProductDimensionsWithAvailabilitiesFull } from '@msdyn365-commerce/commerce-entities';\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction,\n IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric, IRequestContext\n} from '@msdyn365-commerce/core';\nimport { BypassCache, ProductDimension, ProductDimensionAvailabilitySearchCriteria, ProductsDataActions,\n SimpleProduct } 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, channelId: number, matchingDimensionValues?: ProductDimension[],\n bypassCache?: BypassCache, 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(+productId, +inputData.requestContext.apiSettings.channelId,\n undefined, undefined, inputData.requestContext);\n }\n throw new Error('Unable to create SelectedVariantInput, no productId found on module config or query');\n\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 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 (product: SimpleProduct, matchingDimensionValues: ProductDimension[], context: IActionContext, catalogId?: number) => {\n let fullDimensions: IProductDimensionsWithAvailabilitiesFull[] = [];\n const fullDimensionPromises = (product.Dimensions ?? []).map(dimension => {\n const shippingInventoryConfiguration = createInventoryAvailabilitySearchCriteria(context, [], true, undefined, undefined);\n const searchCriteria: ProductDimensionAvailabilitySearchCriteria =\n {\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 (ArrayExtensions.hasElements(fullDimensions) &&\n ArrayExtensions.hasElements(fullDimensions[0].dimensionValuesWithInventory) &&\n ArrayExtensions.hasElements(fullDimensions[0].dimensionValuesWithInventory[0].ProductIds)) {\n const variantProductId = fullDimensions[0].dimensionValuesWithInventory[0].ProductIds[0];\n const result = await ProductsDataActions.getByIdsAsync({\n callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context),\n bypassCache: input.bypassCache\n }, input.channelId, [variantProductId], null, input.catalogId ?? 0);\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 callerContext: context,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context),\n bypassCache: input.bypassCache\n }, input.channelId, [input.productId], null, input.catalogId ?? 0);\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(product, matchingDimensionValues, context, input.catalogId);\n\n // Retrieve product variants only if matching dimensions are provided.\n const productVariant: SimpleProduct | undefined = ArrayExtensions.hasElements(matchingDimensionValues) ? await\n getProductVariant(input, context, fullDimensions) : 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 const matchedTargetDimensionFromSearch = matchingDimensionValues.find(\n targetDimension => targetDimension.DimensionTypeValue === dimension.DimensionTypeValue);\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport {\n CacheType, createObservableDataAction, getCatalogId, IAction, IActionContext, IActionInput,\n IAny, ICommerceApiSettings, ICreateActionContext, IDictionary, IGeneric, 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, apiSettings: ICommerceApiSettings,\n channelId?: number, warehouseId?: string, 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 = () => buildCacheKey(\n `RecordId-${this.productId.toString()}-ChannelId-${this.channelId.toString()}-WahehouseId-${this.warehouseId ?? ''}-${this.catalogId ?? 0}`,\n this.apiSettings);\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) ? [] : productIds.map((productId: string) => {\n return new ProductInput(productId, inputData.requestContext.apiSettings,\n undefined, undefined,\n 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 // eslint-disable-next-line unicorn/no-for-loop -- Need to use indices for dictionary.\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(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 const products = ArrayExtensions.flatten(await Promise.all(getProductPromises));\n const mappedProducts = products.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 }).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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { ChannelDeliveryOption, FeatureState, OrgUnitAvailability, OrgUnitLocation, SearchArea, StoreHours } from '@msdyn365-commerce/retail-proxy';\nimport { getChannelDeliveryOptionsAsync, getOrgUnitLocationsByAreaAsync, getStoreHoursAsync } 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\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(item => item.Name === 'Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature')?.IsEnabled;\n\n return getOrgUnitLocationsByAreaAsync({\n callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n }, searchArea)\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(_channeldeliveryoption => _channeldeliveryoption.ChannelId === store.ChannelId);\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, channelDeleiveryOptions: ChannelDeliveryOption | undefined,\n ctx: IActionContext): Promise {\n if (!orgUnitLocation || !orgUnitLocation.OrgUnitNumber) {\n return { OrgUnitAvailability: undefined };\n }\n\n return getStoreHoursAsync({ callerContext: ctx }, orgUnitLocation.OrgUnitNumber)\n .then((hours: StoreHours) => {\n\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): 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 callerContext: ctx,\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(ctx)\n }, channelIdList, 4)\n .then((channelDeliveryOptions: ChannelDeliveryOption[]) => {\n\n if (channelDeliveryOptions && !(channelDeliveryOptions instanceof Error)) {\n return channelDeliveryOptions;\n }\n\n return undefined;\n })\n .catch((error: Error) => {\n ctx.trace('[GetFullAvailableInventoryNearby][getChannelDeliveryOptionsAsync] error getting availability with channel delivery options');\n ctx.trace(error.message);\n ctx.telemetry.exception(error);\n ctx.telemetry.debug('[GetFullAvailableInventoryNearby] [getChannelDeliveryOptionsAsync] error getting availability with channel delivery options');\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. All rights reserved.\n * See License.txt 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 (\n inputData.requestContext &&\n inputData.requestContext.user &&\n inputData.requestContext.user.isAuthenticated\n ) {\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICreateActionContext } 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICreateActionContext } from '@msdyn365-commerce/core';\nimport { InvoicePaidStatus, InvoiceSearchCriteria, InvoiceType, IQueryResultSettings, OrderInvoice, SalesOrdersDataActions } 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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, ICommerceApiSettings, ICreateActionContext } 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } 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, orderTemplateId: string, productId: number, quantity: number, unitOfMeasure: string): AddItemToOrderTemplateInput => {\n\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 callerContext: ctx\n }, input.orderTemplateId, [productListLineToAdd]);\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\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. All rights reserved.\n * See License.txt 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);\n context.telemetry.trace('Unable to add order template to cart.');\n throw error;\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. All rights reserved.\n * See License.txt 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 callerContext: ctx\n }, orderTemplate);\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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } from '@msdyn365-commerce/core';\nimport { IQueryResultSettings } from '@msdyn365-commerce/retail-proxy';\nimport { ProductList } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { getOrderTemplates, GetOrderTemplatesInput, getPaginatedOrderTemplateLinesAction, GetPaginatedOrderTemplateLinesInput, QueryResultSettingsProxy } 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } from '@msdyn365-commerce/core';\nimport { IQueryResultSettings } from '@msdyn365-commerce/retail-proxy';\nimport { ProductList } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g';\n\nimport { getOrderTemplates, GetOrderTemplatesInput, getPaginatedOrderTemplateLinesAction, GetPaginatedOrderTemplateLinesInput, QueryResultSettingsProxy } from '..';\nimport { 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\n constructor(queryResultSettings: IQueryResultSettings) {\n this.queryResultSettings = queryResultSettings;\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 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 for (const list of productLists) {\n const inputLines = new GetPaginatedOrderTemplateLinesInput(list.Id, input.queryResultSettings);\n const linesState = await getPaginatedOrderTemplateLinesAction(inputLines, ctx);\n orderTemplates.push(new OrderTemplate(list, linesState.lines, linesState.totalCount));\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } 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 return getFullOrderTemplates(new GetFullOrderTemplatesInput(input.queryResultSettings), 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } 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 => `${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 = (inputData: ICreateActionContext, productListId?: string, queryResultSettings?: QueryResultSettings): 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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { FullProduct } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } 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, getProductDetailsCriteriaFromActionInput, 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\n public queryResultSettings: IQueryResultSettings;\n\n public searchText: string;\n\n constructor(orderTemplateId: string, queryResultSettings: IQueryResultSettings, searchText?: string) {\n this.orderTemplateId = orderTemplateId;\n this.queryResultSettings = queryResultSettings;\n this.searchText = searchText || '';\n }\n\n public getCacheKey = () => `GetPaginatedOrderTemplateLines|${this.orderTemplateId}|${convertToString(this.queryResultSettings)}|${this.searchText}`;\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, orderTemplateId: string, searchText?: string): GetPaginatedOrderTemplateLinesInput => {\n\n const queryResultSettings: IQueryResultSettings = QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings;\n queryResultSettings.count = true;\n return new GetPaginatedOrderTemplateLinesInput(orderTemplateId, queryResultSettings, searchText);\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(input: GetPaginatedOrderTemplateLinesInput, context: IActionContext): 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 callerContext: context, queryResultSettings: input.queryResultSettings\n }, input.orderTemplateId, input.searchText); 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(new FullProductInput(\n listLine.ProductId,\n context.requestContext.apiSettings, getProductDetailsCriteriaFromActionInput(context),\n context.requestContext));\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 })\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(product => product.ProductDetails.RecordId === line.productListLine.ProductId);\n if (!fullProduct) {\n context.telemetry.error('[getPaginatedOrderTemplateLinesAction] Unable to find product info for an order template line.');\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } 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 = (inputData: ICreateActionContext, orderTemplate: ProductList): 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 callerContext: ctx\n }, orderTemplate);\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\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType,\n createObservableDataAction,\n IAction,\n IActionContext,\n IActionInput,\n ICreateActionContext } 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, orderTemplateId: string, productId: number, quantity: number, unitOfMeasure: string): UpdateOrderTemplateInput => {\n\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 callerContext: ctx\n }, input.orderTemplateId, [lineToUpdate]);\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 (updatedLine.length !== 1 || updatedLine[0].Quantity !== input.quantity || updatedLine[0].UnitOfMeasure !== input.unitOfMeasure) {\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { CacheType, createObservableDataAction,\n IAction, IActionInput, 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) ? [] : 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. All rights reserved.\n * See License.txt 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 { requestContext: { query, apiSettings: { channelId } } } = inputData;\n\n const search = query && query.q;\n\n if (!search) {\n throw new Error('Unable to preform search without search text. Query string ?q={searchText} must be present or should be configued in module data.');\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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport {\n CacheType, createObservableDataAction, IAction, IActionContext, IActionInput,\n ICommerceApiSettings\n} from '@msdyn365-commerce/core';\nimport { Customer, CustomerAttribute } from '@msdyn365-commerce/retail-proxy';\nimport {\n readAsync, updateAsync\n} 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 */\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(userAccountNumber: string, customerAttributes: CustomerAttribute[], apiSettings: ICommerceApiSettings, phone?: string, vatNumber?: string) {\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport {\n CacheType, createObservableDataAction, IAction, IActionContext, IActionInput,\n ICommerceApiSettings\n} from '@msdyn365-commerce/core';\nimport { Customer } from '@msdyn365-commerce/retail-proxy';\nimport {\n readAsync, updateAsync\n} 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 */\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(input: IUpdateCustomerPersonalizationInput, ctx: IActionContext): 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext } from '@msdyn365-commerce/core';\nimport {\n readAsync, updateAsync\n} 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { IAny, ICreateActionContext, IGeneric, IRequestContext } from '@msdyn365-commerce/core';\nimport { QueryResultSettings, SortColumn } from '@msdyn365-commerce/retail-proxy';\n\nimport { IQueryResultSettingsModuleConfig } from './IQueryResultSettingsModuleConfig';\n\n/**\n * Wrapper for query result settings, which guarantees some properties that are optional in the real subject\n * and includes some common utilities for data actions.\n */\nexport class QueryResultSettingsProxy {\n // Real subject\n private readonly queryResultSettings: QueryResultSettings;\n\n /**\n * Private constructor, expect instances to be created with the factory method.\n * @param queryResultSettings - Query result setting.\n */\n private constructor(\n queryResultSettings: QueryResultSettings\n ) {\n this.queryResultSettings = queryResultSettings;\n }\n\n public get QueryResultSettings(): QueryResultSettings {\n return this.queryResultSettings;\n }\n\n /**\n * Gets the hints for the cache key based on query result settings.\n * @returns - Returns cache key hint.\n */\n public get cacheKeyHint(): string {\n // The factory method guarantees values are defined\n const topHint = `top-${this.queryResultSettings.Paging!.Top!}`;\n const skipHint = `skip-${this.queryResultSettings.Paging!.Skip!}`;\n const sortingHintData = (this.queryResultSettings.Sorting!.Columns || []).map((column: SortColumn) => {\n return `${column.ColumnName}--${column.IsDescending && 'desc' || 'asc'}`;\n }).join(',') || undefined;\n const sortingHint = `sortBy-${sortingHintData}`;\n return `${topHint}|${skipHint}|${sortingHint}`;\n }\n\n /**\n * Factory method for data actions.\n * @param inputData - Input data.\n * @returns - Returns query result settings proxy.\n */\n public static fromInputData(inputData: ICreateActionContext>): QueryResultSettingsProxy {\n const { requestContext, config } = inputData;\n return QueryResultSettingsProxy.fromModuleData(requestContext, config as IQueryResultSettingsModuleConfig);\n }\n\n /**\n * Factory method for modules.\n * @param requestContext - RequestContext.\n * @param config - Module config from props.\n * @returns - Returns query result settings proxy.\n */\n public static fromModuleData(requestContext: IRequestContext, config: IQueryResultSettingsModuleConfig): QueryResultSettingsProxy {\n const sortingCriteria = config && config.sortingCriteria || undefined;\n const query = requestContext && requestContext.query;\n const top = query && query.top || undefined;\n const skip = query && query.skip || undefined;\n\n const queryResultSettings = {\n Paging: {\n Skip: (skip && Number(skip) || 0),\n Top: (top && Number(top) || config?.itemsPerPage || 50)\n },\n Sorting: sortingCriteria || {}\n };\n\n return new QueryResultSettingsProxy(queryResultSettings);\n }\n\n /**\n * Return the query result settings with default paging or with the passed value.\n * @param inputData - Input Data.\n * @returns - Query Result settings.\n */\n public static getPagingFromInputDataOrDefaultValue(inputData: ICreateActionContext>): QueryResultSettings {\n const config: IQueryResultSettingsModuleConfig | undefined = inputData.config;\n const defaultPageSize: number = 100;\n const queryResultSettings: QueryResultSettings = {\n Paging: {\n // eslint-disable-next-line max-len -- Disable max length for next line.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unnecessary-condition -- Reading from config.\n Top:\n config?.itemsPerPage ??\n Number.parseInt(inputData.requestContext?.app?.platform?.defaultPageSizeForAPI ?? defaultPageSize, 10)\n }\n };\n return queryResultSettings;\n }\n\n /**\n * Factory method.\n * @returns - Returns query result settings proxy.\n */\n public static getDefault(): QueryResultSettingsProxy {\n return new QueryResultSettingsProxy({ Paging: {}, Sorting: {} });\n }\n\n}\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport msdyn365Commerce, { IParameterizeFeatureFlags } from '@msdyn365-commerce/core';\n\nexport function parameterize(name: string = '', sep = '-', parameterizeFeatureFlags: IParameterizeFeatureFlags = {}, neutralizedName?: string) {\n // If neutralizedName flag enabled, we use neutralizedName to construct string\n const candidateName = (msdyn365Commerce.platformSettings && msdyn365Commerce.platformSettings.enableUrlLocalization || parameterizeFeatureFlags.enableUrlLocalization) ? name : 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 (parameterizeFeatureFlags.enableUrlEncoding || msdyn365Commerce.platformSettings && msdyn365Commerce.platformSettings.enableUrlEncoding) {\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(candidateName.toLowerCase().replace(/[\\s!&'()*]+/g, '-').trim().replace(/-+/g, '-').replace(/^-+|-+$/g, ''));\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. All rights reserved.\n * See License.txt 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(category: CategoryHierarchy, categoryMap: ICategoryMap, parameterizeFeatureFlags?: IParameterizeFeatureFlags): 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 = category.Slug || `${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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { ObjectExtensions } from './object-extensions';\n\n/**\n * Represents an array which is defined with at least one value.\n */\nexport type NonEmptyArray = [T, ...T[]];\n\n/**\n * Namespace which extends Array functionality.\n */\nexport namespace ArrayExtensions {\n\n /**\n * Verifies whether the object array has elements.\n * @param value - The array to examine.\n * @returns True if the object has at least one element in the array, false otherwise (if array is not defined or empty).\n */\n export function hasElements(value: NonEmptyArray | T[] | null | undefined): value is NonEmptyArray {\n const emptyArrayLength = 0;\n return !ObjectExtensions.isNullOrUndefined(value) && value.length > emptyArrayLength;\n }\n\n /**\n * Retrieves the first element in the array or default value if the array is empty.\n * @param values - The array with values.\n * @param defaultValue - Optional parameter to specify default value. If not specified, undefined will be used.\n * @returns First element or default value.\n */\n export function firstOrDefault(values: NonEmptyArray | T[] | null | undefined, defaultValue?: T): T | undefined {\n if (hasElements(values)) {\n return values[0];\n }\n return defaultValue;\n }\n\n /**\n * Remove duplicate elements in the array.\n * @param value - The array to examine.\n * @returns An array with only unique elements.\n */\n export function unique(value: T[]): T[] {\n if (!hasElements(value)) {\n return [];\n }\n\n return Array.from(new Set(value));\n }\n\n /**\n * Checks if all elements satisfy given condition.\n * @param value - The array to examine.\n * @param predicate - The function which checks an element.\n * @returns True if the array is empty or all the inner elements satisfy given condition,\n * false if at least one element does not pass the condition.\n */\n export function all(value: T[] | null | undefined, predicate: (value: T, index: number, array: T[]) => boolean): boolean {\n if (!hasElements(value)) {\n return true;\n }\n\n return value.filter(predicate).length === value.length;\n }\n\n /**\n * Filters out null and undefined values from the given array.\n * @param value - The array with possibly undefined/null items.\n * @returns All items which are not null or undefined.\n */\n export function validValues(value: (T | undefined | null)[] | undefined | null): T[] {\n if (!hasElements(value)) {\n return [];\n }\n\n return value.filter(item => !ObjectExtensions.isNullOrUndefined(item)) as T[];\n }\n\n /**\n * Merges items from 2-dimensional array into one array with all items.\n * @param value - The 2-dimensional array with the items.\n * @returns All items retrieved from all inner arrays.\n */\n export function flatten(value: ((T | undefined | null)[] | undefined | null)[]): T[] {\n let result: T[] = [];\n\n if (!hasElements(value)) {\n return result;\n }\n\n for (const arrayLine of value) {\n if (!ObjectExtensions.isNullOrUndefined(arrayLine)) {\n result = result.concat(validValues(arrayLine));\n }\n }\n\n return result;\n }\n\n /**\n * Check if two arrays are equal.\n * @param firstArray - The array with the items.\n * @param secondArray - Another array with the items.\n * @param comparator - The comparator which compares the values and returns true if two objects are equal, false otherwise.\n * @returns True if arrays have the same items, false otherwise.\n */\n export function equals(firstArray: T[], secondArray: T[], comparator?: (valueFromFirstArray: T, valueFromSecondArray: T) => boolean): boolean {\n if (firstArray.length !== secondArray.length) {\n return false;\n }\n\n if (comparator === undefined) {\n return JSON.stringify(firstArray) === JSON.stringify(secondArray);\n }\n\n // eslint-disable-next-line unicorn/no-for-loop -- Disable as we need to compare by indices.\n for (let index = 0; index < firstArray.length; ++index) {\n if (!comparator(firstArray[index], secondArray[index])) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Check if two arrays have the same elements irrespective of the order.\n * @param firstArray - The array with the items.\n * @param secondArray - Another array with the items.\n * @param comparator - The comparator which compares the values and returns true if two objects are equal, false otherwise.\n * @returns True if arrays have the same items, false otherwise.\n */\n export function haveSameItems(\n firstArray: T[], secondArray: T[],\n comparator: (valueFromFirstArray: T, valueFromSecondArray: T) => boolean = (\n valueFromFirstArray: T, valueFromSecondArray: T) => valueFromFirstArray === valueFromSecondArray): boolean {\n\n if (firstArray.length !== secondArray.length) {\n return false;\n }\n\n for (const item of firstArray) {\n if (!secondArray.some(otherItem => comparator(item, otherItem))) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Calculates a sum of elements in the given array.\n * @param data - List of items.\n * @returns Sum of elements.\n */\n export function calculateSum(data: NonEmptyArray): number {\n let result = data[0];\n for (let index = 1; index < data.length; ++index) {\n result += data[index];\n }\n\n return result;\n }\n\n /**\n * Reverses the elements in the array without modifying the original one.\n * @param array - The array with the items.\n * @returns A new array with reversed order.\n */\n export function reverse(array: T[]): T[] {\n const newArray: T[] = [];\n\n for (let index = array.length - 1; index >= 0; --index) {\n newArray.push(array[index]);\n }\n\n return newArray;\n }\n}\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { ObjectExtensions } from './object-extensions';\n\n/**\n * Namespace which extends enum functionality.\n */\nexport namespace EnumExtensions {\n\n /**\n * @description Returns a list of numeric values and enum names for the specified enum.\n * @param enumClass\n * @param {any} value The enum to examine.\n * @returns {(number | string)[]} An array of numeric values and enum names.\n */\n export function getValues(enumClass: any): (number | string)[] {\n if (ObjectExtensions.isNullOrUndefined(enumClass)) {\n return [];\n }\n\n return Object.keys(enumClass).map(item => enumClass[item]);\n }\n\n /**\n * @description Returns a list of enum names for the specified enum.\n * @param enumClass\n * @param {any} value The enum to examine.\n * @returns {(number | string)[]} An array of string values.\n */\n export function getNames(enumClass: any): string[] {\n return getValues(enumClass).filter(ObjectExtensions.isString);\n }\n\n /**\n * @description Returns a list of numeric values for the specified enum.\n * @param enumClass\n * @param {any} value The enum to examine.\n * @returns {number[]} An array of numeric values.\n */\n export function getNumericValues(enumClass: any): number[] {\n return getValues(enumClass).filter(ObjectExtensions.isNumber);\n }\n\n /**\n * @description Returns a list of enum values for the specified enum.\n * @param enumClass\n * @param {any} value The enum to examine.\n * @returns {number[]} An array of enum values.\n */\n export function getEnumValues(enumClass: any): T[] {\n return getNumericValues(enumClass).map(value => value);\n }\n\n}\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { ObjectExtensions } from './object-extensions';\n\n/**\n * Namespace which extends string functionality.\n */\nexport namespace StringExtensions {\n\n /**\n * Checks if string is null, undefined, empty, or whitespace.\n * @param {string | null | undefined} value The string to examine.\n * @returns {boolean} True if it's null, undefined, empty, or whitespace; false otherwise.\n */\n export function isNullOrWhitespace(value: string | null | undefined): boolean {\n return isNullOrEmpty(value) || value!.trim() === '';\n }\n\n /**\n * Checks if string is null, undefined, or empty.\n * @param {string | null | undefined} value The string to examine.\n * @returns {boolean} True if it's null, undefined, empty, or whitespace; false otherwise.\n */\n export function isNullOrEmpty(value: string | null | undefined): boolean {\n if (ObjectExtensions.isNullOrUndefined(value)) {\n return true;\n }\n\n if (!ObjectExtensions.isString(value)) {\n throw new Error('StringExtensions has received a non-string input.');\n }\n\n return value === '';\n }\n}\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\n/**\n * Namespace which extends Object functionality.\n */\nexport namespace ObjectExtensions {\n\n /**\n * @description Verifies whether the value is null or undefined.\n * @param {any} value The value to examine.\n * @returns {boolean} True if the value is null or undefined, false otherwise.\n */\n export function isNullOrUndefined(value: any): value is null | undefined {\n return value === null || value === undefined;\n }\n\n /**\n * @description Verifies whether the value is of type string.\n * @param {any} value The value to examine.\n * @returns {boolean} True if the value is a string, false otherwise.\n */\n export function isString(value: any): value is string {\n return typeof value === 'string';\n }\n\n /**\n * @description Verifies whether the value is of type number.\n * @param {any} value The value to examine.\n * @returns {boolean} True if the value is a number, false otherwise.\n */\n export function isNumber(value: any): value is number {\n return typeof value === 'number';\n }\n\n /**\n * Verifies whether the object is a function.\n * @param {any} object The object.\n * @param value\n * @returns {boolean} True if the object is a function, false otherwise.\n */\n export function isFunction(value: any): boolean {\n return typeof value === 'function';\n }\n\n}\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt 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 = (\n args.requestContext.apiSettings.rnr.proxyUrl ? args.requestContext.apiSettings.rnr.proxyUrl : 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { QueryResultSettings } from '@msdyn365-commerce/retail-proxy';\n\nimport { QueryResultSettingsProxy } from './QueryResultSettingsProxy';\n\nexport interface ISearchData {\n q: string;\n skip: number;\n top: number;\n itemsPerPage: string;\n maxItems: string;\n channelId: number;\n queryResultSettings: QueryResultSettings;\n}\n\nexport const parseSearchData = (inputData: ICreateActionContext>): ISearchData => {\n // Query is of type 'IDictionary | undefined', so that q and skip are not recognized by tsc\n // @ts-expect-error:2339\n const { requestContext: { query: { q, top, skip }, apiSettings: { channelId } }, config: { maxItems, itemsPerPage } } = inputData;\n const queryResultSettings = QueryResultSettingsProxy.fromInputData(inputData).QueryResultSettings;\n return {\n q,\n skip: (skip && Number(skip) || 0),\n top: (top && Number(top) || 50),\n itemsPerPage, // TODO BUGBUG 21667361\n maxItems, // TODO BUGBUG 21667361\n channelId,\n queryResultSettings\n };\n};\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { ProductAvailableQuantity, ProductDimensionValueInventoryAvailability, ProductInventoryAvailability } 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): InventoryLevelValues | undefined => {\n\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): InventoryLevelValues | undefined => {\n\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport { IActionContext } from '@msdyn365-commerce/core';\nimport { InventoryAvailabilitySearchCriteria,\n ProductAvailableQuantity,\n ProductWarehouseInventoryAvailability,\n ProductWarehouseInventoryInformation,\n SearchArea } 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 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[]): 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): IProductInventoryInformation | null {\n if (productWarehouseInventoryAvailability.ProductId &&\n 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): IProductInventoryInformation | null {\n const shouldRenderLabel = displayLabelEnabled(context, productWarehouseInventoryAvailability.PhysicalAvailableInventoryLevelCode);\n\n if (productWarehouseInventoryAvailability.ProductId &&\n 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): IProductInventoryInformation | null {\n\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 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 (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 * 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): IProductInventoryInformation[] {\n if (isAggregatedInventory(context)) {\n const productInventoryMapping: ProductWarehouseInventoryAvailability[] | undefined =\n productWarehouseInventoryInformation.AggregatedProductInventoryAvailabilities?.map(\n 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 );\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\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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt 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.body().then(element.resolve).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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt 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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\n/**\n * Regular expressions to validate emails.\n */\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-Z0-9])?)*$/; // eslint-disable-line unicorn/better-regex, security/detect-unsafe-regex, require-unicode-regexp, max-len -- HTML 5 Email Validation Regex.\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\n/**\n * Regular expressions to validate passwords.\n */\nexport abstract class PasswordRegex {\n // eslint-disable-next-line max-len, unicorn/better-regex, require-unicode-regexp -- Default regex from the existing implementation.\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. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\n/**\n * Regular expressions to validate phone number.\n */\nexport abstract class PhoneRegex {\n\n public static readonly defaultRegex = '^$|^[- +()]*[0-9][- +()0-9]*$';\n}\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt in the project root for license information.\n *--------------------------------------------------------------*/\n\nimport msdyn365Commerce, { generateImageUrl as generateImageUrlFromSdk, IAny, ICommerceApiSettings, ICoreContext,\n ICreateActionContext, IGeneric, IRequestContext } from '@msdyn365-commerce/core';\nimport {\n AsyncResult, AttributeValue, CartLine, ChannelInventoryConfiguration, CommerceListLine, ProductDimension,\n ProductDimensionType, ProductSearchResult, QueryResultSettings, SimpleProduct\n} from '@msdyn365-commerce/retail-proxy';\n\nimport { ProductDetailsCriteria } from '../get-full-products';\nimport { ArrayExtensions } from './extensions';\nimport { parseSearchData } from './input-data-parser';\nimport { InventoryLevels } from './product-inventory-information';\n\nexport const wrapInResolvedAsyncResult = (input: T | null | undefined): AsyncResult => {\n return >{\n status: 'SUCCESS',\n result: input,\n metadata: {}\n };\n};\n\nexport const wrapInRejectedAsyncResult = (input: T | null | undefined): AsyncResult => {\n return >{\n status: 'FAILED',\n result: input,\n metadata: {}\n };\n};\n\nexport const buildQueryResultSettings = (inputData: ICreateActionContext, IGeneric>): QueryResultSettings => {\n try {\n const searchInputData = parseSearchData(inputData);\n const search = searchInputData.q;\n if (!search) {\n throw new Error('Query string ?q={searchText} is needed for search actions.');\n }\n const top = (searchInputData.maxItems && Number(searchInputData.maxItems)) || searchInputData.top;\n return { Paging: { Top: top, Skip: searchInputData.skip } };\n } catch {\n return {};\n }\n};\n\n/**\n * Utility function to extract the active productId in the following priority:\n * First query param (productId), then UrlToken (itemId), then module config.\n * @param inputData - The Action Input data.\n * @returns Productid or undefined.\n */\nexport const getSelectedProductIdFromActionInput = (inputData: ICreateActionContext>): string | undefined => {\n const context = inputData.requestContext;\n if (context.query?.productId) {\n return context.query.productId;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Exsiting code.\n } else if (context.urlTokens && inputData.requestContext.urlTokens.itemId && inputData.requestContext.urlTokens.pageType === 'Product') {\n return context.urlTokens.itemId;\n } else if (inputData && inputData.config && inputData.config.productId) {\n return inputData.config.productId;\n }\n return undefined;\n};\n\n/**\n * Generates a Image URL based on data return from retail server.\n * @param imageUrl The image url returned by Retail Server.\n * @param ctx The request context.\n * @param apiSettings\n */\nexport const generateImageUrl = (imageUrl: string | undefined, apiSettings: ICommerceApiSettings): string | undefined => {\n return generateImageUrlFromSdk(apiSettings, imageUrl);\n};\n\n/**\n * Represents app configuration for dimensions.\n */\nexport interface IDimensionsConfig {\n dimensionsAsSwatchType?: DimensionTypes[];\n dimensionsInProductCard?: DimensionTypes[];\n inventoryLevel?: InventoryLevels;\n dimensionToPreSelectInProductCard?: DimensionTypes;\n}\n\n/**\n * Represents app configuration for dimensions.\n */\nexport interface IDimensionsApp {\n config: IDimensionsConfig;\n}\n\n/**\n * Represents product dimension types.\n */\nexport enum DimensionTypes {\n none = 'none',\n color = 'color',\n configuration = 'configuration',\n size = 'size',\n style = 'style'\n}\n\n/**\n * Defines display configuration types.\n */\nexport enum DimensionSwatchDisplayTypes {\n default = 'default',\n productCard = 'productCard'\n}\n\n/**\n * Checks if rendering the particular dimensions is allowed.\n * @param dimensionType - Dimension to be displayed.\n * @param context - Core application context.\n * @param displayType - The swatch location, the component from which it comes from.\n * @returns Updates the state with new product page url.\n */\nexport const checkIfShouldDisplayAsSwatch = (\n dimensionType: DimensionTypes,\n context: ICoreContext,\n displayType: DimensionSwatchDisplayTypes = DimensionSwatchDisplayTypes.default): boolean => {\n\n // Additional checks for the product card since it has a separate config setting.\n if (displayType === DimensionSwatchDisplayTypes.productCard) {\n const dimensionsToDisplayOnProductCard = context.app.config.dimensionsInProductCard;\n if (!ArrayExtensions.hasElements(dimensionsToDisplayOnProductCard) ||\n dimensionsToDisplayOnProductCard.includes(DimensionTypes.none) ||\n !dimensionsToDisplayOnProductCard.includes(dimensionType)) {\n return false;\n }\n }\n\n const dimensionsToDisplayAsSwatch = context.app.config.dimensionsAsSwatchType;\n return ArrayExtensions.hasElements(dimensionsToDisplayAsSwatch) &&\n !dimensionsToDisplayAsSwatch.includes(DimensionTypes.none) &&\n dimensionsToDisplayAsSwatch.includes(dimensionType);\n};\n\n/**\n * Generates an image URL for a swatch.\n * @param imageUrl - The image url returned by Retail Server.\n * @param apiSettings - The request context.\n * @returns Full image url.\n */\nexport const generateSwatchImageUrl = (imageUrl: string, apiSettings: ICommerceApiSettings): string => {\n if (imageUrl.startsWith('http')) {\n return imageUrl;\n }\n\n return apiSettings.baseImageUrl + encodeURIComponent(imageUrl);\n};\n\n/**\n * Generates a Image URL for a product based on data return from retail server.\n * @param product The Product returned by Retail Server.\n * @param ctx The request context.\n * @param apiSettings\n */\nexport const generateProductImageUrl = (\n product: SimpleProduct | ProductSearchResult,\n apiSettings: ICommerceApiSettings\n): string | undefined => {\n return generateImageUrl(product.PrimaryImageUrl, apiSettings);\n};\n\n/**\n * Creates a CartLine object from the passed data.\n * @param product The product.\n * @param quantity The quantity.\n * @param catalogId The catalog.\n */\nexport const buildCartLine = (product: SimpleProduct, quantity?: number, catalogId?: number): CartLine => {\n return {\n CatalogId: catalogId || 0,\n Description: product.Description,\n\n // TODO: Investigate this value and what it represents\n EntryMethodTypeValue: 3,\n ItemId: product.ItemId,\n ProductId: product.RecordId,\n Quantity: quantity || 1,\n TrackingId: '',\n UnitOfMeasureSymbol: product.DefaultUnitOfMeasure\n };\n};\n\n/**\n * Creates a CommerceListLine (also know as WishlistLine) object from the passed data.\n * @param productId The RecordId of the Product to be added.\n * @param customerId The account number of the customer.\n * @param wishlistId The Id of the commerce list.\n */\nexport const buildWishlistLine = (productId: number, customerId: string, wishlistId: number): CommerceListLine => {\n return {\n CommerceListId: wishlistId,\n ProductId: productId,\n CustomerId: customerId\n };\n};\n\n/**\n * Utility function to prepare the product details criteria before getting full product:\n * @param inputData The Action Input data\n */\nexport const getProductDetailsCriteriaFromActionInput = (inputData: ICreateActionContext>): ProductDetailsCriteria => {\n if (inputData && inputData.config) {\n return {\n getPrice: !inputData.config.hidePrice,\n getRating: !inputData.config.hideRating\n };\n }\n return {\n getPrice: true,\n getRating: true\n };\n};\n\n/**\n * Transforms search text into the expected 'search terms' format, expected by refiner APIs.\n * @param searchText Free-form text used for searching for products or categories of products.\n */\nexport const ensureSearchTextIsFormedProperly = (searchText: string): string => {\n const prefix = searchText.startsWith('\\'') ? '' : '\\'';\n const suffix = searchText.endsWith('\\'') ? '' : '\\'';\n return `${prefix}${searchText}${suffix}`;\n};\n\nexport const ensureSafeSearchText = (searchText: string): string => {\n return searchText.replace(/[^\\d\\sA-Za-z]+/g, '');\n};\n\nexport const buildCacheKey = (base: string, apiSettings: ICommerceApiSettings, locale?: string): string => {\n return `${base}-chanId:${apiSettings.channelId}-catId:${apiSettings.catalogId}${locale ? `-${locale}` : ''}`;\n};\n\nexport const buildCacheKeyWithUrlTokens = (base: string, requestContext: IRequestContext): string => {\n const urlTokens = requestContext.urlTokens;\n const defaultCacheKey = buildCacheKey(base, requestContext.apiSettings, requestContext.locale);\n return urlTokens ? `${defaultCacheKey}-${urlTokens.itemId}-${urlTokens.recordId}-${urlTokens.pageType}` : defaultCacheKey;\n};\n\n/**\n * Generates a key from set of arguments as inputs.\n *\n * @param args Argument list of pivots to generate key from.\n * @param handler Handler function for null/undefined values.\n */\n\ntype TKeyTypes = string | number | boolean | null | undefined;\ninterface IGenerateKeyOptions {\n separator?: string;\n handler?(input: null | undefined): string;\n}\nexport const generateKey = (args: TKeyTypes[], options?: IGenerateKeyOptions): string => {\n const { handler, separator }: IGenerateKeyOptions = { ...{ separator: '-', handler: undefined }, ...(options || {}) };\n return args\n .map(arg => {\n if (arg === null || arg === undefined) {\n if (handler) {\n return handler(arg);\n }\n }\n return arg;\n })\n .join(separator);\n};\n\n/**\n * Gets the fall back image url for a variant image.\n * @param itemId Item id of a product.\n * @param apiSettings Api setting from request context.\n */\nexport const getFallbackImageUrl = (itemId: string | undefined, apiSettings: ICommerceApiSettings): string | undefined => {\n if (!itemId) {\n return '';\n }\n\n const parsedItemId = itemId.trim().split(' ')[0];\n\n const productUrl = `Products/${parsedItemId}_000_001.png`;\n return generateImageUrl(productUrl, apiSettings);\n};\n\n/**\n * Converts retail proxy product dimension type to display dimension type.\n * @param productDimensionType - Product dimension type from retail proxy.\n * @returns Local dimension type.\n */\nexport const convertProductDimensionTypeToDimensionTypes = (productDimensionType: ProductDimensionType): DimensionTypes => {\n switch (productDimensionType) {\n case ProductDimensionType.Color:\n return DimensionTypes.color;\n case ProductDimensionType.Configuration:\n return DimensionTypes.configuration;\n case ProductDimensionType.Size:\n return DimensionTypes.size;\n case ProductDimensionType.Style:\n return DimensionTypes.style;\n default:\n return DimensionTypes.none;\n }\n};\n\n/**\n * Converts display dimension type to retail proxy product dimension type.\n * @param dimensionType - Local dimension type.\n * @returns Product dimension type from retail proxy.\n */\nexport const convertDimensionTypeToProductDimensionType = (dimensionType: DimensionTypes): ProductDimensionType => {\n switch (dimensionType) {\n case DimensionTypes.color:\n return ProductDimensionType.Color;\n case DimensionTypes.configuration:\n return ProductDimensionType.Configuration;\n case DimensionTypes.size:\n return ProductDimensionType.Size;\n case DimensionTypes.style:\n return ProductDimensionType.Style;\n default:\n return ProductDimensionType.None;\n }\n};\n\n/**\n * Sets dimensions to url.\n * @param inputUrl - Url to update.\n * @param productDimensions - Dimensions to set.\n */\nexport const setDimensionValuesToQuery = (inputUrl: URL, productDimensions: ProductDimension[]): void => {\n for (const dimension of productDimensions) {\n inputUrl.searchParams.set(\n convertProductDimensionTypeToDimensionTypes(dimension.DimensionTypeValue), dimension.DimensionValue?.Value ?? '');\n }\n\n if (msdyn365Commerce.isBrowser) {\n window.history.replaceState(window.history.state, '', inputUrl.toString().replace(inputUrl.host, window.location.host));\n }\n};\n\n/**\n * Retrieves dimension value stored in url.\n * @param urlParameters - Url parameters.\n * @param productDimensionType - The dimension type to retrieve.\n * @returns Product dimension item.\n */\nconst parseDimensionFromUrl = (urlParameters: URLSearchParams, productDimensionType: ProductDimensionType): ProductDimension | undefined => {\n const localDimensionType = convertProductDimensionTypeToDimensionTypes(productDimensionType);\n const value = urlParameters.get(localDimensionType);\n if (!value) {\n return undefined;\n }\n return {\n DimensionTypeValue: productDimensionType,\n DimensionValue: {\n RecordId: 0,\n Value: value\n }\n };\n};\n\n/**\n * Retrieves all dimensions from URL.\n * @param urlParameters - Url parameters.\n * @returns Product dimensions stored in url.\n */\nconst parseDimensionsFromUrl = (urlParameters: URLSearchParams): ProductDimension[] => {\n const dimensionsToParse: ProductDimensionType[] = [\n ProductDimensionType.Color,\n ProductDimensionType.Configuration,\n ProductDimensionType.Size,\n ProductDimensionType.Style\n ];\n const parsedDimensions = dimensionsToParse.map(dimension => parseDimensionFromUrl(urlParameters, dimension));\n return ArrayExtensions.validValues(parsedDimensions);\n};\n\n/**\n * Utility function to extract the dimension values from input url querystring.\n * @param inputUrl - The request url.\n * @returns The selected dimension values.\n */\nexport const getDimensionValuesFromQuery = (inputUrl: URL): ProductDimension[] => {\n const urlWithIgnoredCase = new URL(inputUrl.toString().toLocaleLowerCase());\n const urlParameters = urlWithIgnoredCase.searchParams;\n const dimensions: ProductDimension[] = parseDimensionsFromUrl(urlParameters);\n return dimensions;\n};\n\n/**\n * Get attribute values by channel inventory configuration.\n * @param attributeValues - The attributeValues.\n * @param channelInventoryConfiguration - The channelInventoryConfiguration.\n * @returns The attributeValues filter by channel inventory configuration.\n */\nexport const getAttributeValuesByConfiguration = (\n attributeValues: AttributeValue[] | null, channelInventoryConfiguration: ChannelInventoryConfiguration | null): AttributeValue[] => {\n if (!attributeValues) {\n return [];\n }\n if (!channelInventoryConfiguration) {\n return attributeValues;\n }\n\n return attributeValues.filter(attribute => (attribute.RecordId !== channelInventoryConfiguration.InventoryProductAttributeRecordId &&\n attribute.RecordId !== channelInventoryConfiguration.ProductAvailabilitySortableAttributeRecordId));\n};\n","/*--------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * See License.txt 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 /**\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): 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\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\n if (productAvailability.ProductAvailableQuantity.ProductId &&\n !productAvailabilityMap.has(productAvailability.ProductAvailableQuantity.ProductId)) {\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 = (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","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","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","searchCriteria","createInventoryAvailabilitySearchCriteria","shippingProductAvailabilities","getEstimatedAvailabilityAsync","bypassCache","ProductWarehouseInventoryAvailabilities","mapAggregatedProductInventoryInformation","bopisItem","productWarehouse","InventLocationId","WarehouseId","InventLocationDataAreaId","DataAreaId","quantityUnitTypeSales","getProductWarehouseAvail","getEstimatedProductWarehouseAvailabilityAsync","queryResultSettings","productWarehouseMapping","mapProductInventoryInformation","getAvailabilitiesForCartLineItemsDataAction","CatalogsInput","customerAccountNumber","channelId","locale","Number","createCatalogsInput","getCatalogAction","CatalogsDataActions","getCatalogActionDataAction","CategoriesInput","mappedToHierarchy","maxItems","sitePath","catalogId","_mappedToHierarchy","getLocale","getCatalogId","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","getSelectedProductIdFromActionInput","getCategoryPathsAction","categoryPathResults","getCategoryPathsAsync","QueryResultSettingsProxy","CategoryPath","categoryUrl","getCategoriesUrlSync","slice","getCategoryPathsActionDataAction","GetChannelDeliveryConfigurationInput","accountNumber","GetCheckoutCartInput","CartCookieName","msdyn365Commerce","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","cacheType","getCustomerActionDataAction","CustomersDataActions","ProductDeliveryOptionsForCartLineItems","getDeliveryOptionsForCartLineItems","ProductsDataActions","message","getDeliveryOptionsForCartLineItemsDataAction","GetDeliveryOptionsForSelectedVariantInput","selectedProduct","customerId","createDeliveryOptionsForSelectedVariantInput","getDeliveryOptionsForSelectedVariantAction","Promise","resolve","activeProduct","selectedVariantInput","SelectedVariantInput","getSelectedVariant","productResult","getDeliveryOptionsAsync","ItemTypeValue","ReleasedProductType","FilterDeliveryModeOption","getDeliveryOptionsForSelectedVariantActionDataAction","DimensionAvailabilitiesForProductSearchResultInput","dimensionContext","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","masterProductId","warning","requestDimensionType","inputs","promise","shippingInventoryConfiguration","RequestedDimensionTypeValue","MatchingDimensionValues","DefaultWarehouseOnly","FilterByChannelFulfillmentGroup","DeliveryModeTypeFilterValue","all","productsDimensions","productDimension","GetDimensionsForSelectedVariantInput","matchingDimensionValues","getDimensionsForSelectedVariantAction","activeProducts","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","productInventoryInformation","productWarehouseInformation","getOrgUnitLocationsByAreaAsync","DeliveryModeTypeFilter","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","productDetailsCriteria","getProductDetailsCriteriaFromActionInput","FullProductsRefineSearchByTextInput","searchText","getRefinedProducts","getRefinedFullProducts","refineSearchByTextAsync","searchInputData","parseSearchData","q","getPrice","getRating","generateKey","_getActivePrices","validProductIds","productCollection","projectDomain","validInputs","Boolean","affiliations","getCartFromCustomer","AffiliationLines","getActivePricesAsync","Date","productPrice","fullProduct","ProductDetails","versionLt","retailServerProxyVersion","CustomerContextualPrice","AdjustedPrice","ProductPrice","_getProductRatings","getProductRatingsAsync","productRating","ProductRating","productInputs","ProductInput","getSimpleProducts","Set","ratingsAndPricePromises","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","PriceForProductSearchResultInput","productRecIds","affiliation","productPrices","productResults","activePrice","price","Price","BasePrice","Math","max","TradeAgreementPrice","PriceForSelectedVariantInput","createActivePriceForSelectedVariantInput","getPriceForSelectedVariantAction","featureStates","ProductTypeValue","ProductType","getPriceForSelectedVariantActionDataAction","ProductAvailabilitiesForSelectedVariantInput","createProductAvailabilitiesForSelectedVariantInput","getProductAvailabilitiesForSelectedVariantAction","enableStockCheck","shippingSearchCriteria","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","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","getRatingsSummaryDataAction","inputIsValid","sendRequest","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","getSelectedVariantActionDataAction","hasUnmatchedDimension","matchedTargetDimension","targetDimension","checkIfHasUnmatchedDimensions","newImageUrl","generateProductImageUrl","PrimaryImageUrl","fullDimensions","fullDimensionPromises","getFullDimensions","ProductIds","variantProductId","variantImageUrl","getProductVariant","matchedTargetDimensionFromApi","warehouseId","getSimpleProductsAction","productIdMapping","getProductPromises","catalogIds","getByIdsAsync","mappedProducts","GetOrgUnitLocationsByAreaInput","_Latitude","_Longitude","_Radius","createGetOrgUnitLocationsByAreaInput","getOrgUnitLocationsByArea","locationPromiseList","_getLocationWithHours","getOrgUnitLocationsByAreaDataAction","retailActionDataAction","createGetByCustomerInput","GetInvoiceDetailsInput","invoiceId","CreateGetInvoiceDetailsInput","getInvoiceDetails","InvoiceId","SalesOrdersDataActions","getInvoiceDetailsDataAction","GetInvoicesInput","CreateGetInvoicesInput","InvoicePaidStatusValues","InvoicePaidStatus","getInvoices","InvoiceTypeValues","InvoiceType","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","concat","refreshCart","CreateOrderTemplateInput","createProductListAsync","GetFullOrderTemplateInput","inputParams","GetOrderTemplatesInput","getOrderTemplates","OrderTemplate","GetFullOrderTemplatesInput","orderTemplates","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","topHint","skipHint","sortingHintData","column","ColumnName","IsDescending","sortingHint","fromModuleData","sortingCriteria","top","defaultPageSizeForAPI","name","sep","neutralizedName","candidateName","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","hasElements","ObjectExtensions","validValues","values","from","predicate","arrayLine","firstArray","secondArray","comparator","JSON","stringify","valueFromFirstArray","valueFromSecondArray","some","otherItem","array","newArray","EnumExtensions","StringExtensions","enumClass","getNumericValues","isNullOrEmpty","args","rnr","getRnrAuthEndpointId","endpoint","proxyUrl","endsWith","substring","InventoryLevels","totalAvailable","TotalAvailableInventoryLevelCode","physicalAvailable","PhysicalAvailableInventoryLevelCode","getInventoryLevelCodeFromProductAvailability","productAvailability","displayLabelEnabled","inventoryCode","inventoryRanges","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","byteToHex","i","arr","offset","arguments","validate","TypeError","options","buf","rnds","random","Guid","Random","uuidv4","_guid","EmailRegex","html5EmailRegex","PasswordRegex","PhoneRegex","imageUrl","generateImageUrlFromSdk","DimensionTypes","DimensionSwatchDisplayTypes","dimensionType","displayType","default","productCard","dimensionsToDisplayOnProductCard","dimensionsInProductCard","none","dimensionsToDisplayAsSwatch","dimensionsAsSwatchType","generateSwatchImageUrl","startsWith","baseImageUrl","buildWishlistLine","wishlistId","CommerceListId","hidePrice","hideRating","base","buildCacheKeyWithUrlTokens","defaultCacheKey","separator","arg","getFallbackImageUrl","parsedItemId","productUrl","convertProductDimensionTypeToDimensionTypes","productDimensionType","color","configuration","size","style","convertDimensionTypeToProductDimensionType","setDimensionValuesToQuery","inputUrl","productDimensions","searchParams","window","history","replaceState","state","host","location","parseDimensionsFromUrl","urlParameters","parsedDimensions","localDimensionType","parseDimensionFromUrl","URL","getAttributeValuesByConfiguration","attributeValues","channelInventoryConfiguration","attribute","InventoryProductAttributeRecordId","ProductAvailabilitySortableAttributeRecordId","validateCartLinesInventory","actionContext","emailDeliveryModeCode","cartLineMap","isValid","productIdWithErrors","IsInvoiceLine","IsGiftCardLine","cartLineTotal","delete","productAvailabilityMap","cartLineQty","availableQuantity","cartLineProduct","isStockedItem","Behavior","IsStockedProduct","isEmailDelivery"],"sourceRoot":""}