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WC,OAAO,EAAMkB,MAAM,EAAMjB,SAP5BU,GAA4B/B,GAAM,WAEpDqC,EAAgC,QAAErY,KAAK,CAAEvF,KAAM,eAA+B,mBAKT,CACrE,QAAW,SAAU8d,GACnB,IAAIC,EAAIN,EAAmBld,KAAMgd,EAAW,YACxCS,EAAaR,EAAWM,GAC5B,OAAOvd,KAAKP,KACVge,EAAa,SAAUd,GACrB,OAAOQ,EAAeK,EAAGD,KAAa9d,MAAK,WAAc,OAAOkd,MAC9DY,EACJE,EAAa,SAAUtQ,GACrB,OAAOgQ,EAAeK,EAAGD,KAAa9d,MAAK,WAAc,MAAM0N,MAC7DoQ,OAMLT,GAAWG,EAAWF,GAA2B,CACpD,IAAIW,EAASV,EAAW,WAAWxiB,UAAmB,QAClD6iB,EAAgC,UAAMK,GACxCN,EAAcC,EAAwB,UAAWK,EAAQ,CAAEC,QAAQ","sources":["webpack://henrys-ecommerce/../../src/action-registrar.ts?ed12","webpack://henrys-ecommerce/../../src/create-data-action.vnext.ts?cb4f","webpack://henrys-ecommerce/../../src/wrap-data-action.ts?c6a2","webpack://henrys-ecommerce/../../src/action-error.ts?76a5","webpack://henrys-ecommerce/../../src/action-runtime-utils.ts?df0b","webpack://henrys-ecommerce/../../../src/cache/retail-cache-helper.ts?35f4","webpack://henrys-ecommerce/../../src/event-emitter.ts?da67","webpack://henrys-ecommerce/../../src/action-executor.ts?e3c4","webpack://henrys-ecommerce/../../../src/actions/get-catalogs.ts?b35c","webpack://henrys-ecommerce/../../src/helpers.ts?e5d2","webpack://henrys-ecommerce/../../src/action-context.ts?0ab9","webpack://henrys-ecommerce/../../src/mock-helper.ts?6126","webpack://henrys-ecommerce/../../../src/actions/get-media-locations.ts?b49d","webpack://henrys-ecommerce/../../../src/actions/get-additional-media-locations.ts?d6e0","webpack://henrys-ecommerce/../../../src/actions/get-customer.ts?6b9b","webpack://henrys-ecommerce/../../src/ICache.ts?b706","webpack://henrys-ecommerce/../../src/cache-utils.ts?471a","webpack://henrys-ecommerce/../../src/request-cache.ts?b274","webpack://henrys-ecommerce/../../src/index.ts?0e3e","webpack://henrys-ecommerce/./node_modules/@msdyn365-commerce/bootloader/node_modules/core-js/internals/delete-property-or-throw.js?6dca","webpack://henrys-ecommerce/./node_modules/@msdyn365-commerce/bootloader/node_modules/core-js/internals/engine-ff-version.js?3dd8","webpack://henrys-ecommerce/./node_modules/@msdyn365-commerce/bootloader/node_modules/core-js/internals/engine-is-ie-or-edge.js?ffaa","webpack://henrys-ecommerce/./node_modules/@msdyn365-commerce/bootloader/node_modules/core-js/internals/engine-webkit-version.js?387e","webpack://henrys-ecommerce/./node_modules/@msdyn365-commerce/bootloader/node_modules/core-js/modules/es.array.sort.js?fdbe","webpack://henrys-ecommerce/./node_modules/@msdyn365-commerce/bootloader/node_modules/core-js/modules/es.promise.finally.js?6cd2"],"sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n ActionPostHook,\n ActionPostReaderHook,\n ActionPreHook,\n ActionPreReaderHook,\n IAnyAction,\n msdyn365Commerce\n} from '@msdyn365-commerce/core-internal';\nimport { LogLevel, StaticTelemetry } from '@msdyn365-commerce/telemetry-internal';\n\nconst DEPRECATED_HOOK_TYPES = ['pre', 'post', 'preRead', 'postRead'];\n\nexport namespace ActionRegistrar {\n type ActionHook = ActionPreHook | ActionPostHook;\n\n export type ActionRegistration = {\n action?: IAnyAction;\n pre?: Set;\n post?: Set>;\n preRead?: Set;\n postRead?: Set>;\n preReader?: Set;\n postReader?: Set>;\n };\n\n interface IActionDictionary {\n [actionKey: string]: ActionRegistration;\n }\n\n const dataActionRegister: IActionDictionary = {};\n\n export const getRegistration = (id?: string): ActionRegistration | undefined => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((msdyn365Commerce).getPartnerOverrideAction && id) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const partnerDataAction = (msdyn365Commerce).getPartnerOverrideAction(id);\n if (partnerDataAction && partnerDataAction.default) {\n dataActionRegister[id].action = partnerDataAction.default;\n } else if (partnerDataAction && partnerDataAction.prototype && partnerDataAction.prototype.Action) {\n dataActionRegister[id].action = partnerDataAction;\n }\n }\n\n if (id) {\n return dataActionRegister[id];\n }\n\n return undefined;\n };\n\n export const unwrapAction = (action: IAnyAction): IAnyAction => {\n if (action && action.prototype && !action.prototype.isAction) {\n // registered action is an action wrapper. Unwrap it.\n return >action.prototype.Action;\n }\n return action;\n };\n /**\n * Gets the action registered with id\n * @param id - ID to look up action\n */\n export const getAction = (id?: string): IAnyAction | undefined => {\n if (!id) {\n return;\n }\n const registeredAction = getRegistration(id);\n if (registeredAction) {\n return >registeredAction.action;\n }\n return;\n };\n\n /**\n * registers action. Does nothing if action is already registered\n * @param id - ID to register action with\n * @param action - action to register\n */\n export const registerAction = (id: string, dataAction: IAnyAction): IAnyAction | undefined => {\n if (!id || !dataAction) {\n // unable to register no id or action\n return;\n }\n\n const actionRegister = dataActionRegister;\n\n if (actionRegister[id]) {\n const registration = actionRegister[id];\n registration.action = dataAction;\n return >actionRegister[id].action;\n } else {\n const registration = { action: dataAction };\n actionRegister[id] = registration;\n return dataAction;\n }\n };\n\n const registerHook = (\n hookType: 'pre' | 'post' | 'preRead' | 'postRead' | 'preReader' | 'postReader'\n ) => (id: string, hook: HookType) => {\n // deprecate read only hook\n if (!msdyn365Commerce.isBrowser && DEPRECATED_HOOK_TYPES.indexOf(hookType) > -1) {\n StaticTelemetry.log(\n LogLevel.Warning,\n `Data action hooks are deprecated and will be removed in later versions. Please use data action overrides to extend data actions. The related action of this ${hookType} hook is - ${id}`\n );\n }\n\n const registration = getRegistration(id);\n // coerce hook into an iterable\n const hooks = Array.isArray(hook) ? hook : [hook];\n if (!registration) {\n // If the registration does not exist init one with just the hooks\n const newRegistration: { [id: string]: unknown } = {};\n newRegistration[hookType] = new Set(hooks);\n dataActionRegister[id] = newRegistration;\n } else {\n // If the registration does exist merge new hooks with existing hooks\n const hookRegistration = registration[hookType] || new Set();\n hooks.forEach(h => {\n hookRegistration.add(h);\n });\n // @ts-ignore\n registration[hookType] = hookRegistration;\n }\n return hook;\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export const registerPostHook = registerHook | ActionPostHook[]>('post');\n export const registerPreHook = registerHook('pre');\n export const registerPreReadOnlyHook = registerHook('preRead');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export const registerPostReadOnlyHook = registerHook | ActionPostHook[]>('postRead');\n export const registerPreReaderHook = registerHook('preReader');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export const registerPostReaderHook = registerHook | ActionPostReaderHook[]>('postReader');\n\n export const getPreHooks = (id: string) => {\n const actionRegistration = getRegistration(id);\n return actionRegistration && actionRegistration.pre;\n };\n\n export const getPostHooks = (id: string) => {\n const actionRegistration = getRegistration(id);\n return actionRegistration && actionRegistration.post;\n };\n\n export const getPreReadHooks = (id: string) => {\n const actionRegistration = getRegistration(id);\n return actionRegistration && actionRegistration.preRead;\n };\n\n export const getPostReadHooks = (id: string) => {\n const actionRegistration = getRegistration(id);\n return actionRegistration && actionRegistration.postRead;\n };\n\n export const getPreReaderHooks = (id: string) => {\n const actionRegistration = getRegistration(id);\n return actionRegistration && actionRegistration.preReader;\n };\n export const getPostReaderHooks = (id: string) => {\n const actionRegistration = getRegistration(id);\n return actionRegistration && actionRegistration.postReader;\n };\n\n /**\n * Resolves the action and returns first action in action chain. Registers action if not yet registered\n * @param id - Action id to look up or register under\n * @param action - Action function\n */\n export const resolveAction = (id: string, action: IAnyAction): IAnyAction | undefined => {\n return getAction(id) || >registerAction(id, action) || action;\n };\n\n export const resolveRegistration = (\n id: string,\n action: IAnyAction,\n preHooks?: ActionPreHook[],\n postHooks?: ActionPostHook[],\n preReadHooks?: ActionPreHook[],\n postReadHooks?: ActionPostHook[],\n preReaderHooks?: ActionPreReaderHook[],\n postReaderHooks?: ActionPostReaderHook[]\n ) => {\n const resolvedAction = resolveAction(id, action);\n if (!resolvedAction) {\n return;\n }\n preHooks && registerPreHook(id, preHooks);\n postHooks && registerPostHook(id, postHooks);\n preReadHooks && registerPreReadOnlyHook(id, preReadHooks);\n postReadHooks && registerPostReadOnlyHook(id, postReadHooks);\n preReaderHooks && registerPreReaderHook(id, preReaderHooks);\n postReaderHooks && registerPostReaderHook(id, postReaderHooks);\n return getRegistration(id);\n };\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IActionContext, IActionInput, IActionWrapperPrototype, IObservableAction } from '@msdyn365-commerce/core-internal';\nimport { AsyncResult } from '@msdyn365-commerce/retail-proxy';\nimport { dataActionOptions, wrapDataAction } from './wrap-data-action';\n\n/**\n * Higher order function which exposes the current method as an action\n * @param action The action method\n * @param isBatched If the service call can handle batched requests efficiently\n * @param input Optional parameter of a single instance or an array of IActionInputs that will be passed to the action method.\n */\nexport const createObservableDataAction = (options: dataActionOptions): IObservableAction => {\n const wrappedAction = wrapDataAction(\n options,\n (arg1: IActionInput | IActionInput[], arg2: IActionContext): AsyncResult => {\n return new AsyncResult((resolve, reject) => {\n arg2.chainAction(options.action, arg1)\n .then(result => {\n resolve(result);\n })\n .catch(error => {\n reject(error);\n });\n });\n }\n );\n (wrappedAction.prototype).setProperty('isObservable', true);\n return >wrappedAction;\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IAction, IActionInput, IObservableAction } from '@msdyn365-commerce/core-internal';\nimport { ActionRegistrar } from './action-registrar';\n\nexport type dataActionOptions = {\n action: IAction;\n isBatched?: boolean;\n id?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n input?: (...args: any[]) => IActionInput | IActionInput[];\n};\n\ntype IActionWrap = IAction | IObservableAction;\n\n/**\n * Wraps a data action with the associated action wrap.\n * @param options\n * @param actionWrap\n */\nexport const wrapDataAction = (options: dataActionOptions, actionWrap: IActionWrap): IActionWrap => {\n if (!options) {\n throw new Error('wrapDataAction called with invalid options. Options should have atleast action defined');\n }\n\n if (!options.action) {\n throw new Error(\n `Received invalid actions when attempting to parse options. Input name: ${options.input ? options.input.name : 'undefined'}`\n );\n }\n\n let inputFunc = options.input!;\n let id = options.id;\n let isBatched = options.isBatched!;\n options.action.prototype = {\n id,\n isBatched,\n isAction: true\n };\n\n actionWrap.prototype = {\n id,\n isAction: false,\n _action: options.action,\n set RegistrationId(registrationId: string) {\n options.action.prototype.RegistrationId = registrationId;\n },\n get RegistrationId(): string {\n return options.action.prototype.RegistrationId || '';\n },\n set inputFunc(func: Function) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (inputFunc) = func;\n },\n get inputFunc(): Function {\n return inputFunc;\n },\n get isBatched(): boolean {\n return isBatched;\n },\n set isBatched(_isBatched: boolean) {\n isBatched = _isBatched;\n },\n get Action(): IAction {\n return options.action;\n },\n set Action(newAction: IAction) {\n // There are no getter/setters on the action function prototype so this behaves as expected.\n inputFunc = newAction.prototype.input || inputFunc;\n id = newAction.prototype.id || id;\n isBatched = newAction.prototype.isBatched || isBatched;\n newAction.prototype = { ...newAction.prototype, ...options.action.prototype };\n options.action = newAction;\n },\n setProperty: (propertyName: string, value: unknown) => {\n options.action.prototype[propertyName] = value;\n actionWrap.prototype[propertyName] = options.action.prototype[propertyName];\n }\n };\n if (actionWrap.prototype.id) {\n ActionRegistrar.registerAction(actionWrap.prototype.id, actionWrap);\n }\n\n return actionWrap;\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/**\n * Known action error failure states\n */\nexport const enum ActionErrorStatus {\n Timeout = 'Timeout',\n HookTimeout = 'Hook Timeout',\n ServiceUnavailable = 'Service Unavailable'\n}\n\n/**\n * Action Error Wrapper\n */\nexport class ActionError extends Error {\n public static readonly Name: string = 'ActionError';\n\n public error?: unknown;\n public status?: ActionErrorStatus;\n\n /**\n * Checks if an object is an action error\n */\n public static isActionError(error: unknown): boolean {\n return error instanceof Error && (error).name === ActionError.Name;\n }\n\n public static isTimeoutError(error: unknown): boolean {\n return error && (error).status === ActionErrorStatus.Timeout;\n }\n\n public static isServiceUnavailable(error: unknown): boolean {\n return error && (error).status === ActionErrorStatus.ServiceUnavailable;\n }\n\n /**\n * Action Errors\n * @param error Original Error\n */\n constructor(error: ActionErrorStatus | Error);\n constructor(error: Error) {\n super();\n this.name = ActionError.Name;\n if (error instanceof Error) {\n this.message = error.message;\n this.error = error;\n } else {\n if (error === ActionErrorStatus.Timeout) {\n this.status = error;\n this.message = 'Action Timeout';\n } else if (error === ActionErrorStatus.HookTimeout) {\n this.status = error;\n this.message = 'Action hook Timeout';\n } else if (error === ActionErrorStatus.ServiceUnavailable) {\n this.status = error;\n this.message = 'Action failed due to service unavailable';\n } else if (typeof error === 'string') {\n this.message = error;\n } else {\n this.error = error;\n }\n }\n\n // As of Typescript 2.1 if we extend the Error object the prototype must be set explicitly\n // See: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ActionError.prototype);\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { AppCache, ICache } from '@msdyn365-commerce/cache-internal';\nimport { IActionInput } from '@msdyn365-commerce/core-internal';\n\n/**\n * Method to indicate if the action should look in app cache for data\n * @param input ActionInput\n */\nexport const shouldReadFromAppCache = (input: IActionInput, appCache: ICache | null): boolean => {\n return !!appCache && input && input.dataCacheType !== undefined && input.dataCacheType() !== 'none';\n};\n\n/**\n * Method to indicate if the action should write in app cache\n * @param input ActionInput\n */\nexport const shouldWriteToAppCache = (input: IActionInput, appCache: ICache | null): boolean => {\n return isAppCacheData(input, appCache);\n};\n\n/**\n * Method to indicate if the action's cache type is application\n * @param input ActionInput\n */\nexport const isAppCacheData = (input: IActionInput, appCache: ICache | null): boolean => {\n if (!appCache) {\n return false;\n }\n\n if (input) {\n if (input.dataCacheType !== undefined && input.dataCacheType() === 'application') {\n return true;\n }\n\n // if an entity has a cache setting defined, we cache that entity - caching retail proxy actions\n return (appCache).hasCacheSetting(input.getCacheObjectType());\n }\n\n return false;\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ICache, ICacheItem, ICacheSource } from '@msdyn365-commerce/cache-internal';\nimport { IActionInput, IRequestContext, msdyn365Commerce, verboseLogger } from '@msdyn365-commerce/core-internal';\nimport { AsyncResult, DataServiceRequest, isAsyncResult } from '@msdyn365-commerce/retail-proxy';\nimport { IInternalTelemetry, ITelemetry } from '@msdyn365-commerce/telemetry-internal';\n\nconst GET_FROM_RETURNIDENTIFIER: string = '___GET__FROM__RETURNIDENTIIER___';\n\nexport const addLocaleInformation = (inputs: IActionInput | IActionInput[], locale: string): void => {\n const isArray = Array.isArray(inputs);\n if (isArray) {\n const actionInputs = (inputs || []) as IActionInput[];\n actionInputs.forEach(input => {\n if (input instanceof DataServiceRequest && !input.getCacheKey().endsWith(`-${locale}`)) {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const tmp = input._cacheKeyFromInput;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n input._cacheKeyFromInput = `${tmp}-${locale}`;\n }\n });\n } else {\n if (inputs instanceof DataServiceRequest && !inputs.getCacheKey().endsWith(`-${locale}`)) {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const tmp = inputs._cacheKeyFromInput;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n inputs._cacheKeyFromInput = `${tmp}-${locale}`;\n }\n }\n};\n\nconst _resolveCacheEntryReference = (\n dataServiceRequest: DataServiceRequest,\n item: any,\n requestCache: ICache,\n appCache: ICache,\n shouldReadFromAppCache?: boolean,\n isWrappingPromise?: boolean,\n isObservable: boolean = true\n) => {\n const cacheValueAsArray = (item.key as string[])\n .map(key => {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheObjectType = dataServiceRequest._cacheObjectType;\n\n const value = requestCache.get({ typeName: cacheObjectType, key });\n if (!value && shouldReadFromAppCache && appCache) {\n appCache.copyTo({ typeName: cacheObjectType, key }, requestCache, isObservable);\n }\n\n if (!value || !value.item) {\n return undefined;\n }\n\n const valueItem: any = value.item;\n\n if (isAsyncResult(valueItem)) {\n return valueItem.result;\n }\n\n return valueItem;\n })\n .filter(data => data !== undefined && data !== null);\n\n if ((item.key as string[]).length > cacheValueAsArray.length) {\n return;\n }\n\n // If we are returning a Promise that represents a future collection, we need to unwrap it\n // @ts-ignore -- accessing a private class variable (_query) which is a valid JS\n const isReturnTypeACollection = dataServiceRequest._query.isReturnTypeACollection;\n\n return cacheValueAsArray && cacheValueAsArray.length > 0\n ? isReturnTypeACollection && !isWrappingPromise\n ? cacheValueAsArray\n : cacheValueAsArray[0]\n : undefined;\n};\n\nconst logTelemetrySource = (\n cacheValue: ICacheItem,\n dataServiceRequest: DataServiceRequest,\n cacheKey: string,\n context: IRequestContext,\n telemetry?: ITelemetry | IInternalTelemetry\n) => {\n if (!telemetry) {\n return;\n }\n if (!msdyn365Commerce.isBrowser) {\n switch (cacheValue.s!) {\n case ICacheSource.AppCache: {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheObjectType = dataServiceRequest._cacheObjectType || 'none';\n\n verboseLogger(context, telemetry, 'dataAction with {actiontype}, {cacheKey}. source {cacheSource}', {\n values: [cacheObjectType, cacheKey, 'AppCache']\n });\n break;\n }\n case ICacheSource.RequestCache: {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheObjectType = dataServiceRequest._cacheObjectType || 'none';\n\n verboseLogger(context, telemetry, 'dataAction with {actiontype}, {cacheKey}. source {cacheSource}', {\n values: [cacheObjectType, cacheKey, 'RequestCache']\n });\n break;\n }\n default: {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheObjectType = dataServiceRequest._cacheObjectType || 'none';\n\n verboseLogger(context, telemetry, 'dataAction with {actiontype}, {cacheKey}. source {cacheSource}', {\n values: [cacheObjectType, cacheKey, 'Default']\n });\n break;\n }\n }\n }\n};\n\nconst readCacheEntriesBasedOnCacheKeyFromReturnType = (\n dataServiceRequest: DataServiceRequest,\n requestCache: ICache,\n appCache: ICache,\n shouldReadFromAppCache: boolean,\n context: IRequestContext,\n telemetry?: ITelemetry | IInternalTelemetry,\n isObservable: boolean = true\n): any => {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyFromReturnType = dataServiceRequest._cacheKeyFromReturnType;\n\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyIdentifierFromReturnType = dataServiceRequest._cacheKeyIdentifierFromReturnType;\n\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheObjectType = dataServiceRequest._cacheObjectType;\n\n if (cacheKeyFromReturnType.length === 0) {\n return { entry: null, shouldRefresh: false };\n }\n let shouldRefreshAll = true;\n const cacheEntries = cacheKeyFromReturnType\n .map((entry: any) => {\n const key = `${cacheKeyIdentifierFromReturnType}-${entry}`;\n\n let cacheValue = requestCache.get({ typeName: cacheObjectType, key });\n\n if (!cacheValue && shouldReadFromAppCache && appCache) {\n cacheValue = appCache.copyTo({ typeName: cacheObjectType, key }, requestCache, isObservable);\n }\n\n if (!cacheValue || !cacheValue.item) {\n return null;\n }\n // according to the logic, will treat the entries to shouldRefresh when all entries have shouldRefresh.\n if (!cacheValue.shouldRefresh) {\n shouldRefreshAll = false;\n }\n logTelemetrySource(cacheValue, dataServiceRequest, key, context, telemetry);\n\n return cacheValue.item;\n })\n .filter(Boolean);\n\n // @ts-ignore -- accessing a private class variable (_query) which is a valid JS\n const isReturnTypeACollection = dataServiceRequest._query.isReturnTypeACollection;\n const cacheEntriesReturn = cacheEntries && cacheEntries.length > 0 ? (isReturnTypeACollection ? cacheEntries : cacheEntries[0]) : null;\n return { entry: cacheEntriesReturn, shouldRefresh: shouldRefreshAll };\n};\n\nexport const readCacheEntries = (\n dataServiceRequest: DataServiceRequest,\n requestCache: ICache,\n appCache: ICache,\n shouldReadFromAppCache: boolean = false,\n context: IRequestContext,\n telemetry?: ITelemetry | IInternalTelemetry,\n isObservable: boolean = true\n): any => {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyFromReturnType = dataServiceRequest._cacheKeyFromReturnType;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheObjectType = dataServiceRequest._cacheObjectType;\n\n if (!requestCache || (!dataServiceRequest.getCacheKey() && cacheKeyFromReturnType.length === 0) || !cacheObjectType) {\n return { entry: null, shouldRefresh: false };\n }\n\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyFromInput = dataServiceRequest._cacheKeyFromInput;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyIdentifierFromReturnType = dataServiceRequest._cacheKeyIdentifierFromReturnType;\n\n if (cacheKeyFromInput === GET_FROM_RETURNIDENTIFIER || (cacheKeyIdentifierFromReturnType && cacheKeyFromReturnType.length !== 0)) {\n const entries = readCacheEntriesBasedOnCacheKeyFromReturnType(\n dataServiceRequest,\n requestCache,\n appCache,\n shouldReadFromAppCache,\n context,\n telemetry,\n isObservable\n );\n if (entries && entries.entry) {\n return entries;\n }\n }\n const cacheKey = { typeName: cacheObjectType, key: cacheKeyFromInput };\n\n let cachedValueBasedOnInput = requestCache.get(cacheKey);\n if (cachedValueBasedOnInput) {\n cachedValueBasedOnInput = { ...cachedValueBasedOnInput };\n } else if (shouldReadFromAppCache && appCache) {\n cachedValueBasedOnInput = appCache.copyTo(cacheKey, requestCache, isObservable);\n }\n\n if (!cachedValueBasedOnInput) {\n return readCacheEntriesBasedOnCacheKeyFromReturnType(\n dataServiceRequest,\n requestCache,\n appCache,\n shouldReadFromAppCache,\n context,\n telemetry,\n isObservable\n );\n }\n logTelemetrySource(cachedValueBasedOnInput, dataServiceRequest, cacheKeyFromInput, context, telemetry);\n\n if (cachedValueBasedOnInput.item instanceof AsyncResult) {\n if (cachedValueBasedOnInput.item.status !== 'LOADING') {\n cachedValueBasedOnInput.item = cachedValueBasedOnInput.item.result || cachedValueBasedOnInput.item.error;\n } else {\n const asyncResult = cachedValueBasedOnInput.item.then(result => {\n if (typeof result !== 'object' || result.$ref !== true) {\n return result;\n }\n\n return _resolveCacheEntryReference(\n dataServiceRequest,\n result,\n requestCache,\n appCache,\n shouldReadFromAppCache,\n isObservable\n );\n });\n return { entry: asyncResult, shouldRefresh: cachedValueBasedOnInput.shouldRefresh };\n }\n }\n\n if (\n typeof cachedValueBasedOnInput.item !== 'object' ||\n (cachedValueBasedOnInput.item &&\n // @ts-ignore -- $ref property does not exists in type object\n cachedValueBasedOnInput.item.$ref !== true)\n ) {\n return { entry: cachedValueBasedOnInput.item, shouldRefresh: cachedValueBasedOnInput.shouldRefresh };\n }\n\n const cachedValueBasedOnInputItem: any = cachedValueBasedOnInput.item;\n\n const resolvedRef = _resolveCacheEntryReference(\n dataServiceRequest,\n cachedValueBasedOnInput.item,\n requestCache,\n appCache,\n shouldReadFromAppCache,\n isAsyncResult(cachedValueBasedOnInputItem),\n isObservable\n );\n return { entry: resolvedRef, shouldRefresh: cachedValueBasedOnInput.shouldRefresh };\n};\n\nconst _saveEntityToCache = (\n dataServiceRequest: DataServiceRequest,\n data: any,\n requestCache: ICache,\n appCache: ICache,\n isCacheTypeApplication: boolean,\n isInstance: boolean = false\n): { [cacheKey: string]: any } | undefined => {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyFromInput = dataServiceRequest._cacheKeyFromInput;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyIdentifierFromReturnType = dataServiceRequest._cacheKeyIdentifierFromReturnType;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const dataServiceRequestQuery = dataServiceRequest._query;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheObjectType = dataServiceRequest._cacheObjectType;\n\n if (!data || (!cacheKeyFromInput && !cacheKeyIdentifierFromReturnType)) {\n return;\n }\n\n const cacheEntries: any = {};\n const results = data;\n\n // using Object.prototype instead of Array.isArray because results can be Observable Array which can't be detected with Array.isArray\n if (!dataServiceRequestQuery.isReturnTypeACollection || Object.prototype.toString.call(results) !== '[object Array]') {\n if (cacheKeyIdentifierFromReturnType) {\n const key = `${cacheKeyIdentifierFromReturnType}-${results[cacheKeyIdentifierFromReturnType]}`;\n cacheEntries[key] = results;\n if (cacheKeyFromInput) {\n let existingCacheItem = requestCache.get({\n typeName: cacheObjectType,\n key: cacheKeyFromInput\n });\n if (existingCacheItem) {\n existingCacheItem = { ...existingCacheItem };\n }\n\n if (\n existingCacheItem &&\n existingCacheItem.item &&\n (!(existingCacheItem.item instanceof AsyncResult) || existingCacheItem.item.status === 'SUCCESS') &&\n (typeof existingCacheItem.item !== 'object' ||\n (existingCacheItem &&\n existingCacheItem.item &&\n // @ts-ignore -- $ref property does not exists in type object\n existingCacheItem?.item?.$ref !== true))\n ) {\n cacheEntries[cacheKeyFromInput] = results;\n } else {\n cacheEntries[cacheKeyFromInput] = {\n $ref: true,\n type: cacheObjectType,\n identifier: cacheKeyIdentifierFromReturnType,\n key: [key],\n // @ts-ignore -- accessing a private class variable which is a valid JS\n count: dataServiceRequest._totalCount\n };\n }\n }\n } else {\n cacheEntries[cacheKeyFromInput] = results;\n }\n } else if (!cacheKeyIdentifierFromReturnType) {\n cacheEntries[cacheKeyFromInput] = results;\n } else {\n const cacheValue = results\n .map((result: { [x: string]: any }) => {\n const identifierValue = result[cacheKeyIdentifierFromReturnType];\n if (identifierValue) {\n const key = `${cacheKeyIdentifierFromReturnType}-${identifierValue}`;\n cacheEntries[key] = result;\n return key;\n }\n })\n .filter(Boolean);\n let existingCacheItem = requestCache.get({\n typeName: cacheObjectType,\n key: cacheKeyFromInput\n });\n if (existingCacheItem) {\n existingCacheItem = { ...existingCacheItem };\n }\n if (\n existingCacheItem &&\n existingCacheItem.item &&\n (!(existingCacheItem.item instanceof AsyncResult) || existingCacheItem.item.status === 'SUCCESS') &&\n (typeof existingCacheItem.item !== 'object' ||\n (existingCacheItem &&\n existingCacheItem.item &&\n // @ts-ignore -- $ref property does not exists in type object\n existingCacheItem.item.$ref !== true))\n ) {\n cacheEntries[cacheKeyFromInput] = results;\n } else {\n if (existingCacheItem) {\n // @ts-ignore - _cacheObjectType does not exist in type ICacheItem\n const existingCacheObjectType = existingCacheItem._cacheObjectType;\n // @ts-ignore - _cacheKeyIdentifierFromReturnType does not exist in type ICacheItem\n const existingCacheKeyIdentifierFromReturnType = existingCacheItem._cacheKeyIdentifierFromReturnType;\n // @ts-ignore - _query does not exist in type ICacheItem\n const existingCacheIsReturnTypeACollection = existingCacheItem._query.isReturnTypeACollection;\n // @ts-ignore - _totalCount does not exist in type ICacheItem\n const existingCacheTotalCount = existingCacheItem._totalCount;\n\n cacheEntries[cacheKeyFromInput] = {\n $ref: true,\n type: existingCacheObjectType,\n identifier: existingCacheKeyIdentifierFromReturnType,\n isCollection: existingCacheIsReturnTypeACollection,\n key: cacheValue,\n count: existingCacheTotalCount\n };\n }\n }\n }\n\n if (cacheEntries) {\n Object.keys(cacheEntries).map(entryKey => {\n requestCache.put(\n { typeName: cacheObjectType, key: entryKey },\n { item: cacheEntries[entryKey], ...(isInstance && { instance: 'instance' }) }\n );\n\n if (appCache && isCacheTypeApplication) {\n appCache.put(\n { typeName: cacheObjectType, key: entryKey },\n { item: cacheEntries[entryKey], ...(isInstance && { instance: 'instance' }) }\n );\n }\n });\n }\n\n return cacheEntries;\n};\n\nexport const saveCacheEntries = (\n dataServiceRequest: DataServiceRequest,\n data: AsyncResult | any,\n requestCache: ICache,\n appCache: ICache,\n isCacheTypeApplication: boolean,\n isInstance: boolean = false\n): { [cacheKey: string]: any } | undefined => {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyFromInput = dataServiceRequest._cacheKeyFromInput;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheKeyIdentifierFromReturnType = dataServiceRequest._cacheKeyIdentifierFromReturnType;\n // @ts-ignore -- accessing a private class variable which is a valid JS\n const cacheObjectType = dataServiceRequest._cacheObjectType;\n\n // if return Entity is collection\n // if entity type has identifier/primary key\n // 1. cache array of primay key value of returned entity collection on input cache key\n // 2. cache individual entity on primary key\n // else\n // 1. cache output on input cache key\n //\n // else if entity type has identifier/primary key\n // 2. cache output entity on primary key\n if (!data || (!cacheKeyFromInput && !cacheKeyIdentifierFromReturnType) || !cacheObjectType) {\n return;\n }\n\n if (data instanceof AsyncResult) {\n // For a loading Promise, cache based on input cachekey, and then cache output again once complete\n if (data.status === 'LOADING') {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n data.then((result: any) => {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n if (dataServiceRequest._totalCount !== undefined) {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n data.metadata.count = dataServiceRequest._totalCount;\n }\n // @ts-ignore -- accessing a private class variable which is a valid JS\n if (dataServiceRequest && dataServiceRequest._otherOdata) {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n data.metadata.others = dataServiceRequest._otherOdata;\n }\n\n _saveEntityToCache(dataServiceRequest, result, requestCache, appCache, isCacheTypeApplication, isInstance);\n return result;\n });\n requestCache.put(\n { typeName: cacheObjectType, key: cacheKeyFromInput },\n { item: data, ...(isInstance && { instance: 'instance' }) }\n );\n\n if (appCache && isCacheTypeApplication) {\n appCache.put(\n { typeName: cacheObjectType, key: cacheKeyFromInput },\n { item: data, ...(isInstance && { instance: 'instance' }) }\n );\n }\n // For a completed promise, save the action results to the cache\n } else {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n if (dataServiceRequest._totalCount !== undefined) {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n data.metadata.count = dataServiceRequest._totalCount;\n }\n // @ts-ignore -- accessing a private class variable which is a valid JS\n if (dataServiceRequest && dataServiceRequest._otherOdata) {\n // @ts-ignore -- accessing a private class variable which is a valid JS\n data.metadata.others = dataServiceRequest._otherOdata;\n }\n _saveEntityToCache(dataServiceRequest, data.result, requestCache, appCache, isCacheTypeApplication, isInstance);\n return data.result;\n }\n } else {\n return _saveEntityToCache(dataServiceRequest, data, requestCache, appCache, isCacheTypeApplication, isInstance);\n }\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { EventEmitter } from 'events';\n\n/** EventEmitter is available in node, but not on the browser,\n * this class attempts to polyfill that so the action context can remain Isomorphic\n */\n/* @internal*/\n\n/**\n * Type for event emitter listener callback\n */\nexport type ListenerCallback = (...args0: T) => void;\n\n/**\n * Generic cast type\n */\nexport type GenericCallback = (...args: any) => void;\n\n/**\n * Custom isomorphic event emitter implementation\n *\n * @export\n * @class CustomEventEmitter\n */\nclass CustomEventEmitter {\n private listeners: Map = new Map();\n private eventEmitter: EventEmitter | null = typeof window !== undefined ? null : new EventEmitter();\n\n public on(event: string, callback: ListenerCallback): void {\n if (!!this.eventEmitter) {\n this.eventEmitter.on(event, callback);\n } else {\n let listeners = this.listeners.get(event);\n if (!!!listeners) {\n listeners = [];\n this.listeners.set(event, listeners);\n }\n\n listeners.push(callback);\n }\n }\n\n public emit(event: string, ...args: T): boolean {\n if (!!this.eventEmitter) {\n return this.eventEmitter.emit(event, args);\n }\n\n const listeners = this.listeners.get(event);\n\n if (listeners && listeners.length) {\n listeners.forEach(listener => {\n listener(...args);\n });\n return true;\n }\n\n return false;\n }\n\n public removeAllListeners(event: string): void {\n if (!!this.eventEmitter) {\n this.eventEmitter.removeAllListeners(event);\n } else {\n this.listeners.delete(event);\n }\n }\n}\n\nexport default new CustomEventEmitter();\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ICache, ICacheItem, ICacheKey } from '@msdyn365-commerce/cache-internal';\nimport {\n CacheType,\n IActionContext,\n IActionInput,\n IAnyAction,\n IDataActionOptions,\n msdyn365Commerce,\n verboseLogger,\n checkVersionForFeature,\n getPerformanceUtils\n} from '@msdyn365-commerce/core-internal';\nimport { AsyncResult, DataServiceRequest, ErrorTypeEnum, isAsyncResult, ProxyError } from '@msdyn365-commerce/retail-proxy';\nimport { asSystemMetadata, ITelemetry, LogLevel, StaticTelemetry } from '@msdyn365-commerce/telemetry-internal';\nimport { get as _get, uniqWith } from 'lodash';\nimport { toJS } from 'mobx';\nimport uuidv1 from 'uuid/v1';\n\nimport { ActionError, ActionErrorStatus } from './action-error';\nimport { ActionRegistrar } from './action-registrar';\nimport { isAppCacheData, shouldReadFromAppCache, shouldWriteToAppCache } from './action-runtime-utils';\nimport { readCacheEntries, saveCacheEntries } from './cache/retail-cache-helper';\nimport EventHelper from './event-emitter';\n\nconst defaultTimeoutInMS: number = 4000;\nconst defaultHookTimeoutInMS: number = 1000;\nexport const CLIENT_HYDRATE_KEY = 'clientHydrateKey';\nexport const CLIENT_HYDRATE_TYPE = 'clientHydrate';\n\nconst Timer = (timeoutInMS: number, message: unknown) => new Promise(resolve => setTimeout(resolve.bind(resolve, message), timeoutInMS));\n\nconst ActionTimer = (timeoutInMS: number) =>\n new Promise((_resolve, reject) => setTimeout(reject.bind(reject, ActionErrorStatus.Timeout), timeoutInMS));\n\nconst ObservableActionTimer = (timeoutInMS: number) =>\n new AsyncResult((_resolve, reject) => setTimeout(reject.bind(reject, ActionErrorStatus.Timeout), timeoutInMS));\n\n/* @internal */\n/**\n * This class contains the logic to batch and de-dupe the actions that can be executed.\n * This class is also responsible for checking and saving the action response to cache.\n */\nexport default class ActionExecutor {\n public readonly action: Function;\n public readonly cacheType: CacheType;\n private readonly isBatched: boolean;\n private readonly eventId: string;\n private readonly isObservable: boolean;\n\n private inputs: IActionInput[];\n /**\n * @param action the action to execute\n * @param inputs the action input\n */\n constructor(action: Function, inputs: IActionInput[], telemetry: ITelemetry, dataActionOption?: IDataActionOptions) {\n this.action = action;\n this.eventId = uuidv1();\n this.inputs = [...inputs]; // Cloning it DO NOT use the reference\n this.isBatched = action.prototype.isBatched;\n\n this.isObservable = action.prototype.isObservable;\n\n // Cache all the calls on browser\n const masterInput = inputs[0];\n\n if (masterInput && masterInput.dataCacheType) {\n this.cacheType = masterInput.dataCacheType();\n } else if (masterInput && masterInput.shouldCacheOutput) {\n this.cacheType = masterInput.shouldCacheOutput() ? 'request' : 'none';\n telemetry.trace('shouldCacheOutput property has been deprecated. Please update the IActionInput to use dataCacheType');\n } else {\n this.cacheType = (dataActionOption && dataActionOption.cacheType) || 'none';\n // for data actions who do not have dataCacheType function, we add customer defined cachtype to the action.\n // this is used for later check if the data acton should be read from app cache.\n inputs.forEach(input => {\n input.dataCacheType = () => this.cacheType;\n });\n telemetry.trace('Neither dataCacheType nor shouldCacheOutput are set. Caching strategy will fall back to \"none\"');\n }\n }\n\n /**\n *\n * @param inputs add more inputs\n */\n public addInputs(inputs: IActionInput[]): void {\n this.inputs.push(...inputs);\n }\n\n /** Execute the action */\n public async execute(\n context: IActionContext,\n requestCache: ICache,\n appCache: ICache | null,\n bypassAppCache?: boolean,\n refreshingInputs: IActionInput[] = []\n ): Promise {\n const unique: IActionInput[] =\n refreshingInputs && refreshingInputs.length > 0\n ? this._removeDuplicates(refreshingInputs)\n : this._removeDuplicates(this.inputs);\n if (!unique.length) {\n return [];\n }\n\n const actionId = this._getActionIdFromInputs(unique);\n\n const performanceUtils = getPerformanceUtils(msdyn365Commerce, context);\n const executionId = performanceUtils?.performanceUtilsPackage.Random.Guid.generateGuid();\n\n performanceUtils?.performanceUtilsPackage.runPreReadonlyDataActionPerformanceHook({\n actionId,\n executionId,\n internalCache: performanceUtils.cache\n });\n\n const result = await this._executeDataAction(context, requestCache, appCache, bypassAppCache, refreshingInputs, unique, actionId);\n\n performanceUtils?.performanceUtilsPackage.runPostReadonlyDataActionPerformanceHook({\n actionId,\n executionId,\n internalCache: performanceUtils.cache\n });\n\n return result;\n }\n\n private async _executeDataAction(\n context: IActionContext,\n requestCache: ICache,\n appCache: ICache | null,\n bypassAppCache: boolean | undefined,\n refreshingInputs: IActionInput[],\n unique: IActionInput[],\n actionId: string\n ): Promise {\n const isRefreshingAction = refreshingInputs && refreshingInputs.length > 0;\n\n this._runPreReadHooks(actionId, unique, context)\n .then(() => null)\n .catch(err => null);\n\n // execte preReaderHook\n this._runPreReaderHooks(actionId, unique, context)\n .then(() => null)\n .catch(err => null);\n const [uncached, needsRefresh]: IActionInput[][] = this._checkForCachedData(\n unique,\n context,\n requestCache,\n appCache,\n bypassAppCache,\n isRefreshingAction\n );\n\n if (!uncached.length) {\n // excute readOnly post hook with all cached actions ouptput\n await this._fetchOutputsAndRunPostReadHook(actionId, unique, requestCache, context);\n return needsRefresh;\n } else {\n const cachedActions = unique.filter(value => !uncached.includes(value));\n if (cachedActions.length) {\n // fetch the output for all cached data action, and run readOnly hooks. The uncached actions will be excuted later.\n await this._fetchOutputsAndRunPostReadHook(actionId, cachedActions, requestCache, context);\n }\n }\n\n let outputs: any[] = [];\n\n // VNext observable promise based flow\n // Create the AsyncResult and immediately return it\n if (this.isObservable) {\n if (this.isBatched) {\n this._executeBatchedObservableActions(uncached, requestCache, appCache, context, isRefreshingAction);\n } else {\n this._executeObservableAction(uncached[0], requestCache, appCache, context, isRefreshingAction);\n }\n return needsRefresh;\n }\n\n if (this.isBatched) {\n // TODO: Have a max batch count on the action\n outputs = await this._actionWrapper(uncached, context, isRefreshingAction);\n\n if (outputs && outputs.length !== uncached.length) {\n // TODO Throw\n context.telemetry.log(\n LogLevel.Trace,\n 'Length of input array {uncached_length} does not meet the output array {outputs_length}',\n { values: [uncached.length, outputs.length] }\n );\n }\n } else {\n outputs[0] = await this._actionWrapper(uncached[0], context, isRefreshingAction);\n }\n\n if (!outputs || outputs.length === 0) {\n return needsRefresh;\n }\n\n this._saveResponseToCache(uncached, outputs, context, requestCache, appCache);\n return needsRefresh;\n }\n\n // the retail proxy data actions who do not have return type should not interact with cache.\n private _checkShouldInteractWithCache(input: IActionInput, typeName: string | undefined): boolean {\n return !(input instanceof DataServiceRequest) || !!typeName;\n }\n\n private async _fetchOutputsAndRunPostReadHook(\n actionId: string,\n inputs: IActionInput[],\n requestCache: ICache,\n context: IActionContext\n ): Promise {\n const outputs = inputs.map(i => {\n const cacheKey = { typeName: i.getCacheObjectType(), key: i.getCacheKey() };\n // if the retail data action does not have return type, we do not read the output from cache.\n let cacheItem;\n if (this._checkShouldInteractWithCache(i, cacheKey.typeName)) {\n cacheItem = requestCache.get>(cacheKey);\n }\n return !!cacheItem ? requestCache.getValue(cacheKey) : null;\n });\n this._runPostReadHooks(actionId, inputs, outputs, context)\n .then(() => null)\n .catch(err => null);\n this._runPostReaderHooks(actionId, inputs, outputs, context)\n .then(() => null)\n .catch(err => null);\n }\n private _removeDuplicates(inputs: IActionInput[]): IActionInput[] {\n if (!this.isBatched) {\n return inputs;\n }\n\n return uniqWith(\n inputs,\n (inputA: IActionInput, inputB: IActionInput) =>\n inputA.getCacheKey() === inputB.getCacheKey() && inputA.getCacheObjectType() === inputB.getCacheObjectType()\n );\n }\n\n private _getActionIdFromInputs(inputs: IActionInput | IActionInput[]): string {\n let inputsActionId;\n for (const input of Array.isArray(inputs) ? inputs : [inputs]) {\n if (typeof input.getActionId === 'function') {\n inputsActionId = input.getActionId();\n }\n }\n return inputsActionId || (>this.action).prototype.id;\n }\n\n private _getActionFromId(actionId?: string): Function {\n let { action } = this;\n if (actionId) {\n const registration = ActionRegistrar.resolveRegistration(actionId, >action);\n if (registration) {\n action = >registration.action;\n return ActionRegistrar.unwrapAction(>action);\n }\n }\n return action;\n }\n\n private async _runPreReadHooks(id: string, inputs: IActionInput | IActionInput[], context: IActionContext): Promise {\n const preReadHooks = ActionRegistrar.getPreReadHooks(id);\n if (!preReadHooks) {\n return;\n }\n\n const hookTimeout = Number(_get(context, 'requestContext.query.actionHookTimeout')) || defaultHookTimeoutInMS;\n const timer = Timer(hookTimeout, ActionErrorStatus.HookTimeout);\n\n const preReadHooksArray = Array.from(preReadHooks);\n return preReadHooksArray.reduce(async (previousTask, currentTask) => {\n await previousTask;\n try {\n await Promise.race([timer, currentTask(inputs, context)]);\n } catch (error) {\n const actionId = id || 'unnamed';\n verboseLogger(\n context && context.requestContext,\n context.telemetry,\n \"Error execution hook of action_id '{id}', returning null\",\n {\n values: [asSystemMetadata(actionId)],\n exception: error\n },\n LogLevel.Trace\n );\n }\n return Promise.resolve();\n }, Promise.resolve());\n }\n\n private async _runPostReaderHooks(\n id: string,\n inputs: IActionInput | IActionInput[],\n actionResult: unknown,\n context: IActionContext\n ): Promise {\n const postReaderHooks = ActionRegistrar.getPostReaderHooks(id);\n if (!postReaderHooks) {\n return;\n }\n\n const hookTimeout = Number(_get(context, 'requestContext.query.actionHookTimeout')) || defaultHookTimeoutInMS;\n const timer = Timer(hookTimeout, ActionErrorStatus.HookTimeout);\n const postReaderHooksArray = Array.from(postReaderHooks);\n return postReaderHooksArray.reduce(async (previousTask, currentTask) => {\n await previousTask;\n try {\n await Promise.race([timer, currentTask(inputs, actionResult, context)]);\n } catch (error) {\n const actionId = id || 'unnamed';\n verboseLogger(\n context && context.requestContext,\n context.telemetry,\n \"Error execution hook of action_id '{id}', returning null\",\n {\n values: [asSystemMetadata(actionId)],\n exception: error\n },\n LogLevel.Trace\n );\n }\n return Promise.resolve();\n }, Promise.resolve());\n }\n\n private async _runPreReaderHooks(id: string, inputs: IActionInput | IActionInput[], context: IActionContext): Promise {\n const preReaderHooks = ActionRegistrar.getPreReaderHooks(id);\n if (!preReaderHooks) {\n return;\n }\n\n const hookTimeout = Number(_get(context, 'requestContext.query.actionHookTimeout')) || defaultHookTimeoutInMS;\n const timer = Timer(hookTimeout, ActionErrorStatus.HookTimeout);\n\n const preReaderHooksArray = Array.from(preReaderHooks);\n return preReaderHooksArray.reduce(async (previousTask, currentTask) => {\n await previousTask;\n try {\n await Promise.race([timer, currentTask(inputs, context)]);\n } catch (error) {\n const actionId = id || 'unnamed';\n verboseLogger(\n context && context.requestContext,\n context.telemetry,\n \"Error execution hook of action_id '{id}', returning null\",\n {\n values: [asSystemMetadata(actionId)],\n exception: error\n },\n LogLevel.Trace\n );\n }\n return Promise.resolve();\n }, Promise.resolve());\n }\n\n private async _runPreHooks(\n id: string,\n inputs: IActionInput | IActionInput[],\n context: IActionContext\n ): Promise {\n const preHooks = ActionRegistrar.getPreHooks(id);\n if (!preHooks) {\n return;\n }\n const hookTimeout = Number(_get(context, 'requestContext.query.actionHookTimeout')) || defaultHookTimeoutInMS;\n const timer = Timer(hookTimeout, ActionErrorStatus.HookTimeout);\n\n const preHooksArray = Array.from(preHooks);\n return preHooksArray.reduce(async (previousTask, currentTask) => {\n const prevInput = await previousTask;\n let tmpNextInput: unknown;\n try {\n tmpNextInput = await Promise.race([timer, currentTask(prevInput, context)]);\n } catch (error) {\n throw error;\n }\n const finalNextInput: IActionInput | IActionInput[] =\n tmpNextInput === ActionErrorStatus.HookTimeout || !tmpNextInput ? prevInput : tmpNextInput;\n return Promise.resolve(finalNextInput);\n }, Promise.resolve(inputs));\n }\n\n private async _runPostReadHooks(\n id: string,\n inputs: IActionInput | IActionInput[],\n actionResult: unknown,\n context: IActionContext\n ): Promise {\n const postHooks = ActionRegistrar.getPostReadHooks(id);\n\n if (!postHooks) {\n return;\n }\n\n const hookTimeout = Number(_get(context, 'requestContext.query.actionHookTimeout')) || defaultHookTimeoutInMS;\n const timer = Timer(hookTimeout, ActionErrorStatus.HookTimeout);\n const postReadHooksArray = Array.from(postHooks);\n return postReadHooksArray.reduce(async (previousTask, currentTask) => {\n await previousTask;\n try {\n await Promise.race([timer, currentTask(inputs, actionResult, context)]);\n } catch (error) {\n const actionId = id || 'unnamed';\n verboseLogger(\n context && context.requestContext,\n context.telemetry,\n \"Error execution hook of action_id '{id}', returning null\",\n {\n values: [asSystemMetadata(actionId)],\n exception: error\n },\n LogLevel.Trace\n );\n }\n return Promise.resolve();\n }, Promise.resolve());\n }\n\n private async _runPostHooks(\n id: string,\n inputs: IActionInput | IActionInput[],\n actionResult: unknown,\n context: IActionContext\n ): Promise {\n const postHooks = ActionRegistrar.getPostHooks(id);\n if (!postHooks) {\n return;\n }\n const hookTimeout = Number(_get(context, 'requestContext.query.actionHookTimeout')) || defaultHookTimeoutInMS;\n const timer = Timer(hookTimeout, ActionErrorStatus.HookTimeout);\n const postHooksArray = Array.from(postHooks);\n return postHooksArray.reduce(async (previousTask, currentTask) => {\n const prevOutput = await previousTask;\n let tmpNextOutput: unknown;\n try {\n tmpNextOutput = await Promise.race([timer, currentTask(inputs, prevOutput, context)]);\n } catch (error) {\n throw error;\n }\n const finalNextOutput = tmpNextOutput === ActionErrorStatus.HookTimeout || !tmpNextOutput ? prevOutput : tmpNextOutput;\n return Promise.resolve(finalNextOutput);\n }, Promise.resolve(actionResult));\n }\n\n /**\n * Add performance logging before and after calling the action?\n */\n // eslint-disable-next-line complexity\n private async _actionWrapper(inputs: IActionInput | IActionInput[], context: IActionContext, isRefreshing?: boolean): Promise {\n const actionId = this._getActionIdFromInputs(inputs);\n const action = this._getActionFromId(actionId);\n\n try {\n // Run pre data action hooks\n const _inputs = await this._runPreHooks(actionId, inputs, context);\n if (_inputs) {\n inputs = _inputs;\n }\n } catch (e) {\n const convertedError = this._convertToJSError(e);\n StaticTelemetry.log(\n LogLevel.Error,\n `Error executing pre-hooks for ${\n isRefreshing ? 'Refreshing' : ''\n } action '{actionName}', returning null. Error '{errorName}'. CorrelationId: '{CorrelationId}'`,\n {\n values: [\n actionId || (action && action.name) || 'unnamed',\n convertedError.name || convertedError.message,\n (convertedError).data ? (convertedError).data.CorrelationId : ''\n ],\n exception: e\n }\n );\n return new ActionError(e);\n }\n let actionResult;\n try {\n const timeOut = Number(_get(context, 'requestContext.query.actionTimeout'));\n const features = _get(context, 'requestContext.features', {});\n const serverSideCustomerTimeout =\n msdyn365Commerce.platformSettings && msdyn365Commerce.platformSettings.serverSideDataActionTimeoutInMs;\n const clientSideCustomerTimeout =\n msdyn365Commerce.platformSettings && msdyn365Commerce.platformSettings.clientSideDataActionTimeoutInMs;\n let promises;\n if (process.env.CURRENT_ENVIRONMENT === 'node' && (features.action_timeout || serverSideCustomerTimeout)) {\n const timeOutValue = (features.action_timeout && timeOut ? timeOut : serverSideCustomerTimeout) || defaultTimeoutInMS;\n promises = [this.isObservable ? ObservableActionTimer(timeOutValue) : ActionTimer(timeOutValue), action(inputs, context)];\n } else if (typeof window !== 'undefined' && msdyn365Commerce.isBrowser && clientSideCustomerTimeout) {\n promises = [\n this.isObservable ? ObservableActionTimer(clientSideCustomerTimeout) : ActionTimer(clientSideCustomerTimeout),\n action(inputs, context)\n ];\n } else {\n promises = [action(inputs, context)];\n }\n // run the data action\n actionResult = await Promise.race(promises);\n } catch (e) {\n if (e.message && e.message.length > 0 && !e.message.includes('Action id')) {\n e.message = `Action id: ${actionId}, Error message: ${e.message}`;\n }\n const convertedError = this._convertToJSError(e);\n StaticTelemetry.log(\n LogLevel.Error,\n `Error executing ${\n isRefreshing ? 'Refreshing' : ''\n } action '{actionName}', returning null. Error '{errorName}'. CorrelationId: '{CorrelationId}'`,\n {\n values: [\n actionId || (action && action.name) || 'unnamed',\n convertedError.name || convertedError.message,\n (convertedError).data ? (convertedError).data.CorrelationId : ''\n ],\n exception: e\n }\n );\n let error = new ActionError(e);\n // For AsyncResult, we need to signal that this was a rejection by throwing\n if (this.isObservable) {\n // Proxy Errors come wrapped as an array\n if (Array.isArray(e)) {\n error =\n e[0]._errorCode === ErrorTypeEnum.SERVICE_UNAVAILABLE\n ? new ActionError(ActionErrorStatus.ServiceUnavailable)\n : ProxyError.toError(e[0]);\n } else {\n error =\n e._errorCode === ErrorTypeEnum.SERVICE_UNAVAILABLE\n ? new ActionError(ActionErrorStatus.ServiceUnavailable)\n : new ActionError(e);\n }\n }\n\n throw error;\n }\n\n try {\n // Run post data action hooks\n const result = await this._runPostHooks(actionId, inputs, actionResult, context);\n if (result) {\n actionResult = result;\n }\n this._runPostReadHooks(actionId, inputs, actionResult, context)\n .then(() => null)\n .catch(err => null);\n this._runPostReaderHooks(actionId, inputs, actionResult, context)\n .then(() => null)\n .catch(err => null);\n } catch (e) {\n const convertedError = this._convertToJSError(e);\n StaticTelemetry.log(\n LogLevel.Error,\n `Error executing post-hooks for ${\n isRefreshing ? 'Refreshing' : ''\n } action '{actionName}', returning null. Error '{errorName}'. CorrelationId: '{CorrelationId}'`,\n {\n values: [\n actionId || (action && action.name) || 'unnamed',\n convertedError.name || convertedError.message,\n (convertedError).data ? (convertedError).data.CorrelationId : ''\n ],\n exception: e\n }\n );\n }\n return actionResult;\n }\n\n private _shouldUseInstanceCache = () => {\n return checkVersionForFeature('instance_cache') || msdyn365Commerce.platformSettings?.shouldUseInstanceCache;\n };\n\n private _saveResponseToCache(\n uncached: IActionInput[],\n outputs: any[],\n context: IActionContext,\n requestCache: ICache,\n appCache: ICache | null\n ): void {\n uncached.forEach((i, idx) => {\n const actionId = this._getActionIdFromInputs(i);\n if (i instanceof DataServiceRequest && !!i.getCacheObjectType()) {\n try {\n const appCacheData = appCache;\n const disableUsingInstanceCache =\n context.requestContext.features && context.requestContext.features.disable_instance_cache;\n const usingInstanceCache = !disableUsingInstanceCache && this._shouldUseInstanceCache();\n saveCacheEntries(i, outputs[idx], requestCache, appCacheData, shouldWriteToAppCache(i, appCache), usingInstanceCache);\n } catch (e) {\n const { action } = this;\n const actionName = actionId || (action && action.name) || 'unnamed';\n verboseLogger(\n context && context.requestContext,\n context.telemetry,\n \"Error execution action '{actionName}', returning null\",\n {\n values: [asSystemMetadata(actionName)],\n exception: e\n },\n LogLevel.Trace\n );\n\n return null;\n }\n } else {\n const entityId = i.getCacheKey();\n const entityType = i.getCacheObjectType();\n\n if (!!entityId && !!entityType) {\n const entry = outputs[idx];\n const cacheKey = { typeName: entityType, key: entityId };\n if (ActionError.isActionError(entry)) {\n if (!ActionError.isTimeoutError(entry)) {\n requestCache.put(cacheKey, { item: ((entry)).error, error: true });\n }\n // else do nothing\n } else {\n if (appCache && shouldWriteToAppCache(i, appCache)) {\n appCache.put(cacheKey, { item: entry });\n }\n const cacheEntry = { item: entry };\n if (i.dataCacheType && i.dataCacheType() === 'instance') {\n Object.assign(cacheEntry, { instance: 'instance' });\n }\n requestCache.put(cacheKey, cacheEntry);\n }\n }\n }\n });\n }\n\n /**\n * Method that executes a set of batchable observable data actions\n * @param uncached The uncached action inputs\n * @param requestCache The request cache\n * @param appCache The application cache, if available\n * @param context The action context\n */\n private _executeBatchedObservableActions(\n uncached: IActionInput[],\n requestCache: ICache,\n appCache: ICache | null,\n context: IActionContext,\n isRefreshing: boolean = false\n ): void {\n const unresolvedSet = new Set();\n const uncachedInputs: IActionInput[] = [];\n // Create an OP for each input in the batch that does not yet exist in cache\n const asyncOutputs = uncached\n .map((input, index) => {\n unresolvedSet.add(index);\n const executor = (resolve: any, reject: any) => {\n // When the side promise completes, update each individual OP to have it's piece of the entire batched result\n new Promise((innerResolve, innerReject) => {\n const onEventIdCompletion = (value: any) => {\n innerResolve(<{}>value);\n };\n\n const onEventIdFinalCompletion = () => {\n innerResolve();\n };\n\n const onEventIdFailure = (error: any) => {\n innerReject(error);\n };\n\n // Standard success event\n EventHelper.on(`${this.eventId}-complete-${index}-${input.getCacheKey()}`, onEventIdCompletion);\n\n // No response closing event\n EventHelper.on(`${this.eventId}-final-complete-${index}-${input.getCacheKey()}`, onEventIdFinalCompletion);\n\n // Failure event\n EventHelper.on(`${this.eventId}-failure`, onEventIdFailure);\n })\n .then(result => {\n EventHelper.removeAllListeners(`${this.eventId}-complete-${index}-${input.getCacheKey()}`);\n EventHelper.removeAllListeners(`${this.eventId}-final-complete-${index}-${input.getCacheKey()}`);\n resolve(result);\n })\n .catch(error => {\n EventHelper.removeAllListeners(`${this.eventId}-failure`);\n reject(error);\n });\n };\n\n // Already cached OP logic (rerun)\n // we only try to fetch the saved promise from cache when the retail proxy data action has cached type\n let cachedPromise;\n if (this._checkShouldInteractWithCache(input, input.getCacheObjectType())) {\n cachedPromise = requestCache.getValue({ key: input.getCacheKey(), typeName: input.getCacheObjectType() });\n }\n if (cachedPromise && isAsyncResult(cachedPromise) && !isRefreshing) {\n (>cachedPromise).run(executor);\n return;\n }\n\n // Not yet cached OP logic (initialize, run)\n uncachedInputs.push(input);\n return new AsyncResult(executor);\n })\n .filter(Boolean);\n\n // Save never before cached OPs to cache\n this._saveResponseToCache(uncachedInputs, asyncOutputs, context, requestCache, appCache);\n\n // Run the actual action\n this._actionWrapper(uncached, context, isRefreshing)\n .then((actionResults: unknown[]) => {\n // Emit events with the associated result so that each individual OP in the cache\n // can be updated appropriately\n actionResults.forEach((actionResult, index) => {\n unresolvedSet.delete(index);\n EventHelper.emit(`${this.eventId}-complete-${index}-${uncached[index].getCacheKey()}`, actionResult);\n });\n })\n .catch(error => {\n EventHelper.emit(`${this.eventId}-failure`, error);\n })\n .finally(() => {\n // In the event some inputs do not have results, we need to resolve the promises anyhow\n unresolvedSet.forEach(unresolvedIndex => {\n const index = unresolvedIndex;\n EventHelper.emit(`${this.eventId}-final-complete-${index}-${uncached[index].getCacheKey()}`);\n });\n });\n }\n\n /**\n * Executes a standard (non-batched) observable data action\n * @param input The action input\n * @param requestCache The request cache\n * @param appCache The application cache, if available\n * @param context The action context\n */\n private _executeObservableAction(\n input: IActionInput,\n requestCache: ICache,\n appCache: ICache | null,\n context: IActionContext,\n isRefreshing: boolean = false\n ): void {\n const cacheKey = { key: input.getCacheKey(), typeName: input.getCacheObjectType() };\n const executor = (resolve: any, reject: any) => {\n this._actionWrapper(input, context, isRefreshing)\n .then(result => {\n resolve(result);\n })\n .catch(error => {\n // If error is timeout error, lookup app-cache if there\n // is a valid entity for the given cacheKey in app-cache\n if (ActionError.isServiceUnavailable(error) && isAppCacheData(input, appCache)) {\n const cachedItem = appCache?.getValue(cacheKey);\n if (cachedItem) {\n return resolve(cachedItem);\n }\n }\n return reject(error);\n });\n };\n // we only try to fetch the saved promise from cache when the retail proxy data action has cached type\n let cachedPromise;\n if (this._checkShouldInteractWithCache(input, input.getCacheObjectType())) {\n cachedPromise = requestCache.getValue({ key: input.getCacheKey(), typeName: input.getCacheObjectType() });\n }\n // If OP is already in cache, just rerun it\n if (cachedPromise && isAsyncResult(cachedPromise) && !isRefreshing) {\n (>cachedPromise).run(executor);\n return;\n }\n\n // Uncached promises need to be saved to cache\n const asyncOutput = new AsyncResult(executor);\n this._saveResponseToCache([input], [asyncOutput], context, requestCache, appCache);\n }\n\n private _checkForCachedData(\n inputs: IActionInput[],\n context: IActionContext,\n requestCache: ICache,\n appCache: ICache | null,\n bypassCache?: boolean,\n refreshing?: boolean\n ): IActionInput[][] {\n const mock = _get(context, 'requestContext.query.actionMock');\n\n if (mock) {\n inputs = this._interceptCacheForMocks(inputs, context, requestCache);\n }\n\n const clientHydrateCacheKey: ICacheKey = {\n key: CLIENT_HYDRATE_KEY,\n typeName: CLIENT_HYDRATE_TYPE\n };\n const isClientHydrate = requestCache.getValue(clientHydrateCacheKey);\n const disableUsingInstanceCache = context.requestContext.features && context.requestContext.features.disable_instance_cache;\n const usingInstanceCache = !disableUsingInstanceCache && this._shouldUseInstanceCache();\n // if the cache type is set a none don't check cache for data and return inputs for execution\n // lazyresponse == true means it has been called from load-data on browser. In this case, data is already present in request-cache due to run on server side\n if (this.cacheType === 'none' || refreshing) {\n // we should keep read from cache when a dataAction\n // 1. run on server\n // 2. none cache type\n // 3. action running as part of initial page load (client hydration).\n // This is important to stay consistent with what we render on server.\n // 4. when instance cache feature is on.\n if (!(this.cacheType === 'none' && inputs[0].runOn === 'server' && isClientHydrate && usingInstanceCache) || refreshing) {\n return [inputs, []];\n }\n }\n\n const uncached: IActionInput[] = [];\n const refresh: IActionInput[] = [];\n // eslint-disable-next-line complexity\n inputs.forEach((i, idx) => {\n const actionId = this._getActionIdFromInputs(i);\n const cacheKey = { typeName: i.getCacheObjectType(), key: i.getCacheKey() };\n // if the retail proxy action does not have return type, we do not check if its in the cache\n if (i instanceof DataServiceRequest && !cacheKey.typeName) {\n uncached.push(i);\n return;\n }\n let cacheItem: ICacheItem | undefined = requestCache.get(cacheKey);\n if (cacheItem && isAsyncResult(cacheItem.item) && (>cacheItem.item).status === 'FAILED') {\n if (!i.runOn || i.runOn !== 'serverOnly') {\n uncached.push(i);\n }\n } else if (cacheItem && cacheItem.item && cacheItem.item.status === 'LOADING' && cacheItem.item.runOn === 'client') {\n // Ideally, an action configured to runOn client should never interfere with actions running on server.\n // However, it is possible that parent action with runon 'server' could be dependent on an action that is configured\n // by partner to be runOn 'client'. In this case, the child action implicitly becomes a server action. Therefore, lets\n // include such actions in the uncached list so that it gets picked and executed later.\n uncached.push(i);\n } else if (i instanceof DataServiceRequest) {\n try {\n if (bypassCache && context.requestContext.features && !!!context.requestContext.features.disable_bypass_request_cache) {\n uncached.push(i);\n } else {\n const appCacheData = appCache;\n const cacheEntries = readCacheEntries(\n i,\n requestCache,\n appCacheData,\n !!!bypassCache && shouldReadFromAppCache(i, appCache),\n context.requestContext,\n undefined,\n !!this.isObservable\n );\n if (!cacheEntries.entry) {\n uncached.push(i);\n }\n if (cacheEntries && cacheEntries.shouldRefresh) {\n refresh.push(i);\n }\n }\n } catch (e) {\n const { action } = this;\n const actionName = actionId || (action && action.name) || 'unnamed';\n verboseLogger(\n context && context.requestContext,\n context.telemetry,\n \"Error execution action '{actionName}', returning null\",\n {\n values: [asSystemMetadata(actionName)],\n exception: e\n },\n LogLevel.Trace\n );\n uncached.push(i);\n }\n } else {\n if (bypassCache && context.requestContext.features && !context.requestContext.features.disable_bypass_request_cache) {\n uncached.push(i);\n } else {\n if (!cacheItem && !!!bypassCache && appCache && shouldReadFromAppCache(i, appCache)) {\n cacheItem = appCache.copyTo(cacheKey, requestCache, !!this.isObservable);\n if (cacheItem && cacheItem.shouldRefresh) {\n refresh.push(i);\n }\n }\n\n if (!cacheItem || !cacheItem.item) {\n uncached.push(i);\n return;\n }\n }\n }\n });\n return [uncached, refresh];\n }\n\n /**\n * Searches cache for mocks matching the inputs\n * @param inputs Current action inputs\n * @param context Current action context\n * @param requestCache Current request cache\n */\n private _interceptCacheForMocks(inputs: IActionInput[], context: IActionContext, requestCache: ICache): IActionInput[] {\n const uncached: IActionInput[] = [];\n const actionId: string = this.action.prototype.id;\n inputs.forEach(i => {\n let mockItem = this._getMockItem(i.getCacheObjectType(), i.getCacheKey(), requestCache);\n if (!mockItem && actionId) {\n mockItem = this._getMockItem(actionId, i.getCacheKey(), requestCache);\n }\n let existingItem;\n if (this._checkShouldInteractWithCache(i, i.getCacheObjectType())) {\n existingItem = requestCache.get({ typeName: i.getCacheObjectType(), key: i.getCacheKey() });\n }\n\n if (!!mockItem && !!mockItem.item && !existingItem) {\n const mockItemJSObject = toJS(mockItem.item);\n if (this.isObservable) {\n requestCache.put(\n { typeName: i.getCacheObjectType(), key: i.getCacheKey() },\n { item: AsyncResult.resolve(mockItemJSObject) }\n );\n } else {\n requestCache.put({ typeName: i.getCacheObjectType(), key: i.getCacheKey() }, { item: toJS(mockItemJSObject) });\n }\n } else {\n uncached.push(i);\n }\n });\n return uncached;\n }\n\n private _getMockItem(cacheNamespace: string, cacheKey: string, requestCache: ICache): ICacheItem | undefined {\n return (\n requestCache.get({ typeName: '__MOCK', key: `${cacheNamespace}:${cacheKey}` }) ||\n requestCache.get({ typeName: '__MOCK', key: `${cacheNamespace}:*` })\n );\n }\n\n private _convertToJSError(e: any): Error {\n // Proxy Error usually comes wrapped in an array\n // If it is, unbox it and conver to regular Error\n if (Array.isArray(e)) {\n const proxyError: ProxyError = e[0];\n if (proxyError.ErrorCode) {\n return ProxyError.toError(proxyError);\n }\n } else if (e.ErrorCode) {\n return ProxyError.toError(e);\n }\n // Return regular Error if not ProxyError\n return new Error(e.message || '');\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { ProductCatalog } from '@msdyn365-commerce/retail-proxy';\nimport {\n CacheType,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric,\n IRequestContext\n} from '@msdyn365-commerce/core-internal';\nimport { getCatalogsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CatalogsDataActions.g';\nimport { createObservableDataAction } from '../create-data-action.vnext';\n\nconst buildCacheKey = (base: string, apiSettings: ICommerceApiSettings, locale?: string): string => {\n return `${base}-chanId:${apiSettings.channelId}-catId:${apiSettings.catalogId}${locale ? `-${locale}` : ''}`;\n};\n\n/**\n * Input for get-catalogs data action.\n */\nexport class CatalogsInput implements IActionInput {\n public readonly channelId: number;\n\n public readonly customerAccountNumber?: string;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n private readonly locale?: string;\n\n public constructor(context: IRequestContext, customerAccountNumber?: string) {\n this.channelId = context.apiSettings.channelId ? Number(context.apiSettings.channelId) : 0;\n this.customerAccountNumber = customerAccountNumber ? customerAccountNumber : context.user.customerAccountNumber;\n this.apiSettings = context.apiSettings;\n this.locale = context.locale || '';\n }\n\n /**\n * Get Cache Key.\n * @returns - Cache key string.\n */\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- customer account number can be undefined.\n // Removing customer account number dependency as API does not need customer account number and cache is of request type.\n // Keeping the contract same not to break backward compatibility.\n public getCacheKey = (): string => buildCacheKey(`${this.channelId}`, this.apiSettings, this.locale);\n\n /**\n * Get Cache object type.\n * @returns - Cache object type.\n */\n public getCacheObjectType = (): string => 'productCatalogs';\n\n /**\n * Get data cache type.\n * @returns - Cache type enum.\n */\n public dataCacheType = (): CacheType => 'request';\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData - The input data passed to the createInput method.\n * @param customerAccountNumber - Customer account number.\n * @returns - Catalogs input.\n */\nexport const createCatalogsInput = (inputData: ICreateActionContext>, customerAccountNumber?: string): IActionInput => {\n if (!inputData.requestContext.user.isAuthenticated) {\n throw new Error('Unable to get product catalog. User is not authenticated.');\n }\n return new CatalogsInput(inputData.requestContext, customerAccountNumber);\n};\n\n/**\n * Calls the Retail API and returns the product catalog for an user.\n * @param input - Catalogs Input.\n * @param context - Current context.\n * @returns - Product catalog for the user.\n */\nexport async function getCatalogAction(input: CatalogsInput, context: IActionContext): Promise {\n const productCatalogs = await getCatalogsAsync({ callerContext: context }, input.channelId, true);\n return productCatalogs;\n}\n\n/**\n * The GetProductCatalogs Data Action\n * Returns product catalogs.\n */\nexport const getCatalogActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce/get-catalogs',\n action: getCatalogAction as IAction,\n input: createCatalogsInput\n});\n\nexport default getCatalogActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IActionContext, IRequestContext, IRequestContextParams } from '@msdyn365-commerce/core-internal';\nimport { ProductCatalog } from '@msdyn365-commerce/retail-proxy';\nimport { CatalogsInput, getCatalogActionDataAction } from './actions/get-catalogs';\n\n/**\n * Returns catalog name for a given catalog id\n * @param context Action Context\n * @param context Catalog Id\n */\nexport const getCatalogName = async (context: IActionContext, catalogId: number): Promise => {\n if (!context || !context.requestContext || !context.requestContext.apiSettings) {\n return '';\n }\n\n const customerAccountNumber = context.requestContext.user.customerAccountNumber;\n const productCatalogs = await getCatalogActionDataAction(new CatalogsInput(context.requestContext, customerAccountNumber), context);\n\n return findCatalogName(productCatalogs, catalogId);\n};\n\n/**\n * Returns true if data action cache needs to be bypassed\n * @param requestContext rendering context\n * @returns cachebypass status\n */\nexport const shouldByPassCache = (requestContext: IRequestContext) => {\n return (requestContext.query && !!requestContext.query.cachebypass) || isPageInsightsEnabled(requestContext.params);\n};\n\nconst isPageInsightsEnabled = (params: IRequestContextParams): boolean => {\n return params?.pageInsights === 'all' || params?.pageInsights === 'info' || params?.pageInsights === 'error';\n};\n\n/**\n * Matches the catalog if with the productCatalogs response and returns catalog name\n * @param productCatalogs Product catalogs response\n * @param catalogId Catalog id to search in Product catalogs response\n * @returns Catalog name\n */\nexport const findCatalogName = (productCatalogs: ProductCatalog[], catalogId: number): string => {\n let catalogName = '';\n productCatalogs &&\n productCatalogs.forEach((catalog: ProductCatalog) => {\n if (catalog.RecordId === catalogId && catalog.Name) {\n catalogName = catalog.Name;\n }\n });\n return catalogName;\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ICache, ICacheItem, ICacheKey, ICacheSource, RequestCache } from '@msdyn365-commerce/cache-internal';\nimport {\n IAction,\n IActionContext,\n IActionInput,\n IDataActionOptions,\n msdyn365Commerce,\n verboseLogger\n} from '@msdyn365-commerce/core-internal';\nimport { AsyncResult, DataServiceRequest, isAsyncResult } from '@msdyn365-commerce/retail-proxy';\nimport {\n asSystemMetadata,\n GenericConsoleLogger,\n ITelemetry,\n LogLevel,\n StaticTelemetry,\n Telemetry\n} from '@msdyn365-commerce/telemetry-internal';\nimport uuidv1 from 'uuid/v1';\nimport ActionExecutor from './action-executor';\nimport { ActionRegistrar } from './action-registrar';\nimport { shouldWriteToAppCache } from './action-runtime-utils';\nimport { addLocaleInformation, readCacheEntries, saveCacheEntries } from './cache/retail-cache-helper';\nimport EventHelper from './event-emitter';\nimport { shouldByPassCache } from './helpers';\n\n/**\n * Cache key for actions which needs to be refreshed after page render\n */\nexport const REFRESH_ACTIONS_CACHE_KEY: ICacheKey = {\n typeName: '__REFRESH_CONFIGS_TYPE__',\n key: '__refresh_cache_key'\n};\n\n/**\n * This interface is used in ActionContext only, for saving information needed to refresh data actions.\n *\n */\nexport interface IRefreshConfigs {\n actionInputs: IActionInput[];\n paramExecutor: ActionExecutor;\n}\n/**\n * This class contains the primary logic which controls the execution flow of the action runtime\n *\n */\n/* @internal*/\n/**\n *\n */\nexport class ActionContext implements IActionContext {\n public static maxDepth: number = 200;\n\n public readonly executionParams: ActionExecutor[] = [];\n public readonly requestContext: any;\n\n /**\n * Telemetry object to log information\n */\n public telemetry: ITelemetry;\n\n private readonly requestCache: ICache;\n private readonly appCache: ICache | null = null;\n private readonly cacheKeyMap: string[] = [];\n private readonly refreshConfigs: IRefreshConfigs[] = [];\n\n /**\n * Action context creates a new instance for every tier of execution,\n * This number specifies the depth/current tier in the execution flow\n */\n private readonly currentExecutionTier: number;\n\n /**\n * Thread ID\n */\n private readonly threadId: string;\n\n /**\n * Event ID\n * Unique ID for each action context, automatically generated\n */\n private readonly eventId: string;\n\n /**\n * Whether the current context as executed\n */\n private hasRun: boolean = false;\n\n /**\n * When this number is > 0, the current context will wait for all the actions to\n * be queued before kicking off execution.\n * This number is decremented for every action that is successful in current tier.\n */\n private expectedActionsInCurrentTier: number;\n\n /**\n * variable tracking the current number of actions that are in queue, context will wait for this to match the expected count\n */\n private currentActionsInQueue: number = 0;\n\n /**\n * Object to track the next tier number.\n */\n private nextTierCounter: { next: number } = { next: 0 };\n\n /**\n * When true will span a new independent action context when an action is executed resetting depth limits\n * Otherwise will invoke the action in the current context.\n */\n private spawnChildOnExecute: boolean = false;\n\n /**\n * @param currentExecutionTier: Current execution tier in the data fetch pipeline, max is currently 7\n * @param expectedActionCount: This value specifies the expected number of actions to be queued before\n * we kick off execution in the current tier\n */\n constructor(args: {\n id: string;\n requestContext: any;\n requestCache: ICache;\n appCache: ICache | null;\n currentExecutionTier?: number;\n expectedActionCount?: number;\n spawnChildOnExecute?: boolean;\n telemetry?: ITelemetry;\n }) {\n const {\n id,\n requestContext,\n requestCache,\n appCache,\n currentExecutionTier,\n expectedActionCount,\n spawnChildOnExecute,\n telemetry\n } = args;\n this.threadId = id;\n this.eventId = uuidv1();\n\n this.currentExecutionTier = currentExecutionTier || 0;\n if (this.currentExecutionTier === 0) {\n this.nextTierCounter = { next: 0 };\n }\n\n this.expectedActionsInCurrentTier = expectedActionCount || 0;\n this.requestCache = requestCache;\n this.requestContext = requestContext || {};\n this.spawnChildOnExecute = Boolean(spawnChildOnExecute);\n\n // If a telemetry object has been passed in use that telemetry object, otherwise create a new Telemetry object\n if (telemetry) {\n this.telemetry = telemetry;\n } else {\n // register default console logger\n const moduleTelemetry = new Telemetry();\n const isDebug = requestContext.params && requestContext.params.isDebug;\n\n // register tracelogger only in development environment or debug is true.\n (process.env.NODE_ENV === 'development' || isDebug) &&\n moduleTelemetry.registerTraceLogger({ traceLogger: GenericConsoleLogger, options: { isDebug: isDebug } });\n\n this.telemetry = moduleTelemetry;\n }\n\n /**\n * @deprecated\n * Trace is an alias for telemetry.log(LogLevel.Trace, message)\n * Use the telemetry object directly.\n */\n this.trace = (message: string) => {\n this.telemetry.log(LogLevel.Debug, message);\n };\n\n // enable app cache only if the disable_app_cache feature switch is false\n if (requestContext.features && !!!requestContext.features.disable_app_cache) {\n this.appCache = appCache;\n }\n }\n\n public getRefreshActions(): IRefreshConfigs[] {\n return this.refreshConfigs;\n }\n\n /**\n * Chains an action method to the current context for execution\n * @param action - action method\n * @param inputs - action input\n */\n public chainAction(\n _action: IAction,\n inputs: IActionInput | IActionInput[],\n actionOption?: IDataActionOptions\n ): Promise {\n const action = ActionRegistrar.unwrapAction(_action);\n addLocaleInformation(inputs, this.requestContext.locale);\n if (!action || !inputs) {\n // Decrement the expected actions on this tier since this action was incorrectly configured\n this.expectedActionsInCurrentTier--;\n if (this.currentActionsInQueue < this.expectedActionsInCurrentTier) {\n return Promise.resolve(null);\n }\n\n if (!this.hasRun) {\n return this.runAllActionsInQueue().then(() => null);\n }\n\n return Promise.resolve(null);\n }\n\n if (this.isMaxDepthExceeded()) {\n this.debug('Max depth exceeded - not running further.');\n return Promise.resolve(null);\n }\n\n if (this.hasRun) {\n // If the parent action decides to queue another action after the current tier completes execution\n // then set the hasRun to false, so the action can fire right away\n this.hasRun = false;\n this.executionParams.length = 0;\n this.currentActionsInQueue = 0;\n }\n\n this.currentActionsInQueue++;\n const isBatched = action.prototype.isBatched;\n const inputsArray = (isBatched ? inputs : [inputs]);\n\n let current = this.executionParams.find(a => a.action === action);\n if (current && isBatched) {\n current.addInputs(inputsArray);\n } else {\n const inputIdentifier = `${inputsArray[0].getCacheObjectType()}||${inputsArray[0].getCacheKey()}`;\n if (!this.cacheKeyMap.find(key => key === inputIdentifier)) {\n current = new ActionExecutor(action, inputsArray, this.telemetry, actionOption);\n this.executionParams.push(current);\n this.cacheKeyMap.push(inputIdentifier);\n }\n }\n\n const asyncResult = new AsyncResult(async (resolve, reject) => {\n if (this.currentActionsInQueue < this.expectedActionsInCurrentTier) {\n // Hold the thread until the entire tier is populated\n await new Promise((innerResolve: Function) => {\n const onEventIdCompletion = (tierNum: number) => {\n if (tierNum === this.currentExecutionTier) {\n innerResolve();\n }\n };\n EventHelper.on<[number]>(`${this.eventId}:completed`, onEventIdCompletion);\n });\n EventHelper.removeAllListeners(`${this.eventId}:completed`);\n }\n\n if (!this.hasRun) {\n await this.runAllActionsInQueue();\n }\n\n const outputs = inputsArray.map(i => {\n if (i instanceof DataServiceRequest) {\n try {\n const appCacheData = this.appCache;\n const entry = readCacheEntries(i, this.requestCache, appCacheData, false, this.requestContext, StaticTelemetry);\n return entry.entry;\n } catch (e) {\n this.debug(\n `Error execution action type '[${i && i.getCacheObjectType()}' and cache key '[{${i &&\n i.getCacheKey()}}]', returning null`\n );\n return null;\n }\n } else {\n const cacheKey = { typeName: i.getCacheObjectType(), key: i.getCacheKey() };\n const cacheItem = this.requestCache.get>(cacheKey);\n const cacheValue = !!cacheItem ? this.requestCache.getValue(cacheKey) : null;\n\n if (cacheItem && !!cacheItem.error) {\n throw cacheValue;\n } else {\n if (cacheItem && !msdyn365Commerce.isBrowser) {\n if (cacheItem.refreshStartTimeInMS) {\n verboseLogger(\n this.requestContext,\n StaticTelemetry,\n 'dataAction with {actiontype}, {cacheKey}. last refresh time {lastRefresh}',\n {\n values: [\n asSystemMetadata(i.getCacheObjectType() || 'none'),\n asSystemMetadata(i.getCacheKey()),\n asSystemMetadata(cacheItem.refreshStartTimeInMS)\n ]\n }\n );\n }\n switch (cacheItem.s!) {\n case ICacheSource.AppCache: {\n verboseLogger(\n this.requestContext,\n StaticTelemetry,\n 'dataAction with {actiontype}, {cacheKey}. source {cacheSource}',\n {\n values: [\n asSystemMetadata(i.getCacheObjectType() || 'none'),\n asSystemMetadata(i.getCacheKey()),\n asSystemMetadata('AppCache')\n ]\n }\n );\n break;\n }\n case ICacheSource.RequestCache: {\n verboseLogger(\n this.requestContext,\n StaticTelemetry,\n 'dataAction with {actiontype}, {cacheKey}. source {cacheSource}',\n {\n values: [\n asSystemMetadata(i.getCacheObjectType() || 'none'),\n asSystemMetadata(i.getCacheKey()),\n asSystemMetadata('RequestCache')\n ]\n }\n );\n break;\n }\n default: {\n verboseLogger(\n this.requestContext,\n StaticTelemetry,\n 'dataAction with {actiontype}, {cacheKey}. source {cacheSource}',\n {\n values: [\n asSystemMetadata(i.getCacheObjectType() || 'none'),\n asSystemMetadata(i.getCacheKey()),\n asSystemMetadata('Undefined')\n ]\n }\n );\n }\n }\n }\n return cacheValue;\n }\n }\n });\n\n this.cacheKeyMap.splice(0, this.cacheKeyMap.length);\n\n // Batched observable actions need to be merged into a single AsyncResult\n if (isBatched && action.prototype.isObservable) {\n resolve(\n Promise.all(outputs).then(results => {\n // Because AsyncResult sometimes get mangled by MobX, we need to ensure mangled ones are still unwrapped\n return results.map(result => {\n return result && result._type === 'AsyncResult' ? result.result : result;\n });\n })\n );\n } else {\n // We need to pass along the metadata explicitly to the outer AsyncResult\n if (isAsyncResult(outputs[0]) && !isBatched) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n outputs[0].then(() => {\n asyncResult.metadata = outputs[0].metadata;\n });\n }\n\n resolve(isBatched ? outputs : (outputs.length && outputs[0]) || null);\n }\n });\n\n return asyncResult;\n }\n\n /**\n * Helper method to update cache\n * @param input The input\n * @param data The data\n */\n public update(inputs: IActionInput | IActionInput[], data: T): T {\n if (inputs && data) {\n // If an array of actionInputs has been passed, an equal amount of data items must be present\n const dataArray = (Array.isArray(inputs) ? data : [data]);\n const inputArray = Array.isArray(inputs) ? inputs : [inputs];\n if (inputArray.length !== dataArray.length) {\n throw new Error('Array of action inputs was passed to actionContext Update, and did not match length of input data array.');\n }\n addLocaleInformation(inputArray, this.requestContext.locale);\n inputArray.map((i, idx) => {\n if (i instanceof DataServiceRequest) {\n try {\n const appCacheData = this.appCache;\n saveCacheEntries(i, dataArray[idx], this.requestCache, appCacheData, shouldWriteToAppCache(i, this.appCache));\n } catch (e) {\n this.debug(\n `Error in updating cache with input '[${i.getCacheObjectType()}]' - '[${i.getCacheKey()}]', returning null`\n );\n this.error(e);\n }\n } else {\n // When updating OPs, only result can be updated, passed OPs will also be unwrapped.\n if (isAsyncResult(dataArray[idx])) {\n dataArray[idx] = (>dataArray[idx]).result;\n }\n\n const cacheKey = { typeName: i.getCacheObjectType(), key: i.getCacheKey() };\n this.requestCache.put(cacheKey, { item: dataArray[idx] });\n if (this.appCache && shouldWriteToAppCache(i, this.appCache)) {\n this.appCache.put(cacheKey, { item: dataArray[idx] });\n }\n }\n });\n\n if (Array.isArray(inputs)) {\n return (inputs.map(input => {\n return this.requestCache.getValue({ typeName: input.getCacheObjectType(), key: input.getCacheKey() });\n }));\n } else {\n return this.requestCache.getValue({ typeName: inputs.getCacheObjectType(), key: inputs.getCacheKey() });\n }\n }\n\n // For scenarios where data/input was bad, we just return original data\n return data;\n }\n\n /**\n * Helper method to log trace using telemetry\n * @param message message to log to console\n */\n public trace = (message: string): void => {\n this.telemetry.log(LogLevel.Debug, 'Depth: {currentExecutionTier}\\tID: {threadId}\\tMessage: {message}', {\n values: [this.currentExecutionTier, this.threadId, message]\n });\n };\n\n /**\n * Helper method to log error using telemetry\n * @param message message to log to console\n */\n public error = (message: string): void => {\n this.telemetry.log(LogLevel.Error, 'Depth: {currentExecutionTier}\\tID: {threadId}\\tMessage: {message}', {\n values: [this.currentExecutionTier, this.threadId, message]\n });\n };\n\n /**\n * Helper method to log debug using telemetry\n * @param message message to log to console\n */\n public debug = (message: string): void => {\n this.telemetry.log(LogLevel.Debug, 'Depth: {currentExecutionTier}\\tID: {threadId}\\tMessage: {message}', {\n values: [this.currentExecutionTier, this.threadId, message]\n });\n };\n\n /**\n * Helper method to data cache from cache\n * if cachekey is null or empty, it returns all entries of cacheObjectType\n * @param cacheObjectType entity type that was cached\n * @param cacheKey cache key against which the object is cached\n * @throws if cacheObjecttype is null or empty\n */\n public get(cacheObjectType: string, cacheKey: string): T | T[] | null {\n if (!cacheObjectType) {\n throw new Error('Cannot have null or empty cacheObjectType');\n }\n\n if (!cacheKey) {\n throw new Error('Cannot have null or empty cacheKey');\n }\n\n const preparedCacheKey = { typeName: cacheObjectType, key: cacheKey };\n let cachedItem = this.requestCache.get(preparedCacheKey);\n\n if (process.env.CURRENT_ENVIRONMENT === 'node' && !cachedItem && this.appCache) {\n cachedItem = this.appCache.get(preparedCacheKey);\n }\n\n if (!cachedItem) {\n return null;\n }\n\n if (typeof cachedItem.item !== 'object' || cachedItem.item.$ref !== true) {\n return cachedItem.item;\n }\n\n return Array.isArray(cachedItem.item.key) ? (cachedItem.item.key)\n .map(key => this.getItemFromCache({ typeName: cacheObjectType, key }))\n .filter(Boolean) : null;\n }\n\n /**\n * Helper method to data cache from cache\n * if cachekey is null or empty, it returns all entries of cacheObjectType\n * @param input The input\n * @param data The data\n * @throws if cacheObjecttype is null or empty\n */\n public getAll(cacheObjectType: string): T[] | null {\n if (!cacheObjectType) {\n throw new Error('Cannot have null or empty cacheObjectType');\n }\n\n let cachedEntries = this.requestCache.getAllItems(cacheObjectType);\n if (!cachedEntries) {\n if (process.env.CURRENT_ENVIRONMENT === 'node' && this.appCache) {\n cachedEntries = this.appCache && this.appCache.getAllItems(cacheObjectType);\n }\n\n if (!cachedEntries) {\n return null;\n }\n }\n\n return Object.keys(cachedEntries)\n .filter(key => typeof cachedEntries![key].item !== 'object' || cachedEntries![key].item.$ref !== true)\n .map(key => cachedEntries![key].item);\n }\n\n /**\n * Executes all the actions in the current context in parallel\n */\n public async runAllActionsInQueue(): Promise {\n const { threadId, requestContext, requestCache, appCache, nextTierCounter, executionParams } = this;\n if (!executionParams.length) {\n this.trace('No actions to execute - not running further.');\n return;\n }\n // Increment the tier each pass through run all actions\n if (this.isMaxDepthExceeded()) {\n this.trace('Max depth exceeded - not running further.');\n return;\n }\n\n // When kicking off the next tier,\n // set the max number of chain actions the can be expected from child actions\n // equal to the number of actions that are executing in current tier\n const expectedNumberOfChildThreads = executionParams.length;\n\n let nextTierStartingDepth;\n if (this.spawnChildOnExecute) {\n nextTierStartingDepth = nextTierCounter.next + 1;\n } else {\n nextTierStartingDepth = ++nextTierCounter.next;\n }\n\n const nextTier = new ActionContext({\n id: threadId,\n requestContext: requestContext,\n requestCache: requestCache,\n appCache: appCache,\n currentExecutionTier: nextTierStartingDepth,\n expectedActionCount: expectedNumberOfChildThreads,\n telemetry: this.telemetry\n });\n\n const refreshconfigslocal: Set = new Set();\n\n nextTier.nextTierCounter = { next: nextTierStartingDepth };\n // DO NOT Trace using current action context, use only secondaryContext to remain consistent with actions\n const promises: Promise[] = executionParams.map(param => {\n // TODO: should we read from input about the cacheability?\n return param.execute(nextTier, requestCache, appCache, shouldByPassCache(this.requestContext), []).then(refreshActions => {\n // refresh the data actions which need to be refreshed.\n if (refreshActions.length) {\n refreshconfigslocal.add({\n paramExecutor: param,\n actionInputs: refreshActions\n });\n\n this.refreshConfigs.push({\n paramExecutor: param,\n actionInputs: refreshActions\n });\n\n const cacheValue = requestCache.get(REFRESH_ACTIONS_CACHE_KEY);\n const refreshConfigs = cacheValue ? cacheValue.item : [];\n refreshConfigs.push({\n paramExecutor: param,\n actionInputs: refreshActions\n });\n requestCache.put(REFRESH_ACTIONS_CACHE_KEY, {\n item: refreshConfigs\n });\n }\n\n // If the current chain action completes execution\n // decrement the max number of threads that we expect\n // from the next tier\n nextTier.expectedActionsInCurrentTier--;\n\n if (!nextTier.hasRun) {\n // First check if the next tier has any actions\n // then check if the number of thread match expected\n if (nextTier.currentActionsInQueue > 0 && nextTier.currentActionsInQueue === nextTier.expectedActionsInCurrentTier) {\n return nextTier.runAllActionsInQueue();\n }\n }\n });\n });\n\n // Wait until all the actions in current tier are run to completion\n return Promise.all(promises)\n .then(() => {\n if (refreshconfigslocal.size > 0 && requestContext.features && !!requestContext.features.disable_appcache_refresh_await) {\n refreshconfigslocal.forEach(rf => {\n const refreshRequestCache = new RequestCache();\n const refreshContext = new ActionContext({\n id: 'Refresh Context',\n requestContext: requestContext,\n requestCache: new RequestCache(),\n telemetry: this.telemetry,\n appCache: appCache,\n spawnChildOnExecute: true\n });\n\n rf.paramExecutor\n .execute(\n refreshContext,\n refreshRequestCache,\n this.appCache,\n shouldByPassCache(this.requestContext),\n rf.actionInputs\n )\n .then(() =>\n verboseLogger(\n this.requestContext,\n StaticTelemetry,\n `BackgroundRefresh - Executed refresh with action input ${rf.actionInputs[0].getCacheObjectType()}-${rf.actionInputs[0].getCacheKey()}`\n )\n )\n .catch(error => {\n StaticTelemetry.log(\n LogLevel.Warning,\n `BackgroundRefresh - Error execution refresh with action input ${rf.actionInputs[0].getCacheObjectType()}-${rf.actionInputs[0].getCacheKey()}`\n );\n });\n });\n }\n this._endCurrentTier();\n })\n .catch(error => {\n this._endCurrentTier();\n throw error;\n });\n }\n\n /**\n * Returns true if current tier has exceeded max depth\n */\n private isMaxDepthExceeded = (): boolean => {\n const maxDepth =\n (this.requestContext &&\n this.requestContext.app &&\n this.requestContext.app.platform &&\n this.requestContext.app.platform.maxDepth) ||\n ActionContext.maxDepth;\n return this.nextTierCounter.next > maxDepth;\n };\n\n /**\n * Retrieves item from request cache and fallsback to app cache if not found\n */\n private getItemFromCache = (cacheKey: ICacheKey): T | undefined => {\n let cachedItem = this.requestCache.get(cacheKey);\n\n if (cachedItem) {\n return cachedItem.item;\n }\n\n if (process.env.CURRENT_ENVIRONMENT === 'node' && this.appCache) {\n cachedItem = this.appCache.get(cacheKey);\n }\n\n return cachedItem ? cachedItem.item : undefined;\n };\n\n /**\n * Signals the end of current tier so actions can return the response\n */\n private _endCurrentTier = (): void => {\n this.hasRun = true;\n EventHelper.emit(`${this.eventId}:completed`, this.currentExecutionTier);\n };\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { RequestCache } from '@msdyn365-commerce/cache-internal';\nimport { IActionContext } from '@msdyn365-commerce/core-internal';\nimport { ActionContext } from './action-context';\n\n/**\n * Creates a mock but usable ActionContext.\n * @param context The partial context to add to the return action context.\n *\n * DEPRECATED: Please use buildMockActionContext and pass in a constructed\n * ActionContext to build a hydrated mock action context\n * Example:\n * const actionContext = buildMockActionContext(new ActionContext({\n * id: 'mock-context',\n * requestCache: new RequestCache(),\n * requestContext: {},\n * appCache: null\n * }));\n *\n */\nexport const buildHydratedMockActionContext = (context?: Partial): IActionContext => {\n return new ActionContext({\n id: 'mock-context',\n requestCache: new RequestCache(),\n requestContext: (context && context.requestContext) || {},\n appCache: null\n });\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n generateImageUrlForOmniChanel,\n IAction,\n IActionContext,\n IActionInput,\n IRequestContext,\n versionGte\n} from '@msdyn365-commerce/core-internal';\nimport { getMediaLocationsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\n// @ts-ignore\nimport { MediaLocation, MediaType } from '@msdyn365-commerce/retail-proxy';\nimport { createObservableDataAction } from '../create-data-action.vnext';\n\n/**\n * The action input class for the getMediaLocationsForSelectedVariant data action.\n */\nexport class MediaLocationsInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public catalogId: number;\n\n private readonly locale?: string;\n\n constructor(context: IRequestContext, productId: number, channelId: number, catalogId?: number) {\n this.productId = productId;\n this.channelId = channelId;\n this.catalogId = catalogId || 0;\n this.locale = context.locale;\n }\n\n public getCacheKey = () => `${this.productId}-${this.channelId}-${this.catalogId}-${this.locale}}`;\n\n public getCacheObjectType = () => 'ProductMediaLocations';\n\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * The action method for the getMediaLocationsForSelectedVariant data action.\n * @param input\n * @param ctx\n */\nexport async function getMediaLocationsForProductAction(input: MediaLocationsInput, ctx: IActionContext): Promise {\n const rsVersion =\n !process.env.MSDyn365Commerce_RSVERSION || process.env.MSDyn365Commerce_RSVERSION === '--'\n ? '0.0'\n : process.env.MSDyn365Commerce_RSVERSION;\n const OmniChannelMediaFeatureVersion = versionGte(rsVersion, '9.43');\n if (!OmniChannelMediaFeatureVersion) {\n return [];\n }\n // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires -- Need for Omni feature.,\n const types = require('@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g');\n\n // TODO: once the dynamicProvider api for fetching the media locations from the azureCms is implemented\n // we should uncomment these code so we can preview the product in edit mode without publish the product.\n // if (ctx.requestContext.params && ctx.requestContext.params.isEditor) {\n // return getOmniChannelMediaInfoAsync(ctx.requestContext, input.productId);\n // }\n\n let productMediaLocations = [];\n try {\n productMediaLocations = await getMediaLocationsAsync(\n {\n callerContext: ctx,\n queryResultSettings: {\n Paging: { Top: Number.parseInt(ctx.requestContext?.app?.platform?.defaultPageSizeForAPI ?? 100, 10) }\n }\n },\n input.productId,\n input.channelId,\n input.catalogId\n );\n } catch (error) {\n ctx.telemetry.error(`Error running getMediaLocationsAsync action: ${error}`);\n return [];\n }\n\n // Filtering product images and videos only\n let productImagesAndVideos = productMediaLocations.filter(\n // @ts-ignore\n media => media.MediaTypeValue === types.MediaType.Image || media.MediaTypeValue === types.MediaType.Video\n );\n if (productImagesAndVideos.length === 0) {\n return [];\n }\n\n // sorting the images by display order settings.\n productImagesAndVideos = productImagesAndVideos.sort((a, b) => {\n // @ts-ignore\n if (typeof a.DisplayOrder === 'undefined' && typeof b.DisplayOrder === 'undefined') {\n return 0;\n // @ts-ignore\n } else if (typeof a.DisplayOrder === 'undefined') {\n return 1;\n // @ts-ignore\n } else if (typeof b.DisplayOrder === 'undefined') {\n return -1;\n } else {\n // @ts-ignore\n return a.DisplayOrder - b.DisplayOrder;\n }\n });\n const productMedia = productImagesAndVideos.map((mediaLocation: MediaLocation) => {\n const mediaLoc = { ...mediaLocation };\n // @ts-ignore\n if (mediaLoc.MediaTypeValue === types.MediaType.Image) {\n mediaLoc.Uri = generateImageUrlForOmniChanel(ctx.requestContext.apiSettings, mediaLocation.Uri);\n }\n return mediaLoc;\n });\n\n return productMedia;\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/get-mediaLocations',\n action: >getMediaLocationsForProductAction\n});\n\nexport default getMediaLocationsForProductAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n generateImageUrlForOmniChanel,\n IAction,\n IActionContext,\n IActionInput,\n IRequestContext,\n versionGte\n} from '@msdyn365-commerce/core-internal';\n// @ts-ignore\nimport { MediaLocation, MediaType } from '@msdyn365-commerce/retail-proxy';\nimport { createObservableDataAction } from '../create-data-action.vnext';\n\nexport enum MediaLocationType {\n All,\n Image,\n Video,\n File\n}\n\n/**\n * The action input class for the getAdditionalMediaLocationsForSelectedVariant data action.\n */\nexport class AdditionalMediaLocationsInput implements IActionInput {\n public productId: number;\n\n public channelId: number;\n\n public catalogId: number;\n\n // defaulting to image for backwards compatibility, old version filters Image by default.\n public typeFilter: MediaLocationType;\n\n private readonly locale?: string;\n\n constructor(context: IRequestContext, productId: number, channelId: number, catalogId?: number, typeFilter = MediaLocationType.All) {\n this.productId = productId;\n this.channelId = channelId;\n this.catalogId = catalogId || 0;\n this.typeFilter = typeFilter;\n this.locale = context.locale;\n }\n\n public getCacheKey = () => `${this.productId}-${this.channelId}-${this.catalogId}-${this.locale}}-${this.typeFilter}`;\n\n public getCacheObjectType = () => 'ProductAdditionalMediaLocations';\n\n public dataCacheType = (): CacheType => 'application';\n}\n\n/**\n * The action method for the getAdditionalMediaLocationsForSelectedVariant data action.\n * @param input\n * @param ctx\n */\nexport async function getAdditionalMediaLocationsForProductAction(\n input: AdditionalMediaLocationsInput,\n ctx: IActionContext\n): Promise {\n const rsVersion =\n !process.env.MSDyn365Commerce_RSVERSION || process.env.MSDyn365Commerce_RSVERSION === '--'\n ? '0.0'\n : process.env.MSDyn365Commerce_RSVERSION;\n const OmniChannelAdditionalMediaFeatureVersion = versionGte(rsVersion, '9.46');\n if (!OmniChannelAdditionalMediaFeatureVersion) {\n return [];\n }\n // the types and productActions are not available in all versions of retail-proxy, so they are imported by direct reference after comparing the version to the minimum required(9.46)\n // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires -- Need for Omni feature.,\n const types = require('@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g');\n // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires -- Need for Omni feature.,\n const productActions = require('@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g');\n\n // TODO: once the dynamicProvider api for fetching the media locations from the azureCms is implemented\n // we should uncomment these code so we can preview the product in edit mode without publish the product.\n // if (ctx.requestContext.params && ctx.requestContext.params.isEditor) {\n // return getOmniChannelMediaInfoAsync(ctx.requestContext, input.productId);\n // }\n\n let productMediaLocations = [];\n try {\n productMediaLocations = await productActions.searchMediaLocationsAsync(\n {\n callerContext: ctx,\n queryResultSettings: {\n Paging: { Top: Number.parseInt(ctx.requestContext?.app?.platform?.defaultPageSizeForAPI ?? 100, 10) }\n }\n },\n {\n ProductId: input.productId,\n ChannelId: input.channelId,\n CatalogId: input.catalogId,\n MediaUsageTypeValue: 1\n }\n );\n } catch (error) {\n ctx.telemetry.error(`Error running searchMediaLocationsAsync action: ${error}`);\n return [];\n }\n\n // Need to add a second enum for MediaTypeValue because the RetailServer API returns a different enum for the MediaTypeValue property,\n // where default is \"None\" instead of \"All\"\n let filteredMedia: MediaLocation[] = [];\n switch (input.typeFilter) {\n case MediaLocationType.Image:\n // @ts-ignore\n filteredMedia = productMediaLocations.filter(media => media.MediaTypeValue === types.MediaType.Image);\n break;\n case MediaLocationType.Video:\n // @ts-ignore\n filteredMedia = productMediaLocations.filter(media => media.MediaTypeValue === types.MediaType.Video);\n break;\n case MediaLocationType.File:\n // @ts-ignore\n filteredMedia = productMediaLocations.filter(media => media.MediaTypeValue === types.MediaType.File);\n break;\n default:\n filteredMedia = productMediaLocations;\n }\n if (filteredMedia.length === 0) {\n return [];\n }\n\n // sorting the images by display order settings.\n filteredMedia = filteredMedia.sort((a, b) => {\n // @ts-ignore\n if (typeof a.DisplayOrder === 'undefined' && typeof b.DisplayOrder === 'undefined') {\n return 0;\n // @ts-ignore\n } else if (typeof a.DisplayOrder === 'undefined') {\n return 1;\n // @ts-ignore\n } else if (typeof b.DisplayOrder === 'undefined') {\n return -1;\n } else {\n // @ts-ignore\n return a.DisplayOrder - b.DisplayOrder;\n }\n });\n const productMedia = filteredMedia.map((mediaLocation: MediaLocation) => {\n mediaLocation.Uri = generateImageUrlForOmniChanel(ctx.requestContext.apiSettings, mediaLocation.Uri);\n mediaLocation.AltText = mediaLocation.AltText;\n return mediaLocation;\n });\n return productMedia;\n}\n\n/**\n * The getAdditionalMediaLocationsForSelectedVariantActionDataAction 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 getAdditionalMediaLocationsForSelectedVariantActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce/get-additional-mediaLocations',\n action: >getAdditionalMediaLocationsForProductAction\n});\n\nexport default getAdditionalMediaLocationsForProductAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport {\n CacheType,\n IAction,\n IActionContext,\n IActionInput,\n IAny,\n ICommerceApiSettings,\n ICreateActionContext,\n IGeneric\n} from '@msdyn365-commerce/core-internal';\nimport { Customer } from '@msdyn365-commerce/retail-proxy';\nimport { readAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g';\nimport { createObservableDataAction } from '../create-data-action.vnext';\n\n/**\n * Input class for get customer data action.\n */\nexport class GetCustomerInput implements IActionInput {\n public customerAccountNumber?: string;\n\n private readonly apiSettings: ICommerceApiSettings;\n\n private readonly cacheType?: CacheType;\n\n public constructor(apiSettings: ICommerceApiSettings, accountNumber?: string, cacheType?: CacheType) {\n this.customerAccountNumber = accountNumber;\n this.apiSettings = apiSettings;\n this.cacheType = cacheType;\n }\n\n /**\n * GetCacheKey.\n * @returns - Returns string.\n */\n public getCacheKey = (): string => `Customer-${this.customerAccountNumber}-chanId:${this.apiSettings.channelId}`;\n\n /**\n * GetCacheObjectType.\n * @returns - Cache Object Type string.\n */\n public getCacheObjectType = (): string => 'Customer';\n\n /**\n * DataCacheType.\n * @returns - CacheType string.\n */\n public dataCacheType = (): CacheType => {\n return this.cacheType ? this.cacheType : 'request';\n };\n}\n\n/**\n * Creates the input required to make the retail api call.\n * @param inputData -- The input data passed to the createInput method.\n * @returns - GetCustomer input.\n */\nexport const createGetCustomerInput = (inputData: ICreateActionContext>): GetCustomerInput => {\n const { user, apiSettings } = inputData.requestContext;\n if (!user.token || !user.isAuthenticated) {\n throw new Error('[getCustomer][createInput]: User is not Authenticated.');\n }\n\n return new GetCustomerInput(apiSettings);\n};\n\n/**\n * GetCustomerAction.\n * @param input - GetCustomerInput.\n * @param ctx - Action Context.\n * @returns - Customer information.\n */\nconst getCustomerAction = async (input: GetCustomerInput, ctx: IActionContext): Promise => {\n if (input && ctx.requestContext.user.isAuthenticated) {\n try {\n return readAsync({ callerContext: ctx, bypassCache: 'get' }, '').then(response => {\n return Array.isArray(response) ? response[0] : response;\n });\n } catch (error) {\n ctx.telemetry.error(`Error running getCustomer action: ${error}`);\n return {};\n }\n }\n\n ctx.telemetry.warning('[getCustomer]Invalid input passed to action');\n return {};\n};\n\n/**\n * The customer data action.\n */\nexport const getCustomerActionDataAction = createObservableDataAction({\n id: '@msdyn365-commerce/get-customer',\n action: >getCustomerAction,\n input: createGetCustomerInput\n});\n\nexport default getCustomerActionDataAction;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IDictionary } from '@msdyn365-commerce/core-internal';\n\nexport enum ICacheSource {\n RequestCache,\n AppCache\n}\n\nexport interface ICacheKey {\n key: string;\n typeName: string;\n}\n\nexport interface ICacheItem {\n item: T;\n shouldRefresh?: boolean;\n error?: boolean;\n instance?: string;\n // property to indicate the source whether it is app/request\n s?: ICacheSource;\n /**\n * Flag to track the when the item start refreshing.\n */\n refreshStartTimeInMS?: number;\n lastRefreshTime?: Date;\n}\n\nexport interface ICompressCache {\n data: T;\n isCompressed: boolean;\n}\n\nexport interface ICacheItemOptions {\n ttr?: number;\n ttl?: number;\n cacheKeySuffix?: string;\n}\nexport interface ICacheStats {\n keys?: number;\n hits?: number;\n misses?: number;\n totalKeySize?: number;\n totalValueSize?: number;\n valueSizePerKey?: object;\n}\n\n/**\n * Interface exposing methods for caching\n */\nexport interface ICache {\n /**\n * @function {put} - Method to insert an item in the cache\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @param cacheItem {ICacheItem} - item that needs to be inserted in the cache\n * @param options {ICacheItemOptions} - Optional cache item options\n */\n put(cacheKey: ICacheKey, item: ICacheItem, options?: ICacheItemOptions): boolean;\n\n /**\n * @function {get} - Method to get the cached item\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @return {ICacheItem} - cached value against the given cache key\n */\n get(cacheKey: ICacheKey): ICacheItem | undefined;\n\n /**\n * @function {getValue} - Method to get the cached item\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @return {T} - cached value against the given cache key\n */\n getValue(cacheKey: ICacheKey): T | undefined;\n\n /**\n * @function {getAllItems} - Method to get all cached items for a given type\n * @param typeName {typeName} - typeName for which all items need to be fetched\n * @return {ICacheItem} - dictionary of cache items of the given typeName\n */\n getAllItems(typeName: string): IDictionary> | undefined;\n\n /**\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @param toCache {ICache} - cache object to which the item needs to be copied\n * @return {ICacheItem} - cache item that was copied\n */\n copyTo(cacheKey: ICacheKey, toCache: ICache, isObservable?: boolean): ICacheItem | undefined;\n\n /**\n * @function {del} - Method to delete an item from the cache\n * @param key {ICacheKey[]} - Array of ICacheGetData items whose values need to be deleted from cache\n * @return {number} - returns true if the cache key is deleted successfully. Does not throw errors.\n */\n del(cacheKey: ICacheKey): boolean;\n\n /**\n * @function {flushAll} - Method to flush all data from the cache\n */\n flushAll(): void;\n\n /**\n * @function {getStats} - Returns statstics about the cache (number of keys, value size in bytes, etc)\n */\n getStats?(): ICacheStats;\n\n /**\n * @function {flushStats} - Flush the stats\n */\n flushStats?(): void;\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { ICacheKey } from './ICache';\n\nexport const MODULE_CSS_CACHE_KEY = 'MODULE-CSS-CHUNKS';\nexport const MODULE_CSS_CACHE_TYPENAME = '__MODULECSSCHUNKS__';\n\nexport const normalizeCacheKey = (cacheKey: ICacheKey): ICacheKey => {\n return {\n typeName: cacheKey.typeName.toUpperCase(),\n key: cacheKey.key.toUpperCase()\n };\n};\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { IDictionary } from '@msdyn365-commerce/core-internal';\nimport { isAsyncResult } from '@msdyn365-commerce/retail-proxy';\nimport { observable, set, transaction } from 'mobx';\nimport { normalizeCacheKey } from './cache-utils';\nimport { ICache, ICacheItem, ICacheKey, ICacheSource } from './ICache';\n\n/**\n * Client cache implementation\n */\nexport class RequestCache implements ICache {\n private internalCache: { [typeName: string]: IDictionary> } = {};\n\n /**\n * @function {put} - Method to insert an item in the cache\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @param cacheItem {ICacheItem} - item that needs to be inserted in the cache\n */\n public put(cacheKey: ICacheKey, item: ICacheItem): boolean {\n if (!cacheKey.typeName) {\n throw new Error(`Invalid type (${cacheKey.typeName} specified)`);\n }\n\n if (!cacheKey.key) {\n throw new Error(`Invalid key (${cacheKey.key} specified) for typeName: ${cacheKey.typeName}`);\n }\n\n item.s = item.s !== undefined ? item.s : ICacheSource.RequestCache;\n const { typeName, key } = normalizeCacheKey(cacheKey);\n if (this.internalCache[typeName] === undefined) {\n this.internalCache[typeName] = {};\n }\n return transaction(() => {\n let cacheItem: ICacheItem = >this.internalCache[typeName][key];\n\n // For updating AsyncResults, only update result\n if (cacheItem && isAsyncResult(cacheItem.item)) {\n if (cacheItem.item.status !== 'LOADING') {\n set(cacheItem.item, 'status', 'LOADING');\n }\n set(cacheItem.item, 'result', item.item);\n // Auto resolve promises whos result is being set, as they are essentially being force-completed\n set(cacheItem.item, 'status', 'SUCCESS');\n } else if (cacheItem) {\n set(cacheItem, 'item', item.item);\n } else {\n if (!isAsyncResult(item.item)) {\n cacheItem = observable>({ ...item }, undefined, {\n deep: true,\n name: `T:${typeName}_K:${key}`\n });\n } else {\n cacheItem = item;\n }\n this.internalCache[typeName][key] = cacheItem;\n }\n\n return true;\n });\n }\n\n /**\n * @function {get} - Method to get the cached item\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @return {IAny} - cached value against the given cache key\n */\n public get(cacheKey: ICacheKey): ICacheItem | undefined {\n if (!cacheKey) {\n throw new Error(`Invalid cacheKey: ${cacheKey}`);\n }\n\n if (!cacheKey.typeName) {\n throw new Error(`Invalid cacheKey type: ${cacheKey.typeName}`);\n }\n\n cacheKey = normalizeCacheKey(cacheKey);\n return this.internalCache[cacheKey.typeName] ? >this.internalCache[cacheKey.typeName][cacheKey.key] : undefined;\n }\n\n /**\n * @function {get} - Method to get the cached item\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @return {IAny} - cached value against the given cache key\n */\n public getAllItems(typeName: string): IDictionary> | undefined {\n if (!typeName) {\n throw new Error(`typeName cannot be empty`);\n }\n\n return >>this.internalCache[typeName.toUpperCase()];\n }\n\n /**\n * @function {getValue} - Method to get the cached item\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @return {IAny} - cached value against the given cache key\n */\n public getValue(cacheKey: ICacheKey): T | undefined {\n const cachedItem: ICacheItem | undefined = this.get(cacheKey);\n return cachedItem ? this._value(cachedItem) : undefined;\n }\n\n /**\n * @param cacheKey {ICacheKey} - object to build the cache key\n * @param toCache {ICache} - cache object to which the item needs to be copied\n * @return {ICacheItem} - cache item that was copied\n */\n public copyTo(cacheKey: ICacheKey, toCache: ICache): ICacheItem | undefined {\n throw new Error('Not Implemented');\n }\n\n /**\n * @function {del} - Method to delete an item from the cache\n * @param key {ICacheKey} - Array of ICacheGetData items whose values need to be deleted from cache\n * @return {number} - returns true if the cache key is deleted successfully. Does not throw errors.\n */\n public del(cacheKey: ICacheKey): boolean {\n cacheKey = normalizeCacheKey(cacheKey);\n const cacheType = this.internalCache[cacheKey.typeName];\n if (cacheType && cacheType[cacheKey.key]) {\n delete cacheType[cacheKey.key];\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @function {flushAll} - Method to flush all data from the cache\n */\n public flushAll(): void {\n this.internalCache = {};\n }\n\n /**\n * @function {keys} - Method to fetch all the keys in the cache\n * @return {string[]} - returns a list of all the keys in the cache\n */\n public keys(): string[] {\n return Object.keys(this.internalCache);\n }\n\n /**\n * Get the value out of a cache item\n * This returns the raw value of the item, it will *not* be a MobX observable value\n * @param item The observable cache item to retireve the value from\n */\n private _value(item: ICacheItem): T {\n return item.item;\n }\n}\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nexport * from './create-data-action';\nexport * from './create-data-action.vnext';\nexport * from './create-data-action-hook';\nexport * from './action-context';\nexport * from './action-executor';\nexport * from './cache/client-cache';\nexport * from './cache/simple-cache';\nexport * from './event-emitter';\nexport * from './mock-helper';\nexport * from './cache/retail-cache-helper';\nexport * from './action-registrar';\nexport * from './helpers';\nexport * from './actions/get-media-locations';\nexport * from './actions/get-additional-media-locations';\nexport * from './actions/get-customer';\n","'use strict';\nvar tryToString = require('../internals/try-to-string');\n\nvar $TypeError = TypeError;\n\nmodule.exports = function (O, P) {\n if (!delete O[P]) throw new $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O));\n};\n","'use strict';\nvar userAgent = require('../internals/engine-user-agent');\n\nvar firefox = userAgent.match(/firefox\\/(\\d+)/i);\n\nmodule.exports = !!firefox && +firefox[1];\n","'use strict';\nvar UA = require('../internals/engine-user-agent');\n\nmodule.exports = /MSIE|Trident/.test(UA);\n","'use strict';\nvar userAgent = require('../internals/engine-user-agent');\n\nvar webkit = userAgent.match(/AppleWebKit\\/(\\d+)\\./);\n\nmodule.exports = !!webkit && +webkit[1];\n","'use strict';\nvar $ = require('../internals/export');\nvar uncurryThis = require('../internals/function-uncurry-this');\nvar aCallable = require('../internals/a-callable');\nvar toObject = require('../internals/to-object');\nvar lengthOfArrayLike = require('../internals/length-of-array-like');\nvar deletePropertyOrThrow = require('../internals/delete-property-or-throw');\nvar toString = require('../internals/to-string');\nvar fails = require('../internals/fails');\nvar internalSort = require('../internals/array-sort');\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\nvar FF = require('../internals/engine-ff-version');\nvar IE_OR_EDGE = require('../internals/engine-is-ie-or-edge');\nvar V8 = require('../internals/engine-v8-version');\nvar WEBKIT = require('../internals/engine-webkit-version');\n\nvar test = [];\nvar nativeSort = uncurryThis(test.sort);\nvar push = uncurryThis(test.push);\n\n// IE8-\nvar FAILS_ON_UNDEFINED = fails(function () {\n test.sort(undefined);\n});\n// V8 bug\nvar FAILS_ON_NULL = fails(function () {\n test.sort(null);\n});\n// Old WebKit\nvar STRICT_METHOD = arrayMethodIsStrict('sort');\n\nvar STABLE_SORT = !fails(function () {\n // feature detection can be too slow, so check engines versions\n if (V8) return V8 < 70;\n if (FF && FF > 3) return;\n if (IE_OR_EDGE) return true;\n if (WEBKIT) return WEBKIT < 603;\n\n var result = '';\n var code, chr, value, index;\n\n // generate an array with more 512 elements (Chakra and old V8 fails only in this case)\n for (code = 65; code < 76; code++) {\n chr = String.fromCharCode(code);\n\n switch (code) {\n case 66: case 69: case 70: case 72: value = 3; break;\n case 68: case 71: value = 4; break;\n default: value = 2;\n }\n\n for (index = 0; index < 47; index++) {\n test.push({ k: chr + index, v: value });\n }\n }\n\n test.sort(function (a, b) { return b.v - a.v; });\n\n for (index = 0; index < test.length; index++) {\n chr = test[index].k.charAt(0);\n if (result.charAt(result.length - 1) !== chr) result += chr;\n }\n\n return result !== 'DGBEFHACIJK';\n});\n\nvar FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;\n\nvar getSortCompare = function (comparefn) {\n return function (x, y) {\n if (y === undefined) return -1;\n if (x === undefined) return 1;\n if (comparefn !== undefined) return +comparefn(x, y) || 0;\n return toString(x) > toString(y) ? 1 : -1;\n };\n};\n\n// `Array.prototype.sort` method\n// https://tc39.es/ecma262/#sec-array.prototype.sort\n$({ target: 'Array', proto: true, forced: FORCED }, {\n sort: function sort(comparefn) {\n if (comparefn !== undefined) aCallable(comparefn);\n\n var array = toObject(this);\n\n if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);\n\n var items = [];\n var arrayLength = lengthOfArrayLike(array);\n var itemsLength, index;\n\n for (index = 0; index < arrayLength; index++) {\n if (index in array) push(items, array[index]);\n }\n\n internalSort(items, getSortCompare(comparefn));\n\n itemsLength = lengthOfArrayLike(items);\n index = 0;\n\n while (index < itemsLength) array[index] = items[index++];\n while (index < arrayLength) deletePropertyOrThrow(array, index++);\n\n return array;\n }\n});\n","'use strict';\nvar $ = require('../internals/export');\nvar IS_PURE = require('../internals/is-pure');\nvar NativePromiseConstructor = require('../internals/promise-native-constructor');\nvar fails = require('../internals/fails');\nvar getBuiltIn = require('../internals/get-built-in');\nvar isCallable = require('../internals/is-callable');\nvar speciesConstructor = require('../internals/species-constructor');\nvar promiseResolve = require('../internals/promise-resolve');\nvar defineBuiltIn = require('../internals/define-built-in');\n\nvar NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;\n\n// Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829\nvar NON_GENERIC = !!NativePromiseConstructor && fails(function () {\n // eslint-disable-next-line unicorn/no-thenable -- required for testing\n NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });\n});\n\n// `Promise.prototype.finally` method\n// https://tc39.es/ecma262/#sec-promise.prototype.finally\n$({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {\n 'finally': function (onFinally) {\n var C = speciesConstructor(this, getBuiltIn('Promise'));\n var isFunction = isCallable(onFinally);\n return this.then(\n isFunction ? function (x) {\n return promiseResolve(C, onFinally()).then(function () { return x; });\n } : onFinally,\n isFunction ? function (e) {\n return promiseResolve(C, onFinally()).then(function () { throw e; });\n } : onFinally\n );\n }\n});\n\n// makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`\nif (!IS_PURE && isCallable(NativePromiseConstructor)) {\n var method = getBuiltIn('Promise').prototype['finally'];\n if (NativePromisePrototype['finally'] !== method) {\n defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });\n }\n}\n"],"names":["DEPRECATED_HOOK_TYPES","ActionRegistrar","dataActionRegister","getRegistration","id","msdyn365Commerce","getPartnerOverrideAction","partnerDataAction","default","action","prototype","Action","unwrapAction","isAction","getAction","registeredAction","registerAction","dataAction","actionRegister","registration","registerHook","hookType","hook","isBrowser","indexOf","StaticTelemetry","log","LogLevel","Warning","hooks","Array","isArray","hookRegistration","Set","forEach","h","add","newRegistration","registerPostHook","registerPreHook","registerPreReadOnlyHook","registerPostReadOnlyHook","registerPreReaderHook","registerPostReaderHook","getPreHooks","actionRegistration","pre","getPostHooks","post","getPreReadHooks","preRead","getPostReadHooks","postRead","getPreReaderHooks","preReader","getPostReaderHooks","postReader","resolveAction","resolveRegistration","preHooks","postHooks","preReadHooks","postReadHooks","preReaderHooks","postReaderHooks","createObservableDataAction","options","wrappedAction","wrapDataAction","actionWrap","Error","input","name","inputFunc","isBatched","_action","registrationId","RegistrationId","func","_isBatched","newAction","_objectSpread","setProperty","propertyName","value","arg1","arg2","AsyncResult","resolve","reject","chainAction","then","result","catch","error","ActionError","constructor","super","this","Name","message","status","Object","setPrototypeOf","shouldReadFromAppCache","appCache","undefined","dataCacheType","shouldWriteToAppCache","isAppCacheData","hasCacheSetting","getCacheObjectType","GET_FROM_RETURNIDENTIFIER","addLocaleInformation","inputs","locale","DataServiceRequest","getCacheKey","endsWith","tmp","_cacheKeyFromInput","_resolveCacheEntryReference","dataServiceRequest","item","requestCache","isWrappingPromise","isObservable","arguments","length","cacheValueAsArray","key","map","cacheObjectType","_cacheObjectType","get","typeName","copyTo","valueItem","isAsyncResult","filter","data","isReturnTypeACollection","_query","logTelemetrySource","cacheValue","cacheKey","context","telemetry","s","ICacheSource","AppCache","verboseLogger","values","RequestCache","readCacheEntriesBasedOnCacheKeyFromReturnType","cacheKeyFromReturnType","_cacheKeyFromReturnType","cacheKeyIdentifierFromReturnType","_cacheKeyIdentifierFromReturnType","entry","shouldRefresh","shouldRefreshAll","cacheEntries","Boolean","cacheEntriesReturn","readCacheEntries","cacheKeyFromInput","entries","cachedValueBasedOnInput","$ref","cachedValueBasedOnInputItem","resolvedRef","_saveEntityToCache","isCacheTypeApplication","isInstance","dataServiceRequestQuery","results","toString","call","identifierValue","existingCacheItem","existingCacheObjectType","existingCacheKeyIdentifierFromReturnType","existingCacheIsReturnTypeACollection","existingCacheTotalCount","_totalCount","type","identifier","isCollection","count","_existingCacheItem","keys","entryKey","put","instance","saveCacheEntries","metadata","_otherOdata","others","listeners","Map","eventEmitter","window","EventEmitter","on","event","callback","set","push","emit","_len","args","_key","listener","removeAllListeners","delete","defaultHookTimeoutInMS","CLIENT_HYDRATE_KEY","CLIENT_HYDRATE_TYPE","Timer","timeoutInMS","Promise","setTimeout","bind","ActionTimer","_resolve","ActionExecutor","dataActionOption","_shouldUseInstanceCache","_msdyn365Commerce$pla","checkVersionForFeature","platformSettings","shouldUseInstanceCache","eventId","uuidv1","masterInput","cacheType","shouldCacheOutput","trace","addInputs","bypassAppCache","refreshingInputs","unique","_removeDuplicates","actionId","_getActionIdFromInputs","performanceUtils","getPerformanceUtils","executionId","performanceUtilsPackage","Random","Guid","generateGuid","runPreReadonlyDataActionPerformanceHook","internalCache","cache","_executeDataAction","runPostReadonlyDataActionPerformanceHook","isRefreshingAction","_runPreReadHooks","err","_runPreReaderHooks","uncached","needsRefresh","_checkForCachedData","_fetchOutputsAndRunPostReadHook","cachedActions","includes","outputs","_executeBatchedObservableActions","_executeObservableAction","_actionWrapper","Trace","_saveResponseToCache","_checkShouldInteractWithCache","i","cacheItem","getValue","_runPostReadHooks","_runPostReaderHooks","_uniqWith","inputA","inputB","inputsActionId","getActionId","_getActionFromId","hookTimeout","Number","_get2","timer","from","reduce","async","previousTask","currentTask","race","requestContext","asSystemMetadata","exception","actionResult","prevInput","tmpNextInput","finalNextInput","prevOutput","tmpNextOutput","finalNextOutput","isRefreshing","_inputs","_runPreHooks","e","convertedError","_convertToJSError","CorrelationId","serverSideDataActionTimeoutInMs","clientSideCustomerTimeout","clientSideDataActionTimeoutInMs","promises","_errorCode","ErrorTypeEnum","SERVICE_UNAVAILABLE","ProxyError","toError","_runPostHooks","idx","appCacheData","usingInstanceCache","features","disable_instance_cache","actionName","entityId","entityType","isActionError","isTimeoutError","cacheEntry","assign","unresolvedSet","uncachedInputs","asyncOutputs","index","executor","innerResolve","innerReject","EventHelper","onEventIdFinalCompletion","cachedPromise","run","actionResults","finally","unresolvedIndex","isServiceUnavailable","cachedItem","asyncOutput","bypassCache","refreshing","_interceptCacheForMocks","clientHydrateCacheKey","isClientHydrate","runOn","refresh","disable_bypass_request_cache","existingItem","mockItem","_getMockItem","mockItemJSObject","toJS","cacheNamespace","proxyError","ErrorCode","CatalogsInput","customerAccountNumber","buildCacheKey","base","channelId","apiSettings","catalogId","user","getCatalogsAsync","callerContext","createCatalogsInput","inputData","isAuthenticated","shouldByPassCache","query","cachebypass","isPageInsightsEnabled","params","pageInsights","REFRESH_ACTIONS_CACHE_KEY","ActionContext","executionParams","cacheKeyMap","refreshConfigs","hasRun","currentActionsInQueue","nextTierCounter","next","spawnChildOnExecute","Debug","currentExecutionTier","threadId","debug","isMaxDepthExceeded","maxDepth","app","platform","getItemFromCache","_endCurrentTier","expectedActionCount","expectedActionsInCurrentTier","moduleTelemetry","Telemetry","isDebug","registerTraceLogger","traceLogger","GenericConsoleLogger","disable_app_cache","getRefreshActions","actionOption","runAllActionsInQueue","inputsArray","current","find","a","inputIdentifier","asyncResult","tierNum","refreshStartTimeInMS","splice","all","_type","update","dataArray","inputArray","preparedCacheKey","getAll","cachedEntries","getAllItems","expectedNumberOfChildThreads","nextTierStartingDepth","nextTier","refreshconfigslocal","param","execute","refreshActions","paramExecutor","actionInputs","size","disable_appcache_refresh_await","rf","refreshRequestCache","refreshContext","buildHydratedMockActionContext","MediaLocationsInput","productId","getMediaLocationsForProductAction","ctx","versionGte","process","types","require","productMediaLocations","_ctx$requestContext$a","_ctx$requestContext","getMediaLocationsAsync","queryResultSettings","Paging","Top","parseInt","defaultPageSizeForAPI","productImagesAndVideos","media","MediaTypeValue","MediaType","Image","Video","sort","b","DisplayOrder","mediaLocation","mediaLoc","Uri","generateImageUrlForOmniChanel","MediaLocationType","AdditionalMediaLocationsInput","typeFilter","All","getAdditionalMediaLocationsForProductAction","productActions","searchMediaLocationsAsync","ProductId","ChannelId","CatalogId","MediaUsageTypeValue","filteredMedia","File","AltText","GetCustomerInput","accountNumber","getCustomerActionDataAction","readAsync","response","warning","token","normalizeCacheKey","toUpperCase","transaction","observable","deep","_value","toCache","del","flushAll","tryToString","$TypeError","TypeError","module","exports","O","P","firefox","match","UA","test","webkit","$","uncurryThis","aCallable","toObject","lengthOfArrayLike","deletePropertyOrThrow","fails","internalSort","arrayMethodIsStrict","FF","IE_OR_EDGE","V8","WEBKIT","nativeSort","FAILS_ON_UNDEFINED","FAILS_ON_NULL","STRICT_METHOD","STABLE_SORT","code","chr","String","fromCharCode","k","v","charAt","target","proto","forced","comparefn","array","itemsLength","items","arrayLength","x","y","getSortCompare","IS_PURE","NativePromiseConstructor","getBuiltIn","isCallable","speciesConstructor","promiseResolve","defineBuiltIn","NativePromisePrototype","real","onFinally","C","isFunction","method","unsafe"],"sourceRoot":""}