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IACvCD,EAASE,aAAaxqB,IAClB8pB,EAA4CxsB,EAAUC,oBAD1D,oBAC+ED,EAAUxB,sBADzF,aAC+E,EAA0BC,aADzG,QACkH,IAGtH0uB,OAAOC,QAAQC,aAAaF,OAAOC,QAAQE,MAAO,GAAIN,EAASz1B,WAAWwpB,QAAQiM,EAASO,KAAMJ,OAAOK,SAASD,QA6B/GE,EAA0BC,IAC5B,MAMMC,EAN4C,CAC9C/vB,EAAAA,qBAAAA,MACAA,EAAAA,qBAAAA,cACAA,EAAAA,qBAAAA,KACAA,EAAAA,qBAAAA,OAEuC3Q,KAAI+S,GA3BrB,EAAC0tB,EAAgCjB,KAC3D,MAAMmB,EAAqBpB,EAA4CC,GACjEluB,EAAQmvB,EAAc5Y,IAAI8Y,GAChC,GAAKrvB,EAGL,MAAO,CACH0B,mBAAoBwsB,EACpBjuB,eAAgB,CACZtP,SAAU,EACVuP,MAAOF,KAiB6CsvB,CAAsBH,EAAe1tB,KACjG,OAAOtU,EAAAA,GAAAA,YAA4BiiC,IAQ1BntB,EAA+BwsB,IACxC,MACMU,EADqB,IAAII,IAAId,EAASz1B,WAAWmG,qBACdwvB,aAEzC,OADuCO,EAAuBC,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-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-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/object-extensions.ts?6388","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/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"],"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);\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, getFeatureStateAction } 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 getFeatureStateAction(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 (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 { CategoryHierarchy } from '@msdyn365-commerce/commerce-entities';\nimport { CacheType, createObservableDataAction, 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 sitePath: string;\n\n private readonly _mappedToHierarchy: boolean;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n private readonly locale?: string;\n\n 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 }\n\n public getCacheKey = () => buildCacheKey(`${this.channelId}|${this.sitePath}|top-${this.maxItems || 250}`, 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, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric, IRequestContext } from '@msdyn365-commerce/core';\nimport { getCategoriesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CategoriesDataActions.g';\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 _mappedToHierarchy: boolean;\n\n 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 ? Number(context.apiSettings.channelId) : 0;\n }\n\n public getCacheKey = () => `${this.channelId}|top-${this.maxItems || 250}`;\n\n public getCacheObjectType = () => (this._mappedToHierarchy ? 'CategoryHierarchy' : 'Category');\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 createCategoriesInput = (inputData: ICreateActionContext>): IActionInput => {\n const topItems = inputData.config && 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\n * @param ctx\n */\nexport async function getCategoryAction(input: CategoriesInput, ctx: IActionContext): Promise {\n return (getCategoriesAsync({ callerContext: ctx }, input.channelId));\n}\n\nexport const getCategoryActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce-modules/retail-actions/get-categories',\n action: >getCategoryAction,\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, 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 { 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 = context.apiSettings.catalogId || 0;\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({ callerContext: ctx }, 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, ICommerceApiSettings, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { Customer } from '@msdyn365-commerce/retail-proxy';\nimport { readAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g';\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 constructor(apiSettings: ICommerceApiSettings, accountNumber?: string) {\n this.customerAccountNumber = accountNumber;\n this.apiSettings = apiSettings;\n }\n\n public getCacheKey = () => buildCacheKey(`Customer-${this.customerAccountNumber}`, this.apiSettings);\n\n public getCacheObjectType = () => 'Customer';\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>): 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\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 readAsync({ callerContext: ctx }, 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\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, IAny, ICommerceApiSettings, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { getCartState } from '@msdyn365-commerce/global-state';\nimport { ProductAvailableQuantity, ProductDeliveryOptions } from '@msdyn365-commerce/retail-proxy';\nimport { getDeliveryOptionsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n\nimport { ActiveCartProductsInput, buildCacheKey, getActiveCartProductsAction } from '.';\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 getDeliveryOptionsAsync({ callerContext: ctx, queryResultSettings: {} }, 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, getFeatureStateAction } from './get-feature-state';\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 getFeatureStateAction(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\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: {} },\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';\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 }\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 { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { ProductDimensionAvailabilitySearchCriteria, ProductDimensionType, ProductDimensionValueInventoryAvailability, ProductsDataActions\n} from '@msdyn365-commerce/retail-proxy';\n\nimport { ArrayExtensions } from './utilities';\nimport { createInventoryAvailabilitySearchCriteria } from './utilities/product-inventory-utils';\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 constructor(masterProductId: number, requestDimensionType: ProductDimensionType) {\n this.masterProductId = masterProductId;\n this.requestDimensionType = requestDimensionType;\n\n }\n\n /**\n * Cache key.\n * @returns String.\n */\n public getCacheKey: () => string = () => `MasterProductId-${this.masterProductId.toString()}-DimensionType-${this.requestDimensionType}-Availabilities`;\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 });\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 };\n\n const dimensionValuesPromise = ProductsDataActions.getDimensionValuesWithEstimatedAvailabilitiesAsync(\n { callerContext: context, queryResultSettings: {} },\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, IAction, IActionContext, IActionInput,\n IAny, ICreateActionContext, IGeneric\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 { 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 constructor(productId: number, channelId: number, matchingDimensionValues?: ProductDimension[]) {\n this.productId = productId;\n this.channelId = channelId;\n this.matchingDimensionValues = matchingDimensionValues || [];\n }\n\n /**\n * Cache key.\n * @returns String.\n */\n public getCacheKey: () => string = () => `DimensionsForSelectedVariantInput-${this.productId}-${this.channelId}`;\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 }\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 activeProduct = await ProductsDataActions.getByIdAsync({ callerContext: context }, input.productId, input.channelId);\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 };\n\n const dimensionValuesPromise = ProductsDataActions.getDimensionValuesWithEstimatedAvailabilitiesAsync(\n { callerContext: context, queryResultSettings: {} },\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 } from '@msdyn365-commerce/retail-proxy';\nimport { getFeatureStatesAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\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 ];\n\n public getCacheKey = () => 'FeatureState';\n\n public getCacheObjectType = () => 'FeatureState';\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 */\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 */\nexport async function getFeatureStateAction(input: FeatureStateInput, ctx: IActionContext): Promise {\n const featureState = await getFeatureStatesAsync({ callerContext: 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,\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, getFeatureStateAction } 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';\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 getFeatureStateAction(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({ callerContext: ctx }, 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({ callerContext: ctx }, 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 { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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 catalogId = inputData.requestContext.apiSettings.catalogId;\n const productDetailsCriteria = getProductDetailsCriteriaFromActionInput(inputData);\n return new FullProductsRefineSearchByCategoryInput(\n queryResultSettingsProxy,\n categoryId,\n +channelId,\n refinementCriteria,\n catalogId,\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 let refinementCriteria: ProductRefinerValue[] = [];\n const fullProductInputs = await refineSearchByCategoryAsync(\n { callerContext: ctx, queryResultSettings: input.queryResultSettingsProxy.QueryResultSettings },\n input.channelId || 0,\n input.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());\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 { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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 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 catalogId = inputData.requestContext.apiSettings.catalogId;\n const productDetailsCriteria = getProductDetailsCriteriaFromActionInput(inputData);\n\n return new FullProductsRefineSearchByTextInput(\n queryResultSettingsProxy,\n searchInputData.q,\n searchInputData.channelId,\n refinementCriteria,\n catalogId,\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 return getRefinedFullProducts(\n input,\n ctx,\n () => {\n return refineSearchByTextAsync(\n { callerContext: ctx, queryResultSettings: input.queryResultSettingsProxy.QueryResultSettings },\n input.channelId || 0,\n input.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(product.RecordId, apiSettings, input.productDetailsCriteria || new ProductDetailsCriteria());\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 { versionLt } from '@msdyn365-commerce/core-internal';\nimport { 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 { 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 ProductDetailsCriteria: ProductDetailsCriteria;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n constructor(productId: number | string, apiSettings: ICommerceApiSettings, criteria: ProductDetailsCriteria) {\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\n public getCacheKey = () => {\n const { getPrice, getRating } = this.ProductDetailsCriteria;\n return buildCacheKey(generateKey([this.productId, 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);\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);\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 const projectDomain: ProjectionDomain = { ChannelId: +ctx.requestContext.apiSettings.channelId, CatalogId: 0 };\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 return getActivePricesAsync(\n { callerContext: ctx, queryResultSettings: {} },\n projectDomain,\n validInputs,\n new Date(),\n null,\n [],\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 Verison < 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({ callerContext: ctx, queryResultSettings: {} }, 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({ callerContext: ctx, queryResultSettings: {} }, 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(commerceListLine.ProductId, ctx.requestContext.apiSettings, getProductDetailsCriteriaFromActionInput(ctx)));\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));\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 } 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({ callerContext: ctx, queryResultSettings: {} }, 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({ callerContext: ctx }, 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, 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 { 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.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 return new MediaLocationsByIdInput(inputData.requestContext.apiSettings, productId, undefined);\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: {} }, 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, 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';\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\n if (productId) {\n return new MediaLocationsForSelectedVariantInput(+productId, +inputData.requestContext.apiSettings.channelId);\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 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({ callerContext: ctx, queryResultSettings: {} }, 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 } 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';\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 projectDomain: ProjectionDomain = { ChannelId: +context.requestContext.apiSettings.channelId,\n CatalogId: +context.requestContext.apiSettings.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: {} },\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 { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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, getFeatureStateAction } from './get-feature-state';\nimport { ArrayExtensions } from './utilities';\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 affliations: AffiliationLoyaltyTier[] | undefined = [];\n if (ctx.requestContext.user.isAuthenticated) {\n const cart = await getCartFromCustomer(ctx);\n affliations = 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\n return getSelectedVariant(selectedVariantInput, ctx);\n }\n\n return activeProduct;\n })\n .then(async (productResult: SimpleProduct | null) => {\n const projectDomain: ProjectionDomain = {\n ChannelId: +ctx.requestContext.apiSettings.channelId,\n CatalogId: +ctx.requestContext.apiSettings.catalogId\n };\n\n const activeProduct: SimpleProduct | undefined = productResult as SimpleProduct | undefined;\n if (activeProduct) {\n const featureStates: FeatureState[] = await getFeatureStateAction(new FeatureStateInput(), ctx);\n return getActivePricesAsync(\n { callerContext: ctx, queryResultSettings: {} },\n projectDomain,\n [activeProduct.RecordId],\n new Date(),\n input.customerId,\n affliations,\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 ).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 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 { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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';\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 constructor(productId: number, channelId: number) {\n this.productId = productId;\n this.channelId = channelId;\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);\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 activeProduct = await ProductsDataActions.getByIdAsync({ callerContext: context }, input.productId, input.channelId);\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 };\n\n const dimensionValuesPromise = ProductsDataActions.getDimensionValuesWithEstimatedAvailabilitiesAsync(\n { callerContext: context, queryResultSettings: {} },\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 }\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);\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, 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(cartLine.ProductId, ctx.requestContext.apiSettings);\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.ProductId!)\n ) : productIdsByWarehouseId.set(cartLine.WarehouseId!, [cartLine.ProductId!]))\n );\n return Promise.all([...productIdsByWarehouseId].map(([entryWarehouseId, entryProductIds]) => {\n return getSimpleProducts(\n entryProductIds.map(productId => {\n if (productId) {\n return new ProductInput(productId,\n ctx.requestContext.apiSettings,\n undefined,\n entryWarehouseId);\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, 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 = inputData.config ? Number(inputData.config.catalogId) : 0;\n const currentCategory = new CurrentCategoryInput(inputData.requestContext);\n\n return new RefinersByCategoryInput(\n currentCategory,\n QueryResultSettingsProxy.fromInputData(inputData),\n Number.isNaN(catalogId) ? 0 : 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 { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } 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 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 = inputData.requestContext.apiSettings.catalogId;\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 if (Number.isNaN(catalogId)) {\n throw new Error('Failed to cast catalog id into a number.');\n }\n\n const queryResultSettingsProxy = QueryResultSettingsProxy.fromInputData(inputData);\n return new GetRelatedProductsInput(productId, catalogId, relationType, queryResultSettingsProxy, productDetailsCriteria);\n }\n\n throw new Error('Invalid input data or request context');\n};\n\nexport function searchProductRelationType(productRelationTypes: ProductRelationType[], _productRelationType: string): number | undefined {\n let foundProductRelationTypeId;\n _productRelationType = _productRelationType.toLowerCase();\n productRelationTypes.forEach((productRelationType: ProductRelationType) => {\n if (productRelationType.Name && productRelationType.Name.toLowerCase() === _productRelationType) {\n return (foundProductRelationTypeId = productRelationType.RecordId);\n }\n });\n\n return foundProductRelationTypeId;\n}\n\nasync function getRelatedProductsAction(input: GetRelatedProductsInput, ctx: IActionContext): Promise {\n const apiSettings = ctx.requestContext.apiSettings;\n const querySettings = input.queryResultSettingsProxy.QueryResultSettings;\n\n const productRelationTypes = await getRelationTypesAsync(\n { callerContext: ctx, queryResultSettings: querySettings },\n input.productId,\n +apiSettings.channelId,\n input.catalogId\n );\n if (!productRelationTypes) {\n ctx.trace(`[getProductRelationType] Unable to get product relation types for product ${input.productId}`);\n return [];\n }\n const productRelationTypeId = searchProductRelationType(productRelationTypes, input.relationType);\n if (!productRelationTypeId) {\n ctx.trace(`[getRelatedProducts] Unable to find relation type ${input.relationType} for product ${input.productId}`);\n return [];\n }\n\n const productInputs = await getRelatedProductsAsync(\n { callerContext: ctx, queryResultSettings: querySettings },\n input.productId,\n +apiSettings.channelId,\n input.catalogId,\n productRelationTypeId\n )\n .then(response => {\n if (response && response.length > 0) {\n return response.map(\n (product: ProductSearchResult): FullProductInput => {\n return new FullProductInput(product.RecordId, apiSettings, input.ProductDetailsCriteria);\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), 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 { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICreateActionContext, IGeneric } from '@msdyn365-commerce/core';\nimport { BypassCache, ProductDimension, ProductDimensionAvailabilitySearchCriteria, ProductsDataActions, SimpleProduct } from '@msdyn365-commerce/retail-proxy';\n\nimport { ArrayExtensions } from './utilities';\nimport { createInventoryAvailabilitySearchCriteria } from './utilities/product-inventory-utils';\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 constructor(productId: number, channelId: number, matchingDimensionValues?: ProductDimension[], bypassCache?: BypassCache) {\n this.productId = productId;\n this.channelId = channelId;\n this.matchingDimensionValues = matchingDimensionValues;\n this.bypassCache = bypassCache;\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 }\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 * @returns Array of dimensions.\n */\nconst getFullDimensions = async (product: SimpleProduct, matchingDimensionValues: ProductDimension[], context: IActionContext) => {\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 };\n const dimensionValuesPromise = ProductsDataActions.getDimensionValuesWithEstimatedAvailabilitiesAsync(\n { callerContext: context, queryResultSettings: {} },\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 productVariant = await ProductsDataActions.getByIdAsync(\n { callerContext: context, bypassCache: input.bypassCache }, variantProductId, input.channelId);\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 let product = await ProductsDataActions.getByIdAsync(\n { callerContext: context, bypassCache: input.bypassCache }, input.productId, input.channelId);\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);\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 { CacheType, createObservableDataAction, IAction, IActionContext, IActionInput, IAny, ICommerceApiSettings, ICreateActionContext, IDictionary, IGeneric } 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 { 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 private readonly apiSettings: ICommerceApiSettings;\n\n constructor(productId: number | string, apiSettings: ICommerceApiSettings, channelId?: number, warehouseId?: string) {\n this.apiSettings = apiSettings;\n this.productId = +productId;\n this.channelId = channelId || apiSettings.channelId;\n this.warehouseId = warehouseId;\n }\n\n public getCacheKey = () => buildCacheKey(\n `RecordId-${this.productId.toString()}-ChannelId-${this.channelId.toString()}-WahehouseId-${this.warehouseId ?? ''}`,\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 });\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 (!Array.isArray(inputs) || inputs.length === 0) {\n ctx.trace('[getSimpleProductsAction] Invalid or empty inputs passed.');\n return [];\n }\n\n const productIdMapping: IDictionary = {};\n const productIds = inputs.map((input, idx) => {\n productIdMapping[input.productId] = idx;\n return input.productId;\n });\n\n return getByIdsAsync(\n { callerContext: ctx, queryResultSettings: QueryResultSettingsProxy.getDefault().QueryResultSettings },\n inputs[0].channelId,\n productIds,\n inputs[0].warehouseId)\n .then(products => {\n const mappedProducts = products\n .map(product => {\n try {\n const newImageUrl = generateProductImageUrl(product, ctx.requestContext.apiSettings);\n\n if (newImageUrl) {\n product.PrimaryImageUrl = newImageUrl;\n }\n\n return product;\n } catch {\n ctx.trace('[getSimpleProductsAction] Unable to update ImageURL for Product');\n }\n })\n .reduce((memo: SimpleProduct[], product: SimpleProduct | undefined) => {\n if (!product) {\n return memo;\n }\n const idx = productIdMapping[product.RecordId];\n memo[idx] = 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}\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, getFeatureStateAction } from './get-feature-state';\nimport { IFullOrgUnitAvailability } from './utilities/full-org-unit-availability';\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 getFeatureStateAction(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({ callerContext: ctx }, 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({ callerContext: ctx }, 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\nimport { buildQueryResultSettings } from './utilities/utils';\n\nconst createWishlistInput = (inputData: ICreateActionContext) => {\n if (\n inputData.requestContext &&\n inputData.requestContext.user &&\n inputData.requestContext.user.isAuthenticated\n ) {\n return createGetByCustomerInput(buildQueryResultSettings(inputData), 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\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: input.queryResultSettings\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(listLine.ProductId,\n context.requestContext.apiSettings, getProductDetailsCriteriaFromActionInput(context)));\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 get QueryResultSettings(): QueryResultSettings {\n return this.queryResultSettings;\n }\n\n /**\n * Gets the hints for the cache key based on query result settings.\n */\n 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 */\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 */\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 * Factory method.\n */\n public static getDefault(): QueryResultSettingsProxy {\n return new QueryResultSettingsProxy({ Paging: {}, Sorting: {} });\n }\n\n /**\n * Private constructor, expect instances to be created with the factory method.\n * @param queryResultSettings\n */\n private constructor(\n queryResultSettings: QueryResultSettings\n ) {\n this.queryResultSettings = 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 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\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 { 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 * 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\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 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 = 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 = 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 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 { IAny, ICommerceApiSettings, ICoreContext, ICreateActionContext, IGeneric, IRequestContext } from '@msdyn365-commerce/core';\nimport {\n AsyncResult, CartLine, 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 if (imageUrl) {\n // Images hosted in CMS include schema\n if (imageUrl.startsWith('http')) {\n return imageUrl;\n }\n\n // Images hosted in Retail Server must be encoded and joined with the base image url\n return apiSettings.baseImageUrl + encodeURIComponent(imageUrl);\n }\n\n // D365Commerce.telemetry.warning(`Unable to generate a proper Image URL for Product: ${product.RecordId}`);\n return undefined;\n\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 window.history.replaceState(window.history.state, '', inputUrl.toString().replace(inputUrl.host, window.location.host));\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"],"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","getFeatureStateAction","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","CategoriesInput","mappedToHierarchy","maxItems","channelId","sitePath","locale","_mappedToHierarchy","getLocale","mapCategoryToHierarchy","categoryList","categoryMap","reduce","memo","category","localName","nameTranslations","nameTranslation","Language","toLowerCase","Text","getFriendlyName","NameTranslations","categoryHierarchy","NeutralizedName","zeroCategory","Object","keys","forEach","element","parentId","ParentCategory","Url","getCategoryUrl","parent","Children","createCategoriesHierarchyInput","topItems","config","topCategories","Number","parseInt","getCategoryHierarchyAction","categories","getCategoryAction","RawCategoriesInput","getCategoryHierarchyActionDataAction","getCategoriesAsync","GetCategoryPathsInput","categoryPathLooksups","constructedCacheKey","ChannelId","CatalogId","catalogId","categoryPath","toString","createGetCategoryPathsInput","getSelectedProductIdFromActionInput","getCategoryPathsAction","categoryPathResults","getCategoryPathsAsync","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","customerAccountNumber","createGetCustomerBalanceInput","getCustomerBalanceAction","getCustomerBalanceAsync","InvoiceAccount","getCustomerBalanceActionDataAction","retailAction","createGetCustomerLoyaltyCardsInput","getCustomerActionDataAction","readAsync","ProductDeliveryOptionsForCartLineItems","getDeliveryOptionsForCartLineItems","getDeliveryOptionsAsync","message","getDeliveryOptionsForCartLineItemsDataAction","GetDeliveryOptionsForSelectedVariantInput","selectedProduct","customerId","createDeliveryOptionsForSelectedVariantInput","getDeliveryOptionsForSelectedVariantAction","Promise","resolve","activeProduct","selectedVariantInput","SelectedVariantInput","getSelectedVariant","productResult","ItemTypeValue","ReleasedProductType","FilterDeliveryModeOption","getDeliveryOptionsForSelectedVariantActionDataAction","DimensionAvailabilitiesForProductSearchResultInput","dimensionContext","productsDimensionInputs","inventoryLevel","app","product","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","ProductsDataActions","all","productsDimensions","productDimension","GetDimensionsForSelectedVariantInput","matchingDimensionValues","getDimensionsForSelectedVariantAction","Dimensions","promises","dimension","DimensionTypeValue","dimensionValues","dimensionValuesResults","newDimension","oldDimension","DimensionValues","getDimensionsForSelectedVariantActionDataAction","getDimensionValuesFromQuery","url","featureNames","createGetFeatureStateInput","getFeatureStatesAsync","getFeatureStateActionDataAction","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","QueryResultSettingsProxy","productDetailsCriteria","getProductDetailsCriteriaFromActionInput","FullProductsRefineSearchByTextInput","searchText","getRefinedProducts","getRefinedFullProducts","refineSearchByTextAsync","searchInputData","parseSearchData","q","getPrice","getRating","generateKey","_getActivePrices","validProductIds","productCollection","projectDomain","validInputs","Boolean","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","PriceForProductSearchResultInput","productRecIds","getCartFromCustomer","affiliation","AffiliationLines","productPrices","productResults","activePrice","price","Price","BasePrice","Math","max","TradeAgreementPrice","PriceForSelectedVariantInput","createActivePriceForSelectedVariantInput","getPriceForSelectedVariantAction","affliations","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","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","idx","getByIdsAsync","mappedProducts","GetOrgUnitLocationsByAreaInput","_Latitude","_Longitude","_Radius","createGetOrgUnitLocationsByAreaInput","getOrgUnitLocationsByArea","locationPromiseList","_getLocationWithHours","getOrgUnitLocationsByAreaDataAction","retailActionDataAction","createGetByCustomerInput","buildQueryResultSettings","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","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","ObjectExtensions","EnumExtensions","StringExtensions","hasElements","isNullOrUndefined","validValues","from","predicate","arrayLine","firstArray","secondArray","comparator","JSON","stringify","valueFromFirstArray","valueFromSecondArray","some","otherItem","array","newArray","enumClass","getNumericValues","isNumber","isString","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","PhysicalAvailable","StockLevelCode","StockLevelLabel","PhysicalAvailableInventoryLevelLabel","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","startsWith","baseImageUrl","DimensionTypes","DimensionSwatchDisplayTypes","dimensionType","displayType","default","productCard","dimensionsToDisplayOnProductCard","dimensionsInProductCard","none","dimensionsToDisplayAsSwatch","dimensionsAsSwatchType","generateSwatchImageUrl","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"],"sourceRoot":""}