diff --git a/dist/browser/esm/dynamics-web-api.js b/dist/browser/esm/dynamics-web-api.js index 8de62fa..bcf6838 100644 --- a/dist/browser/esm/dynamics-web-api.js +++ b/dist/browser/esm/dynamics-web-api.js @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.1.1 (c) 2023 Aleksandr Rogov */ +/*! dynamics-web-api v2.1.2 (c) 2023 Aleksandr Rogov */ var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; @@ -62,7 +62,7 @@ var init_Utility = __esm({ init_Crypto(); init_Regex(); downloadChunkSize = 4194304; - _Utility = class { + _Utility = class _Utility { /** * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]' * @@ -231,9 +231,9 @@ var init_Utility = __esm({ return bytes; } }; - Utility = _Utility; // static isNodeEnv = isNodeEnv; - Utility.downloadChunkSize = downloadChunkSize; + _Utility.downloadChunkSize = downloadChunkSize; + Utility = _Utility; } }); @@ -248,7 +248,7 @@ var init_ErrorHelper = __esm({ "src/helpers/ErrorHelper.ts"() { "use strict"; init_Regex(); - ErrorHelper = class { + ErrorHelper = class _ErrorHelper { static handleErrorResponse(req) { throw new Error(`Error: ${req.status}: ${req.message}`); } @@ -328,7 +328,7 @@ var init_ErrorHelper = __esm({ } static keyParameterCheck(parameter, functionName, parameterName) { try { - ErrorHelper.stringParameterCheck(parameter, functionName, parameterName); + _ErrorHelper.stringParameterCheck(parameter, functionName, parameterName); const match = extractUuid(parameter); if (match) return match; @@ -371,15 +371,15 @@ var _a, _b, _DWA, DWA; var init_dwa = __esm({ "src/dwa.ts"() { "use strict"; - _DWA = class { + _DWA = class _DWA { }; - DWA = _DWA; - DWA.Prefer = (_b = class { + _DWA.Prefer = (_b = class { static get(annotation) { return `${_DWA.Prefer.IncludeAnnotations}="${annotation}"`; } }, _b.ReturnRepresentation = "return=representation", _b.Annotations = (_a = class { }, _a.AssociatedNavigationProperty = "Microsoft.Dynamics.CRM.associatednavigationproperty", _a.LookupLogicalName = "Microsoft.Dynamics.CRM.lookuplogicalname", _a.All = "*", _a.FormattedValue = "OData.Community.Display.V1.FormattedValue", _a.FetchXmlPagingCookie = "Microsoft.Dynamics.CRM.fetchxmlpagingcookie", _a), _b.IncludeAnnotations = "odata.include-annotations", _b); + DWA = _DWA; } }); @@ -839,11 +839,11 @@ init_Utility(); init_ErrorHelper(); var getApiUrl = (serverUrl, apiConfig) => { if (Utility.isRunningWithinPortals()) { - return `${window.location.origin}/_api/`; + return new URL("_api", window.location.origin).toString() + "/"; } else { if (!serverUrl) serverUrl = Utility.getClientUrl(); - return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`; + return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + "/"; } }; var mergeApiConfigs = (apiConfig, apiType, internalConfig) => { @@ -947,7 +947,7 @@ init_Utility(); // src/utils/Request.ts init_Utility(); init_ErrorHelper(); -var _RequestUtility = class { +var _RequestUtility = class _RequestUtility { /** * Converts a request object to URL link * @@ -991,7 +991,6 @@ var _RequestUtility = class { } else { ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, "request.url"); request.path = request.url.replace(config.dataApi.url, ""); - request.path = _RequestUtility.composeUrl(request, config, request.path); } if (request.hasOwnProperty("async") && request.async != null) { ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, "request.async"); @@ -1422,8 +1421,8 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); return headers; } }; +_RequestUtility.entityNames = null; var RequestUtility = _RequestUtility; -RequestUtility.entityNames = null; // src/client/RequestClient.ts init_ErrorHelper(); @@ -1465,7 +1464,7 @@ var _runRequest = async (request, config) => { }; var _batchRequestCollection = {}; var _responseParseParams = {}; -var RequestClient = class { +var RequestClient = class _RequestClient { /** * Sends a request to given URL with given parameters * @@ -1513,7 +1512,7 @@ var RequestClient = class { const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url; return await executeRequest2({ method: request.method, - uri: url + request.path, + uri: url.toString() + request.path, data: processedData, additionalHeaders: request.headers, responseParams: _responseParseParams, @@ -1559,7 +1558,7 @@ var RequestClient = class { return exceptions.indexOf(entityName) > -1; } static async _checkCollectionName(entityName, config) { - if (!entityName || RequestClient._isEntityNameException(entityName)) { + if (!entityName || _RequestClient._isEntityNameException(entityName)) { return entityName; } entityName = entityName.toLowerCase(); @@ -1567,7 +1566,7 @@ var RequestClient = class { return entityName; } try { - return await RequestClient._getCollectionNames(entityName, config); + return await _RequestClient._getCollectionNames(entityName, config); } catch (error) { throw new Error("Unable to fetch Collection Names. Error: " + error.message); } @@ -1577,7 +1576,7 @@ var RequestClient = class { request.userHeaders = request.headers; delete request.headers; if (!request.isBatch) { - const collectionName = await RequestClient._checkCollectionName(request.collection, config); + const collectionName = await _RequestClient._checkCollectionName(request.collection, config); request.collection = collectionName; RequestUtility.compose(request, config); request.responseParameters.convertedToBatch = false; @@ -1606,7 +1605,7 @@ var RequestClient = class { }; // src/dynamics-web-api.ts -var DynamicsWebApi = class { +var DynamicsWebApi = class _DynamicsWebApi { /** * Initializes a new instance of DynamicsWebApi * @param config - Configuration object @@ -2505,19 +2504,19 @@ var DynamicsWebApi = class { return response?.data; }; /** - * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance. + * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance. * - * @param {Config} config - configuration object. - * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi + * @param {Config} config configuration object. + * @returns {DynamicsWebApi} A new instance of DynamicsWebApi */ - this.initializeInstance = (config) => new DynamicsWebApi(config || this._config); + this.initializeInstance = (config) => new _DynamicsWebApi(config || this._config); this.Utility = { /** * Searches for a collection name by provided entity name in a cached entity metadata. * The returned collection name can be null. * - * @param {string} entityName - entity name - * @returns {string | null} a collection name + * @param {string} entityName entity name + * @returns {string | null} collection name */ getCollectionName: (entityName) => RequestClient.getCollectionName(entityName) }; diff --git a/dist/browser/esm/dynamics-web-api.js.map b/dist/browser/esm/dynamics-web-api.js.map index 6520361..853bb04 100644 --- a/dist/browser/esm/dynamics-web-api.js.map +++ b/dist/browser/esm/dynamics-web-api.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../../src/helpers/Crypto.ts", "../../../src/helpers/Regex.ts", "../../../src/utils/Utility.ts", "../../../src/helpers/ErrorHelper.ts", "../../../src/dwa.ts", "../../../src/client/helpers/dateReviver.ts", "../../../src/client/helpers/parseResponse.ts", "../../../src/client/helpers/parseResponseHeaders.ts", "../../../src/client/xhr.ts", "../../../src/utils/Config.ts", "../../../src/dynamics-web-api.ts", "../../../src/client/RequestClient.ts", "../../../src/utils/Request.ts", "../../../src/client/helpers/executeRequest.ts"], - "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): any {\r\n\tconst headers = {};\r\n\tif (!headerStr) {\r\n\t\treturn headers;\r\n\t}\r\n\tconst headerPairs = headerStr.split(\"\\u000d\\u000a\");\r\n\tfor (let i = 0, ilen = headerPairs.length; i < ilen; i++) {\r\n\t\tconst headerPair = headerPairs[i];\r\n\t\tconst index = headerPair.indexOf(\"\\u003a\\u0020\");\r\n\t\tif (index > 0) {\r\n\t\t\theaders[headerPair.substring(0, index)] = headerPair.substring(index + 2);\r\n\t\t}\r\n\t}\r\n\treturn headers;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\nimport { parseResponseHeaders } from \"./helpers/parseResponseHeaders\";\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n if (signal?.aborted) {\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n message: \"The user aborted a request.\",\r\n })\r\n );\r\n\r\n return;\r\n }\r\n\r\n let request = new XMLHttpRequest();\r\n request.open(options.method, options.uri, options.isAsync || false);\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n request.setRequestHeader(key, additionalHeaders[key]);\r\n }\r\n\r\n request.onreadystatechange = function () {\r\n if (request.readyState === 4) {\r\n if (signal) signal.removeEventListener(\"abort\", abort);\r\n\r\n switch (request.status) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: // Success with partial content.\r\n case 304: {\r\n // Success with Not Modified\r\n const responseHeaders = parseResponseHeaders(request.getAllResponseHeaders());\r\n const responseData = parseResponse(request.responseText, responseHeaders, responseParams[options.requestId]);\r\n\r\n const response = {\r\n data: responseData,\r\n headers: responseHeaders,\r\n status: request.status,\r\n };\r\n\r\n request = null as any;\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n case 0:\r\n break; //response will be handled by onerror\r\n default:\r\n if (!request) break; //response was handled somewhere else\r\n\r\n // All other statuses are error cases.\r\n let error;\r\n let headers;\r\n try {\r\n headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n const errorParsed = parseResponse(request.responseText, headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n error = errorParsed.error;\r\n } catch (e) {\r\n if (request.response.length > 0) {\r\n error = { message: request.response };\r\n } else {\r\n error = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n const errorParameters = {\r\n status: request.status,\r\n statusText: request.statusText,\r\n headers: headers,\r\n };\r\n\r\n request = null as any;\r\n\r\n errorCallback(ErrorHelper.handleHttpError(error, errorParameters));\r\n\r\n break;\r\n }\r\n }\r\n };\r\n\r\n if (options.timeout) {\r\n request.timeout = options.timeout;\r\n }\r\n\r\n request.onerror = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Network Error\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n request.ontimeout = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"TimeoutError\",\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Request Timed Out\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //browser abort\r\n request.onabort = function () {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"Request aborted\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //manual abort/cancellation\r\n const abort = () => {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"The user aborted a request.\",\r\n headers: headers,\r\n })\r\n );\r\n\r\n request.abort();\r\n\r\n request = null as any;\r\n };\r\n\r\n if (signal) {\r\n signal.addEventListener(\"abort\", abort);\r\n }\r\n\r\n data ? request.send(data) : request.send();\r\n\r\n //called for testing\r\n if (XhrWrapper.afterSendEvent) XhrWrapper.afterSendEvent();\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n */\r\nexport class XhrWrapper {\r\n //for testing\r\n static afterSendEvent: () => void;\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return `${global.window.location.origin}/_api/`;\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`;\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\",\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\",\r\n },\r\n };\r\n }\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance.\r\n *\r\n * @param {Config} config - configuration object.\r\n * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName - entity name\r\n * @returns {string | null} a collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n oDataContext?: string;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,YAAwB;AACpC,SAAO,OAAqB,OAAc,SAAS,KAAyB,UAAU;AAC1F;AAEO,SAAS,sBAAsB;AAClC,SAAO,OAAqB,UAAU,EAAE,gBAAgB,IAAI,WAAW,CAAC,CAAC,IAAI,UAAU,EAAE,YAAY,CAAC;AAC1G;AANA;AAAA;AAAA;AAAA;AAAA;;;ACEO,SAAS,OAAO,OAAwB;AAC3C,QAAM,QAAQ,IAAI,OAAO,MAAM,GAAG,EAAE,KAAK,KAAK;AAC9C,SAAO,CAAC,CAAC;AACb;AAEO,SAAS,YAAY,OAA8B;AACtD,QAAM,QAAQ,IAAI,OAAO,SAAS,OAAO,QAAQ,GAAG,EAAE,KAAK,KAAK;AAChE,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,mBAAmB,KAA4B;AAC3D,QAAM,QAAQ,IAAI,OAAO,MAAM,OAAO,SAAS,GAAG,EAAE,KAAK,GAAG;AAC5D,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAfA,IAAM;AAAN;AAAA;AAAA;AAAA,IAAM,OAAO;AAAA;AAAA;;;ACAb,IAgBM,mBAEO;AAlBb;AAAA;AAAA;AACA;AACA;AAcA,IAAM,oBAAoB;AAEnB,IAAM,WAAN,MAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOjB,OAAO,wBAAwB,YAA0B;AACrD,YAAI,YAAY;AACZ,gBAAM,iBAAiB,OAAO,KAAK,UAAU;AAC7C,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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,cAAc,kBAAkB,UAAU;AAAA,IACxG;AArnCI,yBAAqB,MAAM,KAAK,SAAS,MAAM;AAAA,EACnD;AAqnCJ;", + "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): any {\r\n\tconst headers = {};\r\n\tif (!headerStr) {\r\n\t\treturn headers;\r\n\t}\r\n\tconst headerPairs = headerStr.split(\"\\u000d\\u000a\");\r\n\tfor (let i = 0, ilen = headerPairs.length; i < ilen; i++) {\r\n\t\tconst headerPair = headerPairs[i];\r\n\t\tconst index = headerPair.indexOf(\"\\u003a\\u0020\");\r\n\t\tif (index > 0) {\r\n\t\t\theaders[headerPair.substring(0, index)] = headerPair.substring(index + 2);\r\n\t\t}\r\n\t}\r\n\treturn headers;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\nimport { parseResponseHeaders } from \"./helpers/parseResponseHeaders\";\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n if (signal?.aborted) {\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n message: \"The user aborted a request.\",\r\n })\r\n );\r\n\r\n return;\r\n }\r\n\r\n let request = new XMLHttpRequest();\r\n request.open(options.method, options.uri, options.isAsync || false);\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n request.setRequestHeader(key, additionalHeaders[key]);\r\n }\r\n\r\n request.onreadystatechange = function () {\r\n if (request.readyState === 4) {\r\n if (signal) signal.removeEventListener(\"abort\", abort);\r\n\r\n switch (request.status) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: // Success with partial content.\r\n case 304: {\r\n // Success with Not Modified\r\n const responseHeaders = parseResponseHeaders(request.getAllResponseHeaders());\r\n const responseData = parseResponse(request.responseText, responseHeaders, responseParams[options.requestId]);\r\n\r\n const response = {\r\n data: responseData,\r\n headers: responseHeaders,\r\n status: request.status,\r\n };\r\n\r\n request = null as any;\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n case 0:\r\n break; //response will be handled by onerror\r\n default:\r\n if (!request) break; //response was handled somewhere else\r\n\r\n // All other statuses are error cases.\r\n let error;\r\n let headers;\r\n try {\r\n headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n const errorParsed = parseResponse(request.responseText, headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n error = errorParsed.error;\r\n } catch (e) {\r\n if (request.response.length > 0) {\r\n error = { message: request.response };\r\n } else {\r\n error = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n const errorParameters = {\r\n status: request.status,\r\n statusText: request.statusText,\r\n headers: headers,\r\n };\r\n\r\n request = null as any;\r\n\r\n errorCallback(ErrorHelper.handleHttpError(error, errorParameters));\r\n\r\n break;\r\n }\r\n }\r\n };\r\n\r\n if (options.timeout) {\r\n request.timeout = options.timeout;\r\n }\r\n\r\n request.onerror = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Network Error\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n request.ontimeout = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"TimeoutError\",\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Request Timed Out\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //browser abort\r\n request.onabort = function () {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"Request aborted\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //manual abort/cancellation\r\n const abort = () => {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"The user aborted a request.\",\r\n headers: headers,\r\n })\r\n );\r\n\r\n request.abort();\r\n\r\n request = null as any;\r\n };\r\n\r\n if (signal) {\r\n signal.addEventListener(\"abort\", abort);\r\n }\r\n\r\n data ? request.send(data) : request.send();\r\n\r\n //called for testing\r\n if (XhrWrapper.afterSendEvent) XhrWrapper.afterSendEvent();\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n */\r\nexport class XhrWrapper {\r\n //for testing\r\n static afterSendEvent: () => void;\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\"\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\"\r\n },\r\n };\r\n }\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance.\r\n *\r\n * @param {Config} config configuration object.\r\n * @returns {DynamicsWebApi} A new instance of DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName entity name\r\n * @returns {string | null} collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n \"@odata.count\"?: number;\r\n oDataContext?: string;\r\n \"@odata.context\"?: number;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n \"@odata.deltaLink\"?: string;\r\n \"@odata.nextLink\"?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url!.toString() + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BRO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zF,sBAAgB,aAAa;AAC7B,sBAAgB,SAAS;AACzB,sBAAgB,eAAe;AAC/B,sBAAgB,YAAY,KAAK;AAEjC,WAAK,kBAAkB;AACvB,WAAK,WAAW;AAEhB,YAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,aAAO,UAAU;AAAA,IACrB;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,KAAK,OAAO;AAEnG,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,cAAc,kBAAkB,UAAU;AAAA,IACxG;AArnCI,yBAAqB,MAAM,KAAK,SAAS,MAAM;AAAA,EACnD;AAqnCJ;", "names": ["executeRequest", "executeRequest", "request"] } diff --git a/dist/cjs/dynamics-web-api.js b/dist/cjs/dynamics-web-api.js index 0081816..c3a6290 100644 --- a/dist/cjs/dynamics-web-api.js +++ b/dist/cjs/dynamics-web-api.js @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.1.1 (c) 2023 Aleksandr Rogov */ +/*! dynamics-web-api v2.1.2 (c) 2023 Aleksandr Rogov */ "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; @@ -69,8 +69,8 @@ function extractUuid(value) { const match = new RegExp("^{?(" + uuid + ")}?$", "i").exec(value); return match ? match[1] : null; } -function extractUuidFromUrl(url2) { - const match = new RegExp("(" + uuid + ")\\)$", "i").exec(url2); +function extractUuidFromUrl(url) { + const match = new RegExp("(" + uuid + ")\\)$", "i").exec(url); return match ? match[1] : null; } var uuid; @@ -89,7 +89,7 @@ var init_Utility = __esm({ init_Crypto(); init_Regex(); downloadChunkSize = 4194304; - _Utility = class { + _Utility = class _Utility { /** * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]' * @@ -258,9 +258,9 @@ var init_Utility = __esm({ return bytes; } }; - Utility = _Utility; // static isNodeEnv = isNodeEnv; - Utility.downloadChunkSize = downloadChunkSize; + _Utility.downloadChunkSize = downloadChunkSize; + Utility = _Utility; } }); @@ -275,7 +275,7 @@ var init_ErrorHelper = __esm({ "src/helpers/ErrorHelper.ts"() { "use strict"; init_Regex(); - ErrorHelper = class { + ErrorHelper = class _ErrorHelper { static handleErrorResponse(req) { throw new Error(`Error: ${req.status}: ${req.message}`); } @@ -355,7 +355,7 @@ var init_ErrorHelper = __esm({ } static keyParameterCheck(parameter, functionName, parameterName) { try { - ErrorHelper.stringParameterCheck(parameter, functionName, parameterName); + _ErrorHelper.stringParameterCheck(parameter, functionName, parameterName); const match = extractUuid(parameter); if (match) return match; @@ -398,15 +398,15 @@ var _a, _b, _DWA, DWA; var init_dwa = __esm({ "src/dwa.ts"() { "use strict"; - _DWA = class { + _DWA = class _DWA { }; - DWA = _DWA; - DWA.Prefer = (_b = class { + _DWA.Prefer = (_b = class { static get(annotation) { return `${_DWA.Prefer.IncludeAnnotations}="${annotation}"`; } }, _b.ReturnRepresentation = "return=representation", _b.Annotations = (_a = class { }, _a.AssociatedNavigationProperty = "Microsoft.Dynamics.CRM.associatednavigationproperty", _a.LookupLogicalName = "Microsoft.Dynamics.CRM.lookuplogicalname", _a.All = "*", _a.FormattedValue = "OData.Community.Display.V1.FormattedValue", _a.FetchXmlPagingCookie = "Microsoft.Dynamics.CRM.fetchxmlpagingcookie", _a), _b.IncludeAnnotations = "odata.include-annotations", _b); + DWA = _DWA; } }); @@ -701,13 +701,13 @@ function _executeRequest(options, successCallback, errorCallback) { for (let key in additionalHeaders) { headers[key] = additionalHeaders[key]; } - const parsedUrl = url.parse(options.uri); + const parsedUrl = new URL(options.uri); const protocol = ((_a2 = parsedUrl.protocol) == null ? void 0 : _a2.slice(0, -1)) || "https"; const protocolInterface = protocol === "http" ? http : https; const internalOptions = { hostname: parsedUrl.hostname, port: parsedUrl.port, - path: parsedUrl.path, + path: parsedUrl.pathname + parsedUrl.search, method: options.method, timeout: options.timeout || 0, headers, @@ -787,13 +787,12 @@ function _executeRequest(options, successCallback, errorCallback) { } request.end(); } -var http, https, url, import_http_proxy_agent, import_https_proxy_agent, agents, getAgent; +var http, https, import_http_proxy_agent, import_https_proxy_agent, agents, getAgent; var init_http = __esm({ "src/client/http.ts"() { "use strict"; http = __toESM(require("http")); https = __toESM(require("https")); - url = __toESM(require("url")); import_http_proxy_agent = __toESM(require("http-proxy-agent")); import_https_proxy_agent = __toESM(require("https-proxy-agent")); init_ErrorHelper(); @@ -842,11 +841,11 @@ init_Utility(); init_ErrorHelper(); var getApiUrl = (serverUrl, apiConfig) => { if (Utility.isRunningWithinPortals()) { - return `${global.window.location.origin}/_api/`; + return new URL("_api", global.window.location.origin).toString() + "/"; } else { if (!serverUrl) serverUrl = Utility.getClientUrl(); - return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`; + return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + "/"; } }; var mergeApiConfigs = (apiConfig, apiType, internalConfig) => { @@ -950,7 +949,7 @@ init_Utility(); // src/utils/Request.ts init_Utility(); init_ErrorHelper(); -var _RequestUtility = class { +var _RequestUtility = class _RequestUtility { /** * Converts a request object to URL link * @@ -994,7 +993,6 @@ var _RequestUtility = class { } else { ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, "request.url"); request.path = request.url.replace(config.dataApi.url, ""); - request.path = _RequestUtility.composeUrl(request, config, request.path); } if (request.hasOwnProperty("async") && request.async != null) { ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, "request.async"); @@ -1014,20 +1012,20 @@ var _RequestUtility = class { * @param {Object} [config] - DynamicsWebApi config * @returns {ConvertedRequestOptions} Additional options in request */ - static composeUrl(request, config, url2 = "", joinSymbol = "&") { + static composeUrl(request, config, url = "", joinSymbol = "&") { var _a2, _b2, _c; const queryArray = []; if (request) { if (request.navigationProperty) { ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, "request.navigationProperty"); - url2 += "/" + request.navigationProperty; + url += "/" + request.navigationProperty; if (request.navigationPropertyKey) { let navigationKey = ErrorHelper.keyParameterCheck( request.navigationPropertyKey, `DynamicsWebApi.${request.functionName}`, "request.navigationPropertyKey" ); - url2 += "(" + navigationKey + ")"; + url += "(" + navigationKey + ")"; } if (request.navigationProperty === "Attributes") { if (request.metadataAttributeType) { @@ -1036,18 +1034,18 @@ var _RequestUtility = class { `DynamicsWebApi.${request.functionName}`, "request.metadataAttributeType" ); - url2 += "/" + request.metadataAttributeType; + url += "/" + request.metadataAttributeType; } } } if ((_a2 = request.select) == null ? void 0 : _a2.length) { ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, "request.select"); if (request.functionName == "retrieve" && request.select.length == 1 && request.select[0].endsWith("/$ref")) { - url2 += "/" + request.select[0]; + url += "/" + request.select[0]; } else { if (request.select[0].startsWith("/") && request.functionName == "retrieve") { if (request.navigationProperty == null) { - url2 += request.select.shift(); + url += request.select.shift(); } else { request.select.shift(); } @@ -1073,7 +1071,7 @@ var _RequestUtility = class { } if (request.fieldName) { ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, "request.fieldName"); - url2 += "/" + request.fieldName; + url += "/" + request.fieldName; } if (request.savedQuery) { queryArray.push( @@ -1154,7 +1152,7 @@ var _RequestUtility = class { } } } - return !queryArray.length ? url2 : url2 + "?" + queryArray.join(joinSymbol); + return !queryArray.length ? url : url + "?" + queryArray.join(joinSymbol); } static composeHeaders(request, config) { const headers = { ...config.headers, ...request.userHeaders }; @@ -1427,8 +1425,8 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); return headers; } }; +_RequestUtility.entityNames = null; var RequestUtility = _RequestUtility; -RequestUtility.entityNames = null; // src/client/RequestClient.ts init_ErrorHelper(); @@ -1470,7 +1468,7 @@ var _runRequest = async (request, config) => { }; var _batchRequestCollection = {}; var _responseParseParams = {}; -var RequestClient = class { +var RequestClient = class _RequestClient { /** * Sends a request to given URL with given parameters * @@ -1516,10 +1514,10 @@ var RequestClient = class { if (Utility.isRunningWithinPortals()) { request.headers["__RequestVerificationToken"] = await global.window.shell.getTokenDeferred(); } - const url2 = request.apiConfig ? request.apiConfig.url : config.dataApi.url; + const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url; return await executeRequest2({ method: request.method, - uri: url2 + request.path, + uri: url.toString() + request.path, data: processedData, additionalHeaders: request.headers, responseParams: _responseParseParams, @@ -1565,7 +1563,7 @@ var RequestClient = class { return exceptions.indexOf(entityName) > -1; } static async _checkCollectionName(entityName, config) { - if (!entityName || RequestClient._isEntityNameException(entityName)) { + if (!entityName || _RequestClient._isEntityNameException(entityName)) { return entityName; } entityName = entityName.toLowerCase(); @@ -1573,7 +1571,7 @@ var RequestClient = class { return entityName; } try { - return await RequestClient._getCollectionNames(entityName, config); + return await _RequestClient._getCollectionNames(entityName, config); } catch (error) { throw new Error("Unable to fetch Collection Names. Error: " + error.message); } @@ -1583,7 +1581,7 @@ var RequestClient = class { request.userHeaders = request.headers; delete request.headers; if (!request.isBatch) { - const collectionName = await RequestClient._checkCollectionName(request.collection, config); + const collectionName = await _RequestClient._checkCollectionName(request.collection, config); request.collection = collectionName; RequestUtility.compose(request, config); request.responseParameters.convertedToBatch = false; @@ -1612,7 +1610,7 @@ var RequestClient = class { }; // src/dynamics-web-api.ts -var DynamicsWebApi = class { +var DynamicsWebApi = class _DynamicsWebApi { /** * Initializes a new instance of DynamicsWebApi * @param config - Configuration object @@ -2513,19 +2511,19 @@ var DynamicsWebApi = class { return response == null ? void 0 : response.data; }; /** - * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance. + * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance. * - * @param {Config} config - configuration object. - * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi + * @param {Config} config configuration object. + * @returns {DynamicsWebApi} A new instance of DynamicsWebApi */ - this.initializeInstance = (config) => new DynamicsWebApi(config || this._config); + this.initializeInstance = (config) => new _DynamicsWebApi(config || this._config); this.Utility = { /** * Searches for a collection name by provided entity name in a cached entity metadata. * The returned collection name can be null. * - * @param {string} entityName - entity name - * @returns {string | null} a collection name + * @param {string} entityName entity name + * @returns {string | null} collection name */ getCollectionName: (entityName) => RequestClient.getCollectionName(entityName) }; diff --git a/dist/cjs/dynamics-web-api.js.map b/dist/cjs/dynamics-web-api.js.map index c610f85..c3cba13 100644 --- a/dist/cjs/dynamics-web-api.js.map +++ b/dist/cjs/dynamics-web-api.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/helpers/crypto/node.ts", "../../src/helpers/Crypto.ts", "../../src/helpers/Regex.ts", "../../src/utils/Utility.ts", "../../src/helpers/ErrorHelper.ts", "../../src/dwa.ts", "../../src/client/helpers/dateReviver.ts", "../../src/client/helpers/parseResponse.ts", "../../src/client/http.ts", "../../src/dynamics-web-api.ts", "../../src/utils/Config.ts", "../../src/client/RequestClient.ts", "../../src/utils/Request.ts", "../../src/client/helpers/executeRequest.ts"], - "sourcesContent": ["//had to move getCrypto for node to a different local module,\r\n//because esbuild does not support external require in esm format\r\nimport nCrypto from \"node:crypto\";\r\n\r\nexport function getCrypto () {\r\n return nCrypto;\r\n}", "export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFimport * as http from \"http\";\r\nimport * as https from \"https\";\r\nimport * as url from \"url\";\r\nimport HttpProxyAgent from \"http-proxy-agent\";\r\nimport HttpsProxyAgent from \"https-proxy-agent\";\r\nimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\n\r\nconst agents: { [key: string]: http.Agent } = {};\r\n\r\nconst getAgent = (options: Core.RequestOptions, protocol: string): http.Agent => {\r\n const isHttp = protocol === \"http\";\r\n const proxy = options.proxy;\r\n const agentName = proxy ? proxy.url : protocol;\r\n\r\n if (!agents[agentName]) {\r\n if (proxy) {\r\n const parsedProxyUrl = new URL(proxy.url);\r\n const proxyAgent = isHttp ? HttpProxyAgent.HttpProxyAgent : HttpsProxyAgent.HttpsProxyAgent;\r\n\r\n const proxyOptions: HttpProxyAgent.HttpProxyAgentOptions | HttpsProxyAgent.HttpsProxyAgentOptions = {\r\n host: parsedProxyUrl.hostname,\r\n port: parsedProxyUrl.port,\r\n protocol: parsedProxyUrl.protocol,\r\n };\r\n\r\n if (proxy.auth) proxyOptions.auth = proxy.auth.username + \":\" + proxy.auth.password;\r\n else if (parsedProxyUrl.username && parsedProxyUrl.password) proxyOptions.auth = `${parsedProxyUrl.username}:${parsedProxyUrl.password}`;\r\n\r\n agents[agentName] = new proxyAgent(proxyOptions);\r\n } else {\r\n const protocolInterface = isHttp ? http : https;\r\n\r\n agents[agentName] = new protocolInterface.Agent({\r\n keepAlive: true,\r\n maxSockets: Infinity,\r\n });\r\n }\r\n }\r\n\r\n return agents[agentName];\r\n};\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n *\r\n */\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n const headers: http.OutgoingHttpHeaders = {};\r\n\r\n if (data) {\r\n headers[\"Content-Type\"] = additionalHeaders[\"Content-Type\"];\r\n headers[\"Content-Length\"] = data.length;\r\n\r\n delete additionalHeaders[\"Content-Type\"];\r\n }\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n headers[key] = additionalHeaders[key];\r\n }\r\n const parsedUrl = url.parse(options.uri);\r\n const protocol = parsedUrl.protocol?.slice(0, -1) || \"https\";\r\n const protocolInterface = protocol === \"http\" ? http : https;\r\n\r\n const internalOptions: http.RequestOptions = {\r\n hostname: parsedUrl.hostname,\r\n port: parsedUrl.port,\r\n path: parsedUrl.path,\r\n method: options.method,\r\n timeout: options.timeout || 0,\r\n headers: headers,\r\n signal: signal,\r\n };\r\n\r\n //support environment variables\r\n if (!options.proxy && process.env[`${protocol}_proxy`]) {\r\n options.proxy = {\r\n url: process.env[`${protocol}_proxy`]!,\r\n };\r\n }\r\n\r\n internalOptions.agent = getAgent(options, protocol);\r\n\r\n if (options.proxy) {\r\n const hostHeader =new URL(options.proxy.url).host;\r\n if (hostHeader) headers.host = hostHeader;\r\n }\r\n\r\n const request = protocolInterface.request(internalOptions, function (res) {\r\n let rawData = \"\";\r\n res.setEncoding(\"utf8\");\r\n res.on(\"data\", function (chunk) {\r\n rawData += chunk;\r\n });\r\n res.on(\"end\", function () {\r\n switch (res.statusCode) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: //Success with partial content\r\n case 304: {\r\n // Success with Not Modified\r\n let responseData = parseResponse(rawData, res.headers, responseParams[options.requestId]);\r\n\r\n let response = {\r\n data: responseData,\r\n headers: res.headers as any,\r\n status: res.statusCode,\r\n };\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n default:\r\n // All other statuses are error cases.\r\n let crmError;\r\n try {\r\n var errorParsed = parseResponse(rawData, res.headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n crmError = errorParsed.hasOwnProperty(\"error\") && errorParsed.error ? errorParsed.error : { message: errorParsed.Message };\r\n } catch (e) {\r\n if (rawData.length > 0) {\r\n crmError = { message: rawData };\r\n } else {\r\n crmError = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError(crmError, {\r\n status: res.statusCode,\r\n statusText: \"\",\r\n statusMessage: res.statusMessage,\r\n headers: res.headers,\r\n })\r\n );\r\n break;\r\n }\r\n });\r\n });\r\n\r\n if (internalOptions.timeout) {\r\n request.setTimeout(internalOptions.timeout, function () {\r\n request.destroy();\r\n });\r\n }\r\n\r\n request.on(\"error\", function (error) {\r\n errorCallback(error);\r\n });\r\n\r\n if (data) {\r\n request.write(data);\r\n }\r\n\r\n request.end();\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance.\r\n *\r\n * @param {Config} config - configuration object.\r\n * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName - entity name\r\n * @returns {string | null} a collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n oDataContext?: string;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return `${global.window.location.origin}/_api/`;\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`;\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\",\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\",\r\n },\r\n };\r\n }\r\n}\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAIO,SAAS,YAAa;AACzB,SAAO,mBAAAA;AACX;AANA,IAEA;AAFA;AAAA;AAAA;AAEA,yBAAoB;AAAA;AAAA;;;ACFb,SAASC,aAAwB;AACpC,SAAO,QAAqB,OAAO,OAAO,SAAS,0CAAyB,UAAU;AAC1F;AAEO,SAAS,sBAAsB;AAClC,SAAO,QAAqBA,WAAU,EAAE,gBAAgB,IAAI,WAAW,CAAC,CAAC,IAAIA,WAAU,EAAE,YAAY,CAAC;AAC1G;AANA;AAAA;AAAA;AAAA;AAAA;;;ACEO,SAAS,OAAO,OAAwB;AAC3C,QAAM,QAAQ,IAAI,OAAO,MAAM,GAAG,EAAE,KAAK,KAAK;AAC9C,SAAO,CAAC,CAAC;AACb;AAEO,SAAS,YAAY,OAA8B;AACtD,QAAM,QAAQ,IAAI,OAAO,SAAS,OAAO,QAAQ,GAAG,EAAE,KAAK,KAAK;AAChE,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,mBAAmBC,MAA4B;AAC3D,QAAM,QAAQ,IAAI,OAAO,MAAM,OAAO,SAAS,GA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AAY,KAAK,QAAQ;AAEzC,aAAO,gBAAgB;AAEvB,YAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,aAAO,qCAAU;AAAA,IACrB;AAKA;AAAA;AAAA;AAAA,sBAAa,MAAY;AACrB,WAAK,WAAW;AAChB,WAAK,kBAAkB,QAAQ,aAAa;AAAA,IAChD;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe,OAAO,YAA2C;AAC7D,kBAAY,qBAAqB,KAAK,QAAQ;AAE9C,YAAM,kBAAwC,CAAC,UAAU,CAAC,IAAI,QAAQ,YAAY,OAAO;AAEzF,sBAAgB,aAAa;AAC7B,sBAAgB,SAAS;AACzB,sBAAgB,eAAe;AAC/B,sBAAgB,YAAY,KAAK;AAEjC,WAAK,kBAAkB;AACvB,WAAK,WAAW;AAEhB,YAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,aAAO,qCAAU;AAAA,IACrB;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,eAAe,UAAU,KAAK,OAAO;AAEnG,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,cAAc,kBAAkB,UAAU;AAAA,IACxG;AArnCI,yBAAqB,MAAM,KAAK,SAAS,MAAM;AAAA,EACnD;AAqnCJ;", - "names": ["nCrypto", "getCrypto", "url", "_a", "HttpProxyAgent", "HttpsProxyAgent", "url", "_a", "_b", "executeRequest", "_a", "url", "executeRequest", "_a", "request"] + "sourcesContent": ["//had to move getCrypto for node to a different local module,\r\n//because esbuild does not support external require in esm format\r\nimport nCrypto from \"node:crypto\";\r\n\r\nexport function getCrypto () {\r\n return nCrypto;\r\n}", "export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFimport * as http from \"http\";\r\nimport * as https from \"https\";\r\nimport HttpProxyAgent from \"http-proxy-agent\";\r\nimport HttpsProxyAgent from \"https-proxy-agent\";\r\nimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\n\r\nconst agents: { [key: string]: http.Agent } = {};\r\n\r\nconst getAgent = (options: Core.RequestOptions, protocol: string): http.Agent => {\r\n const isHttp = protocol === \"http\";\r\n const proxy = options.proxy;\r\n const agentName = proxy ? proxy.url : protocol;\r\n\r\n if (!agents[agentName]) {\r\n if (proxy) {\r\n const parsedProxyUrl = new URL(proxy.url);\r\n const proxyAgent = isHttp ? HttpProxyAgent.HttpProxyAgent : HttpsProxyAgent.HttpsProxyAgent;\r\n\r\n const proxyOptions: HttpProxyAgent.HttpProxyAgentOptions | HttpsProxyAgent.HttpsProxyAgentOptions = {\r\n host: parsedProxyUrl.hostname,\r\n port: parsedProxyUrl.port,\r\n protocol: parsedProxyUrl.protocol,\r\n };\r\n\r\n if (proxy.auth) proxyOptions.auth = proxy.auth.username + \":\" + proxy.auth.password;\r\n else if (parsedProxyUrl.username && parsedProxyUrl.password) proxyOptions.auth = `${parsedProxyUrl.username}:${parsedProxyUrl.password}`;\r\n\r\n agents[agentName] = new proxyAgent(proxyOptions);\r\n } else {\r\n const protocolInterface = isHttp ? http : https;\r\n\r\n agents[agentName] = new protocolInterface.Agent({\r\n keepAlive: true,\r\n maxSockets: Infinity,\r\n });\r\n }\r\n }\r\n\r\n return agents[agentName];\r\n};\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n *\r\n */\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n const headers: http.OutgoingHttpHeaders = {};\r\n\r\n if (data) {\r\n headers[\"Content-Type\"] = additionalHeaders[\"Content-Type\"];\r\n headers[\"Content-Length\"] = data.length;\r\n\r\n delete additionalHeaders[\"Content-Type\"];\r\n }\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n headers[key] = additionalHeaders[key];\r\n }\r\n const parsedUrl = new URL(options.uri);\r\n const protocol = parsedUrl.protocol?.slice(0, -1) || \"https\";\r\n const protocolInterface = protocol === \"http\" ? http : https;\r\n\r\n const internalOptions: http.RequestOptions = {\r\n hostname: parsedUrl.hostname,\r\n port: parsedUrl.port,\r\n path: parsedUrl.pathname + parsedUrl.search,\r\n method: options.method,\r\n timeout: options.timeout || 0,\r\n headers: headers,\r\n signal: signal,\r\n };\r\n\r\n //support environment variables\r\n if (!options.proxy && process.env[`${protocol}_proxy`]) {\r\n options.proxy = {\r\n url: process.env[`${protocol}_proxy`]!,\r\n };\r\n }\r\n\r\n internalOptions.agent = getAgent(options, protocol);\r\n\r\n if (options.proxy) {\r\n const hostHeader = new URL(options.proxy.url).host;\r\n if (hostHeader) headers.host = hostHeader;\r\n }\r\n\r\n const request = protocolInterface.request(internalOptions, function (res) {\r\n let rawData = \"\";\r\n res.setEncoding(\"utf8\");\r\n res.on(\"data\", function (chunk) {\r\n rawData += chunk;\r\n });\r\n res.on(\"end\", function () {\r\n switch (res.statusCode) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: //Success with partial content\r\n case 304: {\r\n // Success with Not Modified\r\n let responseData = parseResponse(rawData, res.headers, responseParams[options.requestId]);\r\n\r\n let response = {\r\n data: responseData,\r\n headers: res.headers as any,\r\n status: res.statusCode,\r\n };\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n default:\r\n // All other statuses are error cases.\r\n let crmError;\r\n try {\r\n var errorParsed = parseResponse(rawData, res.headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n crmError = errorParsed.hasOwnProperty(\"error\") && errorParsed.error ? errorParsed.error : { message: errorParsed.Message };\r\n } catch (e) {\r\n if (rawData.length > 0) {\r\n crmError = { message: rawData };\r\n } else {\r\n crmError = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError(crmError, {\r\n status: res.statusCode,\r\n statusText: \"\",\r\n statusMessage: res.statusMessage,\r\n headers: res.headers,\r\n })\r\n );\r\n break;\r\n }\r\n });\r\n });\r\n\r\n if (internalOptions.timeout) {\r\n request.setTimeout(internalOptions.timeout, function () {\r\n request.destroy();\r\n });\r\n }\r\n\r\n request.on(\"error\", function (error) {\r\n errorCallback(error);\r\n });\r\n\r\n if (data) {\r\n request.write(data);\r\n }\r\n\r\n request.end();\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance.\r\n *\r\n * @param {Config} config configuration object.\r\n * @returns {DynamicsWebApi} A new instance of DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName entity name\r\n * @returns {string | null} collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n \"@odata.count\"?: number;\r\n oDataContext?: string;\r\n \"@odata.context\"?: number;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n \"@odata.deltaLink\"?: string;\r\n \"@odata.nextLink\"?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\"\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\"\r\n },\r\n };\r\n }\r\n}\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url!.toString() + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAIO,SAAS,YAAa;AACzB,SAAO,mBAAAA;AACX;AANA,IAEA;AAFA;AAAA;AAAA;AAEA,yBAAoB;AAAA;AAAA;;;ACFb,SAASC,aAAwB;AACpC,SAAO,QAAqB,OAAO,OAAO,SAAS,0CAAyB,UAAU;AAC1F;AAEO,SAAS,sBAAsB;AAClC,SAAO,QAAqBA,WAAU,EAAE,gBAAgB,IAAI,WAAW,CAAC,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9C,YAAM,kBAAwC,CAAC,UAAU,CAAC,IAAI,QAAQ,YAAY,OAAO;AAEzF,sBAAgB,aAAa;AAC7B,sBAAgB,SAAS;AACzB,sBAAgB,eAAe;AAC/B,sBAAgB,YAAY,KAAK;AAEjC,WAAK,kBAAkB;AACvB,WAAK,WAAW;AAEhB,YAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,aAAO,qCAAU;AAAA,IACrB;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,KAAK,OAAO;AAEnG,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,cAAc,kBAAkB,UAAU;AAAA,IACxG;AArnCI,yBAAqB,MAAM,KAAK,SAAS,MAAM;AAAA,EACnD;AAqnCJ;", + "names": ["nCrypto", "getCrypto", "_a", "HttpProxyAgent", "HttpsProxyAgent", "_a", "_b", "executeRequest", "_a", "executeRequest", "_a", "request"] } diff --git a/dist/dynamics-web-api.d.ts b/dist/dynamics-web-api.d.ts index 8f09f3f..d1873c6 100644 --- a/dist/dynamics-web-api.d.ts +++ b/dist/dynamics-web-api.d.ts @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.1.1 (c) 2023 Aleksandr Rogov */ +/*! dynamics-web-api v2.1.2 (c) 2023 Aleksandr Rogov */ /// /** * Microsoft Dynamics CRM Web API helper library written in JavaScript. @@ -349,10 +349,10 @@ export declare class DynamicsWebApi { */ executeBatch: (request?: BatchRequest) => Promise; /** - * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance. + * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance. * - * @param {Config} config - configuration object. - * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi + * @param {Config} config configuration object. + * @returns {DynamicsWebApi} A new instance of DynamicsWebApi */ initializeInstance: (config?: Config) => DynamicsWebApi; Utility: { @@ -360,8 +360,8 @@ export declare class DynamicsWebApi { * Searches for a collection name by provided entity name in a cached entity metadata. * The returned collection name can be null. * - * @param {string} entityName - entity name - * @returns {string | null} a collection name + * @param {string} entityName entity name + * @returns {string | null} collection name */ getCollectionName: (entityName: string) => string | null; }; @@ -902,7 +902,9 @@ export interface MultipleResponse { /**Multiple respone entities */ value: T[]; oDataCount?: number; + "@odata.count"?: number; oDataContext?: string; + "@odata.context"?: number; } export interface AllResponse extends MultipleResponse { /**@odata.deltaLink value */ @@ -915,6 +917,8 @@ export interface RetrieveMultipleResponse extends MultipleResponse { oDataNextLink?: string; /**@odata.deltaLink value */ oDataDeltaLink?: string; + "@odata.deltaLink"?: string; + "@odata.nextLink"?: string; } export interface FetchXmlResponse extends MultipleResponse { "@Microsoft.Dynamics.CRM.totalrecordcount"?: number; diff --git a/dist/dynamics-web-api.js b/dist/dynamics-web-api.js index ea87675..7034b9e 100644 --- a/dist/dynamics-web-api.js +++ b/dist/dynamics-web-api.js @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.1.1 (c) 2023 Aleksandr Rogov */ +/*! dynamics-web-api v2.1.2 (c) 2023 Aleksandr Rogov */ "use strict"; var _dynamicsWebApiExports = (() => { var __defProp = Object.defineProperty; @@ -64,7 +64,7 @@ var _dynamicsWebApiExports = (() => { init_Crypto(); init_Regex(); downloadChunkSize = 4194304; - _Utility = class { + _Utility = class _Utility { /** * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]' * @@ -233,9 +233,9 @@ var _dynamicsWebApiExports = (() => { return bytes; } }; - Utility = _Utility; // static isNodeEnv = isNodeEnv; - Utility.downloadChunkSize = downloadChunkSize; + _Utility.downloadChunkSize = downloadChunkSize; + Utility = _Utility; } }); @@ -250,7 +250,7 @@ var _dynamicsWebApiExports = (() => { "src/helpers/ErrorHelper.ts"() { "use strict"; init_Regex(); - ErrorHelper = class { + ErrorHelper = class _ErrorHelper { static handleErrorResponse(req) { throw new Error(`Error: ${req.status}: ${req.message}`); } @@ -330,7 +330,7 @@ var _dynamicsWebApiExports = (() => { } static keyParameterCheck(parameter, functionName, parameterName) { try { - ErrorHelper.stringParameterCheck(parameter, functionName, parameterName); + _ErrorHelper.stringParameterCheck(parameter, functionName, parameterName); const match = extractUuid(parameter); if (match) return match; @@ -373,15 +373,15 @@ var _dynamicsWebApiExports = (() => { var init_dwa = __esm({ "src/dwa.ts"() { "use strict"; - _DWA = class { + _DWA = class _DWA { }; - DWA = _DWA; - DWA.Prefer = (_b = class { + _DWA.Prefer = (_b = class { static get(annotation) { return `${_DWA.Prefer.IncludeAnnotations}="${annotation}"`; } }, _b.ReturnRepresentation = "return=representation", _b.Annotations = (_a = class { }, _a.AssociatedNavigationProperty = "Microsoft.Dynamics.CRM.associatednavigationproperty", _a.LookupLogicalName = "Microsoft.Dynamics.CRM.lookuplogicalname", _a.All = "*", _a.FormattedValue = "OData.Community.Display.V1.FormattedValue", _a.FetchXmlPagingCookie = "Microsoft.Dynamics.CRM.fetchxmlpagingcookie", _a), _b.IncludeAnnotations = "odata.include-annotations", _b); + DWA = _DWA; } }); @@ -847,11 +847,11 @@ var _dynamicsWebApiExports = (() => { init_ErrorHelper(); var getApiUrl = (serverUrl, apiConfig) => { if (Utility.isRunningWithinPortals()) { - return `${window.location.origin}/_api/`; + return new URL("_api", window.location.origin).toString() + "/"; } else { if (!serverUrl) serverUrl = Utility.getClientUrl(); - return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`; + return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + "/"; } }; var mergeApiConfigs = (apiConfig, apiType, internalConfig) => { @@ -955,7 +955,7 @@ var _dynamicsWebApiExports = (() => { // src/utils/Request.ts init_Utility(); init_ErrorHelper(); - var _RequestUtility = class { + var _RequestUtility = class _RequestUtility { /** * Converts a request object to URL link * @@ -999,7 +999,6 @@ var _dynamicsWebApiExports = (() => { } else { ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, "request.url"); request.path = request.url.replace(config.dataApi.url, ""); - request.path = _RequestUtility.composeUrl(request, config, request.path); } if (request.hasOwnProperty("async") && request.async != null) { ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, "request.async"); @@ -1430,8 +1429,8 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); return headers; } }; + _RequestUtility.entityNames = null; var RequestUtility = _RequestUtility; - RequestUtility.entityNames = null; // src/client/RequestClient.ts init_ErrorHelper(); @@ -1473,7 +1472,7 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); }; var _batchRequestCollection = {}; var _responseParseParams = {}; - var RequestClient = class { + var RequestClient = class _RequestClient { /** * Sends a request to given URL with given parameters * @@ -1521,7 +1520,7 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url; return await executeRequest2({ method: request.method, - uri: url + request.path, + uri: url.toString() + request.path, data: processedData, additionalHeaders: request.headers, responseParams: _responseParseParams, @@ -1567,7 +1566,7 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); return exceptions.indexOf(entityName) > -1; } static async _checkCollectionName(entityName, config) { - if (!entityName || RequestClient._isEntityNameException(entityName)) { + if (!entityName || _RequestClient._isEntityNameException(entityName)) { return entityName; } entityName = entityName.toLowerCase(); @@ -1575,7 +1574,7 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); return entityName; } try { - return await RequestClient._getCollectionNames(entityName, config); + return await _RequestClient._getCollectionNames(entityName, config); } catch (error) { throw new Error("Unable to fetch Collection Names. Error: " + error.message); } @@ -1585,7 +1584,7 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); request.userHeaders = request.headers; delete request.headers; if (!request.isBatch) { - const collectionName = await RequestClient._checkCollectionName(request.collection, config); + const collectionName = await _RequestClient._checkCollectionName(request.collection, config); request.collection = collectionName; RequestUtility.compose(request, config); request.responseParameters.convertedToBatch = false; @@ -1614,7 +1613,7 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); }; // src/dynamics-web-api.ts - var DynamicsWebApi = class { + var DynamicsWebApi = class _DynamicsWebApi { /** * Initializes a new instance of DynamicsWebApi * @param config - Configuration object @@ -2513,19 +2512,19 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); return response?.data; }; /** - * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance. + * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance. * - * @param {Config} config - configuration object. - * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi + * @param {Config} config configuration object. + * @returns {DynamicsWebApi} A new instance of DynamicsWebApi */ - this.initializeInstance = (config) => new DynamicsWebApi(config || this._config); + this.initializeInstance = (config) => new _DynamicsWebApi(config || this._config); this.Utility = { /** * Searches for a collection name by provided entity name in a cached entity metadata. * The returned collection name can be null. * - * @param {string} entityName - entity name - * @returns {string | null} a collection name + * @param {string} entityName entity name + * @returns {string | null} collection name */ getCollectionName: (entityName) => RequestClient.getCollectionName(entityName) }; diff --git a/dist/dynamics-web-api.js.map b/dist/dynamics-web-api.js.map index 71b89a0..6b483e5 100644 --- a/dist/dynamics-web-api.js.map +++ b/dist/dynamics-web-api.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/helpers/Crypto.ts", "../src/helpers/Regex.ts", "../src/utils/Utility.ts", "../src/helpers/ErrorHelper.ts", "../src/dwa.ts", "../src/client/helpers/dateReviver.ts", "../src/client/helpers/parseResponse.ts", "../src/client/helpers/parseResponseHeaders.ts", "../src/client/xhr.ts", "../src/dynamics-web-api.ts", "../src/utils/Config.ts", "../src/client/RequestClient.ts", "../src/utils/Request.ts", "../src/client/helpers/executeRequest.ts"], - "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): any {\r\n\tconst headers = {};\r\n\tif (!headerStr) {\r\n\t\treturn headers;\r\n\t}\r\n\tconst headerPairs = headerStr.split(\"\\u000d\\u000a\");\r\n\tfor (let i = 0, ilen = headerPairs.length; i < ilen; i++) {\r\n\t\tconst headerPair = headerPairs[i];\r\n\t\tconst index = headerPair.indexOf(\"\\u003a\\u0020\");\r\n\t\tif (index > 0) {\r\n\t\t\theaders[headerPair.substring(0, index)] = headerPair.substring(index + 2);\r\n\t\t}\r\n\t}\r\n\treturn headers;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\nimport { parseResponseHeaders } from \"./helpers/parseResponseHeaders\";\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n if (signal?.aborted) {\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n message: \"The user aborted a request.\",\r\n })\r\n );\r\n\r\n return;\r\n }\r\n\r\n let request = new XMLHttpRequest();\r\n request.open(options.method, options.uri, options.isAsync || false);\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n request.setRequestHeader(key, additionalHeaders[key]);\r\n }\r\n\r\n request.onreadystatechange = function () {\r\n if (request.readyState === 4) {\r\n if (signal) signal.removeEventListener(\"abort\", abort);\r\n\r\n switch (request.status) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: // Success with partial content.\r\n case 304: {\r\n // Success with Not Modified\r\n const responseHeaders = parseResponseHeaders(request.getAllResponseHeaders());\r\n const responseData = parseResponse(request.responseText, responseHeaders, responseParams[options.requestId]);\r\n\r\n const response = {\r\n data: responseData,\r\n headers: responseHeaders,\r\n status: request.status,\r\n };\r\n\r\n request = null as any;\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n case 0:\r\n break; //response will be handled by onerror\r\n default:\r\n if (!request) break; //response was handled somewhere else\r\n\r\n // All other statuses are error cases.\r\n let error;\r\n let headers;\r\n try {\r\n headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n const errorParsed = parseResponse(request.responseText, headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n error = errorParsed.error;\r\n } catch (e) {\r\n if (request.response.length > 0) {\r\n error = { message: request.response };\r\n } else {\r\n error = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n const errorParameters = {\r\n status: request.status,\r\n statusText: request.statusText,\r\n headers: headers,\r\n };\r\n\r\n request = null as any;\r\n\r\n errorCallback(ErrorHelper.handleHttpError(error, errorParameters));\r\n\r\n break;\r\n }\r\n }\r\n };\r\n\r\n if (options.timeout) {\r\n request.timeout = options.timeout;\r\n }\r\n\r\n request.onerror = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Network Error\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n request.ontimeout = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"TimeoutError\",\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Request Timed Out\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //browser abort\r\n request.onabort = function () {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"Request aborted\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //manual abort/cancellation\r\n const abort = () => {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"The user aborted a request.\",\r\n headers: headers,\r\n })\r\n );\r\n\r\n request.abort();\r\n\r\n request = null as any;\r\n };\r\n\r\n if (signal) {\r\n signal.addEventListener(\"abort\", abort);\r\n }\r\n\r\n data ? request.send(data) : request.send();\r\n\r\n //called for testing\r\n if (XhrWrapper.afterSendEvent) XhrWrapper.afterSendEvent();\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n */\r\nexport class XhrWrapper {\r\n //for testing\r\n static afterSendEvent: () => void;\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance.\r\n *\r\n * @param {Config} config - configuration object.\r\n * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName - entity name\r\n * @returns {string | null} a collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n oDataContext?: string;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return `${global.window.location.origin}/_api/`;\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`;\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\",\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\",\r\n },\r\n };\r\n }\r\n}\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAO,WAAS,YAAwB;AACpC,WAAO,OAAqB,OAAc,SAAS,KAAyB,UAAU;AAAA,EAC1F;AAEO,WAAS,sBAAsB;AAClC,WAAO,OAAqB,UAAU,EAAE,gBAAgB,IAAI,WAAW,CAAC,CAAC,IAAI,UAAU,EAAE,YAAY,CAAC;AAAA,EAC1G;AANA;AAAA;AAAA;AAAA;AAAA;;;ACEO,WAAS,OAAO,OAAwB;AAC3C,UAAM,QAAQ,IAAI,OAAO,MAAM,GAAG,EAAE,KAAK,KAAK;AAC9C,WAAO,CAAC,CAAC;AAAA,EACb;AAE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AAY,eAAe,gBAAgB,OAAO,+BAA+B,eAAe;AAC9G,oBAAY,qBAAqB,gBAAgB,MAAM,QAAQ,+BAA+B,aAAa;AAC3G,oBAAY,8BAA8B,gBAAgB,MAAM,QAAQ,+BAA+B,eAAe,GAAG;AAEzH,wBAAgB,eAAe,gBAAgB,aAAa;AAC5D,wBAAgB,SAAS;AACzB,wBAAgB,OAAO,gBAAgB;AACvC,wBAAgB,YAAY,KAAK,QAAQ;AAEzC,eAAO,gBAAgB;AAEvB,cAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,eAAO,UAAU;AAAA,MACrB;AAKA;AAAA;AAAA;AAAA,wBAAa,MAAY;AACrB,aAAK,WAAW;AAChB,aAAK,kBAAkB,QAAQ,aAAa;AAAA,MAChD;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAe,OAAO,YAA2C;AAC7D,oBAAY,qBAAqB,KAAK,QAAQ;AAE9C,cAAM,kBAAwC,CAAC,UAAU,CAAC,IAAI,QAAQ,YAAY,OAAO;AAEzF,wBAAgB,aAAa;AAC7B,wBAAgB,SAAS;AACzB,wBAAgB,eAAe;AAC/B,wBAAgB,YAAY,KAAK;AAEjC,aAAK,kBAAkB;AACvB,aAAK,WAAW;AAEhB,cAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,eAAO,UAAU;AAAA,MACrB;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAqB,CAAC,WAAoC,IAAI,eAAe,UAAU,KAAK,OAAO;AAEnG,qBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQN,mBAAmB,CAAC,eAAsC,cAAc,kBAAkB,UAAU;AAAA,MACxG;AArnCI,2BAAqB,MAAM,KAAK,SAAS,MAAM;AAAA,IACnD;AAAA,EAqnCJ;", + "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): any {\r\n\tconst headers = {};\r\n\tif (!headerStr) {\r\n\t\treturn headers;\r\n\t}\r\n\tconst headerPairs = headerStr.split(\"\\u000d\\u000a\");\r\n\tfor (let i = 0, ilen = headerPairs.length; i < ilen; i++) {\r\n\t\tconst headerPair = headerPairs[i];\r\n\t\tconst index = headerPair.indexOf(\"\\u003a\\u0020\");\r\n\t\tif (index > 0) {\r\n\t\t\theaders[headerPair.substring(0, index)] = headerPair.substring(index + 2);\r\n\t\t}\r\n\t}\r\n\treturn headers;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\nimport { parseResponseHeaders } from \"./helpers/parseResponseHeaders\";\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n if (signal?.aborted) {\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n message: \"The user aborted a request.\",\r\n })\r\n );\r\n\r\n return;\r\n }\r\n\r\n let request = new XMLHttpRequest();\r\n request.open(options.method, options.uri, options.isAsync || false);\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n request.setRequestHeader(key, additionalHeaders[key]);\r\n }\r\n\r\n request.onreadystatechange = function () {\r\n if (request.readyState === 4) {\r\n if (signal) signal.removeEventListener(\"abort\", abort);\r\n\r\n switch (request.status) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: // Success with partial content.\r\n case 304: {\r\n // Success with Not Modified\r\n const responseHeaders = parseResponseHeaders(request.getAllResponseHeaders());\r\n const responseData = parseResponse(request.responseText, responseHeaders, responseParams[options.requestId]);\r\n\r\n const response = {\r\n data: responseData,\r\n headers: responseHeaders,\r\n status: request.status,\r\n };\r\n\r\n request = null as any;\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n case 0:\r\n break; //response will be handled by onerror\r\n default:\r\n if (!request) break; //response was handled somewhere else\r\n\r\n // All other statuses are error cases.\r\n let error;\r\n let headers;\r\n try {\r\n headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n const errorParsed = parseResponse(request.responseText, headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n error = errorParsed.error;\r\n } catch (e) {\r\n if (request.response.length > 0) {\r\n error = { message: request.response };\r\n } else {\r\n error = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n const errorParameters = {\r\n status: request.status,\r\n statusText: request.statusText,\r\n headers: headers,\r\n };\r\n\r\n request = null as any;\r\n\r\n errorCallback(ErrorHelper.handleHttpError(error, errorParameters));\r\n\r\n break;\r\n }\r\n }\r\n };\r\n\r\n if (options.timeout) {\r\n request.timeout = options.timeout;\r\n }\r\n\r\n request.onerror = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Network Error\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n request.ontimeout = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"TimeoutError\",\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Request Timed Out\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //browser abort\r\n request.onabort = function () {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"Request aborted\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //manual abort/cancellation\r\n const abort = () => {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"The user aborted a request.\",\r\n headers: headers,\r\n })\r\n );\r\n\r\n request.abort();\r\n\r\n request = null as any;\r\n };\r\n\r\n if (signal) {\r\n signal.addEventListener(\"abort\", abort);\r\n }\r\n\r\n data ? request.send(data) : request.send();\r\n\r\n //called for testing\r\n if (XhrWrapper.afterSendEvent) XhrWrapper.afterSendEvent();\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n */\r\nexport class XhrWrapper {\r\n //for testing\r\n static afterSendEvent: () => void;\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance.\r\n *\r\n * @param {Config} config configuration object.\r\n * @returns {DynamicsWebApi} A new instance of DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName entity name\r\n * @returns {string | null} collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n \"@odata.count\"?: number;\r\n oDataContext?: string;\r\n \"@odata.context\"?: number;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n \"@odata.deltaLink\"?: string;\r\n \"@odata.nextLink\"?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\"\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\"\r\n },\r\n };\r\n }\r\n}\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url!.toString() + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAO,WAAS,YAAwB;AACpC,WAAO,OAAqB,OAAc,SAAS,KAAyB,UAAU;AAAA,EAC1F;AAEO,WAAS,sBAAsB;AAClC,WAAO,OAAqB,UAAU,EAAE,gBAAgB,IAAI,WAAW,CAAC,CAAC,IAAI,UA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BAAe,OAAO,YAA2C;AAC7D,oBAAY,qBAAqB,KAAK,QAAQ;AAE9C,cAAM,kBAAwC,CAAC,UAAU,CAAC,IAAI,QAAQ,YAAY,OAAO;AAEzF,wBAAgB,aAAa;AAC7B,wBAAgB,SAAS;AACzB,wBAAgB,eAAe;AAC/B,wBAAgB,YAAY,KAAK;AAEjC,aAAK,kBAAkB;AACvB,aAAK,WAAW;AAEhB,cAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,eAAO,UAAU;AAAA,MACrB;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,KAAK,OAAO;AAEnG,qBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQN,mBAAmB,CAAC,eAAsC,cAAc,kBAAkB,UAAU;AAAA,MACxG;AArnCI,2BAAqB,MAAM,KAAK,SAAS,MAAM;AAAA,IACnD;AAAA,EAqnCJ;", "names": ["executeRequest", "executeRequest", "request"] } diff --git a/dist/dynamics-web-api.min.js b/dist/dynamics-web-api.min.js index 1067159..bb80290 100644 --- a/dist/dynamics-web-api.min.js +++ b/dist/dynamics-web-api.min.js @@ -1,9 +1,9 @@ -/*! dynamics-web-api v2.1.1 (c) 2023 Aleksandr Rogov */ -"use strict";var _dynamicsWebApiExports=(()=>{var q=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var C=(s,e)=>()=>(s&&(e=s(s=0)),e);var z=(s,e)=>{for(var t in e)q(s,t,{get:e[t],enumerable:!0})},me=(s,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pe(e))!ue.call(s,n)&&n!==t&&q(s,n,{get:()=>e[n],enumerable:!(a=le(e,n))||a.enumerable});return s};var X=s=>me(q({},"__esModule",{value:!0}),s);function de(){return window.crypto}function j(){return de().getRandomValues(new Uint8Array(1))}var Q=C(()=>{"use strict"});function J(s){return!!new RegExp(M,"i").exec(s)}function S(s){let e=new RegExp("^{?("+M+")}?$","i").exec(s);return e?e[1]:null}function _(s){let e=new RegExp("("+M+")\\)$","i").exec(s);return e?e[1]:null}var M,$=C(()=>{"use strict";M="[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}"});var ye,g,c,W=C(()=>{"use strict";Q();$();ye=4194304,g=class{static buildFunctionParameters(e){if(e){let a=Object.keys(e),n="",r="";for(var t=1;t<=a.length;t++){let l=a[t-1],o=e[l];o!=null&&(typeof o=="string"&&!o.startsWith("Microsoft.Dynamics.CRM")&&!J(o)?o="'"+o+"'":typeof o=="object"&&(o=JSON.stringify(o)),t>1&&(n+=",",r+="&"),n+=l+"=@p"+t,r+="@p"+t+"="+(S(o)||o))}return r&&(r="?"+r),"("+n+")"+r}else return"()"}static getFetchXmlPagingCookie(e="",t=1){e=decodeURIComponent(decodeURIComponent(e));let a=/pagingcookie="()/.exec(e);if(a!=null){let n=parseInt(a[2]);return{cookie:a[1].replace(//g,">").replace(/\"/g,"'").replace(/\'/g,"""),page:n,nextPage:n+1}}else return{cookie:"",page:t,nextPage:t+1}}static convertToReferenceObject(e){let t=/\/(\w+)\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(e["@odata.id"]);return{id:t[2],collection:t[1],oDataContext:e["@odata.context"]}}static isNull(e){return typeof e>"u"||e==null}static generateUUID(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^j()[0]&15>>e/4).toString(16))}static getXrmContext(){if(typeof GetGlobalContext<"u")return GetGlobalContext();if(typeof Xrm<"u"){if(!g.isNull(Xrm.Utility)&&!g.isNull(Xrm.Utility.getGlobalContext))return Xrm.Utility.getGlobalContext();if(!g.isNull(Xrm.Page)&&!g.isNull(Xrm.Page.context))return Xrm.Page.context}throw new Error("Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.")}static getClientUrl(){let t=g.getXrmContext().getClientUrl();return t.match(/\/$/)&&(t=t.substring(0,t.length-1)),t}static isRunningWithinPortals(){return!!window.shell}static isObject(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&Object.prototype.toString.call(e)!=="[object Date]"}static copyObject(e,t){let a={};for(let n in e)e.hasOwnProperty(n)&&!t?.includes(n)&&(g.isObject(e[n])?a[n]=g.copyObject(e[n]):Array.isArray(e[n])?a[n]=e[n].slice():a[n]=e[n]);return a}static copyRequest(e,t=[]){t.includes("signal")||t.push("signal");let a=g.copyObject(e,t);return a.signal=e.signal,a}static setFileChunk(e,t,a,n){n=n||0;let r=n+a>t.length?t.length%a:a,l;l=new Uint8Array(r);for(let o=0;o{"use strict";$();i=class{static handleErrorResponse(e){throw new Error(`Error: ${e.status}: ${e.message}`)}static parameterCheck(e,t,a,n){(typeof e>"u"||e===null||e==="")&&A(t,a,n)}static stringParameterCheck(e,t,a){typeof e!="string"&&A(t,a,"String")}static maxLengthStringParameterCheck(e,t,a,n){if(e&&e.length>n)throw new Error(`${a} has a ${n} character limit.`)}static arrayParameterCheck(e,t,a){e.constructor!==Array&&A(t,a,"Array")}static stringOrArrayParameterCheck(e,t,a){e.constructor!==Array&&typeof e!="string"&&A(t,a,"String or Array")}static numberParameterCheck(e,t,a){if(typeof e!="number"){if(typeof e=="string"&&e&&!isNaN(parseInt(e)))return;A(t,a,"Number")}}static batchIsEmpty(){return[new Error("Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.")]}static handleHttpError(e,t){let a=new Error;return Object.keys(e).forEach(n=>{a[n]=e[n]}),t&&Object.keys(t).forEach(n=>{a[n]=t[n]}),a}static boolParameterCheck(e,t,a){typeof e!="boolean"&&A(t,a,"Boolean")}static guidParameterCheck(e,t,a){let n=S(e);return n||A(t,a,"GUID String"),n}static keyParameterCheck(e,t,a){try{i.stringParameterCheck(e,t,a);let n=S(e);if(n)return n;let r=e.split(",");if(r.length)for(let l=0;l{"use strict";K=class{},x=K;x.Prefer=(E=class{static get(e){return`${K.Prefer.IncludeAnnotations}="${e}"`}},E.ReturnRepresentation="return=representation",E.Annotations=(T=class{},T.AssociatedNavigationProperty="Microsoft.Dynamics.CRM.associatednavigationproperty",T.LookupLogicalName="Microsoft.Dynamics.CRM.lookuplogicalname",T.All="*",T.FormattedValue="OData.Community.Display.V1.FormattedValue",T.FetchXmlPagingCookie="Microsoft.Dynamics.CRM.fetchxmlpagingcookie",T),E.IncludeAnnotations="odata.include-annotations",E)});function G(s,e){if(typeof e=="string"){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:Z|[-+]\d{2}:\d{2})$/.exec(e);if(t)return new Date(Date.UTC(+t[1],+t[2]-1,+t[3],+t[4],+t[5],+t[6]))}return e}var Y=C(()=>{"use strict"});function V(s,e){let t=null;if(s.indexOf("@")!==-1){let a=s.split("@");switch(a[1]){case"odata.context":t="oDataContext";break;case"odata.count":t="oDataCount",e=e!=null?parseInt(e):0;break;case"odata.nextLink":t="oDataNextLink";break;case"odata.deltaLink":t="oDataDeltaLink";break;case x.Prefer.Annotations.FormattedValue:t=a[0]+"_Formatted";break;case x.Prefer.Annotations.AssociatedNavigationProperty:t=a[0]+"_NavigationProperty";break;case x.Prefer.Annotations.LookupLogicalName:t=a[0]+"_LogicalName";break}}return[t,e]}function B(s,e){if(e){if(e.isRef&&s["@odata.id"]!=null)return c.convertToReferenceObject(s);if(e.toCount)return V("@odata.count",s["@odata.count"])[1]||0}let t=Object.keys(s);for(let n=0;n{var q=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var b=(s,e)=>()=>(s&&(e=s(s=0)),e);var z=(s,e)=>{for(var t in e)q(s,t,{get:e[t],enumerable:!0})},me=(s,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pe(e))!ue.call(s,n)&&n!==t&&q(s,n,{get:()=>e[n],enumerable:!(a=le(e,n))||a.enumerable});return s};var X=s=>me(q({},"__esModule",{value:!0}),s);function de(){return window.crypto}function j(){return de().getRandomValues(new Uint8Array(1))}var Q=b(()=>{"use strict"});function J(s){return!!new RegExp(M,"i").exec(s)}function S(s){let e=new RegExp("^{?("+M+")}?$","i").exec(s);return e?e[1]:null}function F(s){let e=new RegExp("("+M+")\\)$","i").exec(s);return e?e[1]:null}var M,w=b(()=>{"use strict";M="[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}"});var ye,g,c,v=b(()=>{"use strict";Q();w();ye=4194304,g=class g{static buildFunctionParameters(e){if(e){let a=Object.keys(e),n="",r="";for(var t=1;t<=a.length;t++){let l=a[t-1],o=e[l];o!=null&&(typeof o=="string"&&!o.startsWith("Microsoft.Dynamics.CRM")&&!J(o)?o="'"+o+"'":typeof o=="object"&&(o=JSON.stringify(o)),t>1&&(n+=",",r+="&"),n+=l+"=@p"+t,r+="@p"+t+"="+(S(o)||o))}return r&&(r="?"+r),"("+n+")"+r}else return"()"}static getFetchXmlPagingCookie(e="",t=1){e=decodeURIComponent(decodeURIComponent(e));let a=/pagingcookie="()/.exec(e);if(a!=null){let n=parseInt(a[2]);return{cookie:a[1].replace(//g,">").replace(/\"/g,"'").replace(/\'/g,"""),page:n,nextPage:n+1}}else return{cookie:"",page:t,nextPage:t+1}}static convertToReferenceObject(e){let t=/\/(\w+)\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(e["@odata.id"]);return{id:t[2],collection:t[1],oDataContext:e["@odata.context"]}}static isNull(e){return typeof e>"u"||e==null}static generateUUID(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^j()[0]&15>>e/4).toString(16))}static getXrmContext(){if(typeof GetGlobalContext<"u")return GetGlobalContext();if(typeof Xrm<"u"){if(!g.isNull(Xrm.Utility)&&!g.isNull(Xrm.Utility.getGlobalContext))return Xrm.Utility.getGlobalContext();if(!g.isNull(Xrm.Page)&&!g.isNull(Xrm.Page.context))return Xrm.Page.context}throw new Error("Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.")}static getClientUrl(){let t=g.getXrmContext().getClientUrl();return t.match(/\/$/)&&(t=t.substring(0,t.length-1)),t}static isRunningWithinPortals(){return!!window.shell}static isObject(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&Object.prototype.toString.call(e)!=="[object Date]"}static copyObject(e,t){let a={};for(let n in e)e.hasOwnProperty(n)&&!t?.includes(n)&&(g.isObject(e[n])?a[n]=g.copyObject(e[n]):Array.isArray(e[n])?a[n]=e[n].slice():a[n]=e[n]);return a}static copyRequest(e,t=[]){t.includes("signal")||t.push("signal");let a=g.copyObject(e,t);return a.signal=e.signal,a}static setFileChunk(e,t,a,n){n=n||0;let r=n+a>t.length?t.length%a:a,l;l=new Uint8Array(r);for(let o=0;o{"use strict";w();i=class s{static handleErrorResponse(e){throw new Error(`Error: ${e.status}: ${e.message}`)}static parameterCheck(e,t,a,n){(typeof e>"u"||e===null||e==="")&&C(t,a,n)}static stringParameterCheck(e,t,a){typeof e!="string"&&C(t,a,"String")}static maxLengthStringParameterCheck(e,t,a,n){if(e&&e.length>n)throw new Error(`${a} has a ${n} character limit.`)}static arrayParameterCheck(e,t,a){e.constructor!==Array&&C(t,a,"Array")}static stringOrArrayParameterCheck(e,t,a){e.constructor!==Array&&typeof e!="string"&&C(t,a,"String or Array")}static numberParameterCheck(e,t,a){if(typeof e!="number"){if(typeof e=="string"&&e&&!isNaN(parseInt(e)))return;C(t,a,"Number")}}static batchIsEmpty(){return[new Error("Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.")]}static handleHttpError(e,t){let a=new Error;return Object.keys(e).forEach(n=>{a[n]=e[n]}),t&&Object.keys(t).forEach(n=>{a[n]=t[n]}),a}static boolParameterCheck(e,t,a){typeof e!="boolean"&&C(t,a,"Boolean")}static guidParameterCheck(e,t,a){let n=S(e);return n||C(t,a,"GUID String"),n}static keyParameterCheck(e,t,a){try{s.stringParameterCheck(e,t,a);let n=S(e);if(n)return n;let r=e.split(",");if(r.length)for(let l=0;l{"use strict";$=class ${};$.Prefer=(E=class{static get(e){return`${$.Prefer.IncludeAnnotations}="${e}"`}},E.ReturnRepresentation="return=representation",E.Annotations=(D=class{},D.AssociatedNavigationProperty="Microsoft.Dynamics.CRM.associatednavigationproperty",D.LookupLogicalName="Microsoft.Dynamics.CRM.lookuplogicalname",D.All="*",D.FormattedValue="OData.Community.Display.V1.FormattedValue",D.FetchXmlPagingCookie="Microsoft.Dynamics.CRM.fetchxmlpagingcookie",D),E.IncludeAnnotations="odata.include-annotations",E);A=$});function K(s,e){if(typeof e=="string"){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:Z|[-+]\d{2}:\d{2})$/.exec(e);if(t)return new Date(Date.UTC(+t[1],+t[2]-1,+t[3],+t[4],+t[5],+t[6]))}return e}var Y=b(()=>{"use strict"});function G(s,e){let t=null;if(s.indexOf("@")!==-1){let a=s.split("@");switch(a[1]){case"odata.context":t="oDataContext";break;case"odata.count":t="oDataCount",e=e!=null?parseInt(e):0;break;case"odata.nextLink":t="oDataNextLink";break;case"odata.deltaLink":t="oDataDeltaLink";break;case A.Prefer.Annotations.FormattedValue:t=a[0]+"_Formatted";break;case A.Prefer.Annotations.AssociatedNavigationProperty:t=a[0]+"_NavigationProperty";break;case A.Prefer.Annotations.LookupLogicalName:t=a[0]+"_LogicalName";break}}return[t,e]}function B(s,e){if(e){if(e.isRef&&s["@odata.id"]!=null)return c.convertToReferenceObject(s);if(e.toCount)return G("@odata.count",s["@odata.count"])[1]||0}let t=Object.keys(s);for(let n=0;n-1){o=o.trim();let u=o.substring(o.indexOf(`\r -`)+1).trim();r=r.concat(ee(u,e,t))}else{let u=/HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/gm.exec(o),p=parseInt(u[1]),m=u[2].trim(),f=o.substring(o.indexOf("{"),o.lastIndexOf("}")+1);if(f){let d=B(JSON.parse(f,G),e[t]);if(p>=400){let b=ge(o.substring(o.indexOf(u[0])+u[0].length+1,o.indexOf("{")));r.push(i.handleHttpError(d,{status:p,statusText:m,statusMessage:m,headers:b}))}else r.push(d)}else if(/Content-Type: text\/plain/i.test(o)){let d=/\w+$/gi.exec(o.trim()),b=d&&d.length?d[0]:void 0;r.push(isNaN(Number(b))?b:Number(b))}else if(e.length&&e[t]&&e[t].hasOwnProperty("valueIfEmpty"))r.push(e[t].valueIfEmpty);else{let d=/OData-EntityId.+/i.exec(o);if(d&&d.length){let b=_(d[0]);r.push(b||void 0)}else r.push(void 0)}}t++}return r}function Ce(s){return window.atob(s)}function Ae(s,e,t){let a=s;t.hasOwnProperty("parse")&&(a=JSON.parse(a).value,a=Ce(a));var n={value:a};return e["x-ms-file-name"]&&(n.fileName=e["x-ms-file-name"]),e["x-ms-file-size"]&&(n.fileSize=parseInt(e["x-ms-file-size"])),O(e,"Location")&&(n.location=U(e,"Location")),n}function O(s,e){return s.hasOwnProperty(e)||s.hasOwnProperty(e.toLowerCase())}function U(s,e){return s[e]?s[e]:s[e.toLowerCase()]}function H(s,e,t){let a;if(s.length)if(s.indexOf("--batchresponse_")>-1){let n=ee(s,t);a=t.length===1&&t[0].convertedToBatch?n[0]:n}else O(e,"Content-Disposition")?a=Ae(s,e,t[0]):U(e,"Content-Type").startsWith("application/json")?a=B(JSON.parse(s,G),t[0]):a=isNaN(Number(s))?s:Number(s);else if(t.length&&t[0].hasOwnProperty("valueIfEmpty"))a=t[0].valueIfEmpty;else if(O(e,"OData-EntityId")){let n=U(e,"OData-EntityId"),r=_(n);r&&(a=r)}else O(e,"Location")&&(a={location:U(e,"Location")},e["x-ms-chunk-size"]&&(a.chunkSize=parseInt(e["x-ms-chunk-size"])));return a}var fe,te=C(()=>{"use strict";Z();W();k();Y();$();fe=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/});function v(s){let e={};if(!s)return e;let t=s.split(`\r -`);for(let a=0,n=t.length;a0&&(e[r.substring(0,l)]=r.substring(l+2))}return e}var ne=C(()=>{"use strict"});var ae={};z(ae,{XhrWrapper:()=>I,executeRequest:()=>xe});function xe(s){return new Promise((e,t)=>{Pe(s,e,t)})}function Pe(s,e,t){let a=s.data,n=s.additionalHeaders,r=s.responseParams,l=s.abortSignal;if(l?.aborted){t(i.handleHttpError({name:"AbortError",code:20,message:"The user aborted a request."}));return}let o=new XMLHttpRequest;o.open(s.method,s.uri,s.isAsync||!1);for(let p in n)o.setRequestHeader(p,n[p]);o.onreadystatechange=function(){if(o.readyState===4)switch(l&&l.removeEventListener("abort",u),o.status){case 200:case 201:case 204:case 206:case 304:{let d=v(o.getAllResponseHeaders()),ce={data:H(o.responseText,d,r[s.requestId]),headers:d,status:o.status};o=null,e(ce);break}case 0:break;default:if(!o)break;let p,m;try{m=v(o.getAllResponseHeaders());let d=H(o.responseText,m,r[s.requestId]);if(Array.isArray(d)){t(d);break}p=d.error}catch{o.response.length>0?p={message:o.response}:p={message:"Unexpected Error"}}let f={status:o.status,statusText:o.statusText,headers:m};o=null,t(i.handleHttpError(p,f));break}},s.timeout&&(o.timeout=s.timeout),o.onerror=function(){let p=v(o.getAllResponseHeaders());t(i.handleHttpError({status:o.status,statusText:o.statusText,message:o.responseText||"Network Error",headers:p})),o=null},o.ontimeout=function(){let p=v(o.getAllResponseHeaders());t(i.handleHttpError({name:"TimeoutError",status:o.status,statusText:o.statusText,message:o.responseText||"Request Timed Out",headers:p})),o=null},o.onabort=function(){if(!o)return;let p=v(o.getAllResponseHeaders());t(i.handleHttpError({status:o.status,statusText:o.statusText,message:"Request aborted",headers:p})),o=null};let u=()=>{if(!o)return;let p=v(o.getAllResponseHeaders());t(i.handleHttpError({name:"AbortError",code:20,status:o.status,statusText:o.statusText,message:"The user aborted a request.",headers:p})),o.abort(),o=null};l&&l.addEventListener("abort",u),a?o.send(a):o.send(),I.afterSendEvent&&I.afterSendEvent()}var I,ie=C(()=>{"use strict";k();te();ne();I=class{}});var De={};z(De,{DynamicsWebApi:()=>w});W();k();var he=(s,e)=>c.isRunningWithinPortals()?`${window.location.origin}/_api/`:(s||(s=c.getClientUrl()),`${s}/api/${e.path}/v${e.version}/`),F=(s,e,t)=>{let a=t[e];s?.version&&(i.stringParameterCheck(s.version,"DynamicsWebApi.setConfig",`config.${e}.version`),a.version=s.version),s?.path&&(i.stringParameterCheck(s.path,"DynamicsWebApi.setConfig",`config.${e}.path`),a.path=s.path),a.url=he(t.serverUrl,a)},D=class{static merge(e,t){t?.serverUrl&&(i.stringParameterCheck(t.serverUrl,"DynamicsWebApi.setConfig","config.serverUrl"),e.serverUrl=t.serverUrl),F(t?.dataApi,"dataApi",e),F(t?.searchApi,"searchApi",e),t?.impersonate&&(e.impersonate=i.guidParameterCheck(t.impersonate,"DynamicsWebApi.setConfig","config.impersonate")),t?.impersonateAAD&&(e.impersonateAAD=i.guidParameterCheck(t.impersonateAAD,"DynamicsWebApi.setConfig","config.impersonateAAD")),t?.onTokenRefresh&&(i.callbackParameterCheck(t.onTokenRefresh,"DynamicsWebApi.setConfig","config.onTokenRefresh"),e.onTokenRefresh=t.onTokenRefresh),t?.includeAnnotations&&(i.stringParameterCheck(t.includeAnnotations,"DynamicsWebApi.setConfig","config.includeAnnotations"),e.includeAnnotations=t.includeAnnotations),t?.timeout&&(i.numberParameterCheck(t.timeout,"DynamicsWebApi.setConfig","config.timeout"),e.timeout=t.timeout),t?.maxPageSize&&(i.numberParameterCheck(t.maxPageSize,"DynamicsWebApi.setConfig","config.maxPageSize"),e.maxPageSize=t.maxPageSize),t?.returnRepresentation&&(i.boolParameterCheck(t.returnRepresentation,"DynamicsWebApi.setConfig","config.returnRepresentation"),e.returnRepresentation=t.returnRepresentation),t?.useEntityNames&&(i.boolParameterCheck(t.useEntityNames,"DynamicsWebApi.setConfig","config.useEntityNames"),e.useEntityNames=t.useEntityNames),t?.headers&&(e.headers=t.headers)}static default(){return{serverUrl:null,impersonate:null,impersonateAAD:null,onTokenRefresh:null,includeAnnotations:null,maxPageSize:null,returnRepresentation:null,proxy:null,dataApi:{path:"data",version:"9.2",url:""},searchApi:{path:"search",version:"1.0",url:""}}}};D.mergeApiConfigs=F;W();k();W();W();k();var h=class{static compose(e,t){if(e.path=e.path||"",e.functionName=e.functionName||"",e.url)i.stringParameterCheck(e.url,`DynamicsWebApi.${e.functionName}`,"request.url"),e.path=e.url.replace(t.dataApi.url,""),e.path=h.composeUrl(e,t,e.path);else if(!e._isUnboundRequest&&!e.collection&&i.parameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.collection!=null&&(i.stringParameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.path=e.collection,e.contentId&&(i.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")&&(e.path=`${e.contentId}/${e.path}`)),e.key&&(e.key=i.keyParameterCheck(e.key,`DynamicsWebApi.${e.functionName}`,"request.key"),e.path+=`(${e.key})`)),e._additionalUrl&&(e.path&&(e.path+="/"),e.path+=e._additionalUrl),e.path=h.composeUrl(e,t,e.path),e.fetchXml){i.stringParameterCheck(e.fetchXml,`DynamicsWebApi.${e.functionName}`,"request.fetchXml");let a=e.path.indexOf("?")===-1?"?":"&";e.path+=`${a}fetchXml=${encodeURIComponent(e.fetchXml)}`}return e.hasOwnProperty("async")&&e.async!=null?i.boolParameterCheck(e.async,`DynamicsWebApi.${e.functionName}`,"request.async"):e.async=!0,e.headers=h.composeHeaders(e,t),e}static composeUrl(e,t,a="",n="&"){let r=[];if(e){if(e.navigationProperty){if(i.stringParameterCheck(e.navigationProperty,`DynamicsWebApi.${e.functionName}`,"request.navigationProperty"),a+="/"+e.navigationProperty,e.navigationPropertyKey){let l=i.keyParameterCheck(e.navigationPropertyKey,`DynamicsWebApi.${e.functionName}`,"request.navigationPropertyKey");a+="("+l+")"}e.navigationProperty==="Attributes"&&e.metadataAttributeType&&(i.stringParameterCheck(e.metadataAttributeType,`DynamicsWebApi.${e.functionName}`,"request.metadataAttributeType"),a+="/"+e.metadataAttributeType)}if(e.select?.length&&(i.arrayParameterCheck(e.select,`DynamicsWebApi.${e.functionName}`,"request.select"),e.functionName=="retrieve"&&e.select.length==1&&e.select[0].endsWith("/$ref")?a+="/"+e.select[0]:(e.select[0].startsWith("/")&&e.functionName=="retrieve"&&(e.navigationProperty==null?a+=e.select.shift():e.select.shift()),e.select.length&&r.push("$select="+e.select.join(",")))),e.filter){i.stringParameterCheck(e.filter,`DynamicsWebApi.${e.functionName}`,"request.filter");let l=/[^"']{([\w\d]{8}[-]?(?:[\w\d]{4}[-]?){3}[\w\d]{12})}(?:[^"']|$)/g,o=e.filter,u=null;for(;(u=l.exec(o))!==null;){u.index===l.lastIndex&&l.lastIndex++;let p=u[0].endsWith(")")?")":" ";o=o.replace(u[0]," "+u[1]+p)}r.push("$filter="+encodeURIComponent(o))}if(e.fieldName&&(i.stringParameterCheck(e.fieldName,`DynamicsWebApi.${e.functionName}`,"request.fieldName"),a+="/"+e.fieldName),e.savedQuery&&r.push("savedQuery="+i.guidParameterCheck(e.savedQuery,`DynamicsWebApi.${e.functionName}`,"request.savedQuery")),e.userQuery&&r.push("userQuery="+i.guidParameterCheck(e.userQuery,`DynamicsWebApi.${e.functionName}`,"request.userQuery")),e.apply&&(i.stringParameterCheck(e.apply,`DynamicsWebApi.${e.functionName}`,"request.apply"),r.push("$apply="+e.apply)),e.count&&(i.boolParameterCheck(e.count,`DynamicsWebApi.${e.functionName}`,"request.count"),r.push("$count="+e.count)),e.top&&e.top>0&&(i.numberParameterCheck(e.top,`DynamicsWebApi.${e.functionName}`,"request.top"),r.push("$top="+e.top)),e.orderBy!=null&&e.orderBy.length&&(i.arrayParameterCheck(e.orderBy,`DynamicsWebApi.${e.functionName}`,"request.orderBy"),r.push("$orderby="+e.orderBy.join(","))),e.partitionId&&(i.stringParameterCheck(e.partitionId,`DynamicsWebApi.${e.functionName}`,"request.partitionId"),r.push("partitionid='"+e.partitionId+"'")),e.downloadSize&&(i.stringParameterCheck(e.downloadSize,`DynamicsWebApi.${e.functionName}`,"request.downloadSize"),r.push("size="+e.downloadSize)),e.queryParams?.length&&(i.arrayParameterCheck(e.queryParams,`DynamicsWebApi.${e.functionName}`,"request.queryParams"),r.push(e.queryParams.join("&"))),e.fileName&&(i.stringParameterCheck(e.fileName,`DynamicsWebApi.${e.functionName}`,"request.fileName"),r.push("x-ms-file-name="+e.fileName)),e.data&&i.parameterCheck(e.data,`DynamicsWebApi.${e.functionName}`,"request.data"),e.isBatch&&i.boolParameterCheck(e.isBatch,`DynamicsWebApi.${e.functionName}`,"request.isBatch"),c.isNull(e.inChangeSet)||i.boolParameterCheck(e.inChangeSet,`DynamicsWebApi.${e.functionName}`,"request.inChangeSet"),e.isBatch&&c.isNull(e.inChangeSet)&&(e.inChangeSet=!0),e.timeout&&i.numberParameterCheck(e.timeout,`DynamicsWebApi.${e.functionName}`,"request.timeout"),e.expand?.length)if(i.stringOrArrayParameterCheck(e.expand,`DynamicsWebApi.${e.functionName}`,"request.expand"),typeof e.expand=="string")r.push("$expand="+e.expand);else{let l=[];for(let o=0;o0&&(i.numberParameterCheck(r,`DynamicsWebApi.${e.functionName}`,"request.maxPageSize"),u.push("odata.maxpagesize="+r)),l&&(i.boolParameterCheck(l,`DynamicsWebApi.${e.functionName}`,"request.trackChanges"),u.push("odata.track-changes")),o&&(i.boolParameterCheck(o,`DynamicsWebApi.${e.functionName}`,"request.continueOnError"),u.push("odata.continue-on-error")),u.join(",")}static convertToBatch(e,t,a){let n=`dwa_batch_${c.generateUUID()}`,r=[],l=null,o=1e5;e.forEach(p=>{p.functionName="executeBatch",a?.inChangeSet===!1&&(p.inChangeSet=!1);let m=p.method==="GET"?!1:!!p.inChangeSet;if(!m&&l&&(r.push(` +`)+1).trim();r=r.concat(ee(u,e,t))}else{let u=/HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/gm.exec(o),p=parseInt(u[1]),m=u[2].trim(),f=o.substring(o.indexOf("{"),o.lastIndexOf("}")+1);if(f){let d=B(JSON.parse(f,K),e[t]);if(p>=400){let R=ge(o.substring(o.indexOf(u[0])+u[0].length+1,o.indexOf("{")));r.push(i.handleHttpError(d,{status:p,statusText:m,statusMessage:m,headers:R}))}else r.push(d)}else if(/Content-Type: text\/plain/i.test(o)){let d=/\w+$/gi.exec(o.trim()),R=d&&d.length?d[0]:void 0;r.push(isNaN(Number(R))?R:Number(R))}else if(e.length&&e[t]&&e[t].hasOwnProperty("valueIfEmpty"))r.push(e[t].valueIfEmpty);else{let d=/OData-EntityId.+/i.exec(o);if(d&&d.length){let R=F(d[0]);r.push(R||void 0)}else r.push(void 0)}}t++}return r}function Ce(s){return window.atob(s)}function Ae(s,e,t){let a=s;t.hasOwnProperty("parse")&&(a=JSON.parse(a).value,a=Ce(a));var n={value:a};return e["x-ms-file-name"]&&(n.fileName=e["x-ms-file-name"]),e["x-ms-file-size"]&&(n.fileSize=parseInt(e["x-ms-file-size"])),O(e,"Location")&&(n.location=U(e,"Location")),n}function O(s,e){return s.hasOwnProperty(e)||s.hasOwnProperty(e.toLowerCase())}function U(s,e){return s[e]?s[e]:s[e.toLowerCase()]}function L(s,e,t){let a;if(s.length)if(s.indexOf("--batchresponse_")>-1){let n=ee(s,t);a=t.length===1&&t[0].convertedToBatch?n[0]:n}else O(e,"Content-Disposition")?a=Ae(s,e,t[0]):U(e,"Content-Type").startsWith("application/json")?a=B(JSON.parse(s,K),t[0]):a=isNaN(Number(s))?s:Number(s);else if(t.length&&t[0].hasOwnProperty("valueIfEmpty"))a=t[0].valueIfEmpty;else if(O(e,"OData-EntityId")){let n=U(e,"OData-EntityId"),r=F(n);r&&(a=r)}else O(e,"Location")&&(a={location:U(e,"Location")},e["x-ms-chunk-size"]&&(a.chunkSize=parseInt(e["x-ms-chunk-size"])));return a}var fe,te=b(()=>{"use strict";Z();v();k();Y();w();fe=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/});function T(s){let e={};if(!s)return e;let t=s.split(`\r +`);for(let a=0,n=t.length;a0&&(e[r.substring(0,l)]=r.substring(l+2))}return e}var ne=b(()=>{"use strict"});var ae={};z(ae,{XhrWrapper:()=>I,executeRequest:()=>xe});function xe(s){return new Promise((e,t)=>{ke(s,e,t)})}function ke(s,e,t){let a=s.data,n=s.additionalHeaders,r=s.responseParams,l=s.abortSignal;if(l?.aborted){t(i.handleHttpError({name:"AbortError",code:20,message:"The user aborted a request."}));return}let o=new XMLHttpRequest;o.open(s.method,s.uri,s.isAsync||!1);for(let p in n)o.setRequestHeader(p,n[p]);o.onreadystatechange=function(){if(o.readyState===4)switch(l&&l.removeEventListener("abort",u),o.status){case 200:case 201:case 204:case 206:case 304:{let d=T(o.getAllResponseHeaders()),ce={data:L(o.responseText,d,r[s.requestId]),headers:d,status:o.status};o=null,e(ce);break}case 0:break;default:if(!o)break;let p,m;try{m=T(o.getAllResponseHeaders());let d=L(o.responseText,m,r[s.requestId]);if(Array.isArray(d)){t(d);break}p=d.error}catch{o.response.length>0?p={message:o.response}:p={message:"Unexpected Error"}}let f={status:o.status,statusText:o.statusText,headers:m};o=null,t(i.handleHttpError(p,f));break}},s.timeout&&(o.timeout=s.timeout),o.onerror=function(){let p=T(o.getAllResponseHeaders());t(i.handleHttpError({status:o.status,statusText:o.statusText,message:o.responseText||"Network Error",headers:p})),o=null},o.ontimeout=function(){let p=T(o.getAllResponseHeaders());t(i.handleHttpError({name:"TimeoutError",status:o.status,statusText:o.statusText,message:o.responseText||"Request Timed Out",headers:p})),o=null},o.onabort=function(){if(!o)return;let p=T(o.getAllResponseHeaders());t(i.handleHttpError({status:o.status,statusText:o.statusText,message:"Request aborted",headers:p})),o=null};let u=()=>{if(!o)return;let p=T(o.getAllResponseHeaders());t(i.handleHttpError({name:"AbortError",code:20,status:o.status,statusText:o.statusText,message:"The user aborted a request.",headers:p})),o.abort(),o=null};l&&l.addEventListener("abort",u),a?o.send(a):o.send(),I.afterSendEvent&&I.afterSendEvent()}var I,ie=b(()=>{"use strict";k();te();ne();I=class{}});var De={};z(De,{DynamicsWebApi:()=>H});v();k();var he=(s,e)=>c.isRunningWithinPortals()?new URL("_api",window.location.origin).toString()+"/":(s||(s=c.getClientUrl()),new URL(`api/${e.path}/v${e.version}`,s).toString()+"/"),_=(s,e,t)=>{let a=t[e];s?.version&&(i.stringParameterCheck(s.version,"DynamicsWebApi.setConfig",`config.${e}.version`),a.version=s.version),s?.path&&(i.stringParameterCheck(s.path,"DynamicsWebApi.setConfig",`config.${e}.path`),a.path=s.path),a.url=he(t.serverUrl,a)},P=class{static merge(e,t){t?.serverUrl&&(i.stringParameterCheck(t.serverUrl,"DynamicsWebApi.setConfig","config.serverUrl"),e.serverUrl=t.serverUrl),_(t?.dataApi,"dataApi",e),_(t?.searchApi,"searchApi",e),t?.impersonate&&(e.impersonate=i.guidParameterCheck(t.impersonate,"DynamicsWebApi.setConfig","config.impersonate")),t?.impersonateAAD&&(e.impersonateAAD=i.guidParameterCheck(t.impersonateAAD,"DynamicsWebApi.setConfig","config.impersonateAAD")),t?.onTokenRefresh&&(i.callbackParameterCheck(t.onTokenRefresh,"DynamicsWebApi.setConfig","config.onTokenRefresh"),e.onTokenRefresh=t.onTokenRefresh),t?.includeAnnotations&&(i.stringParameterCheck(t.includeAnnotations,"DynamicsWebApi.setConfig","config.includeAnnotations"),e.includeAnnotations=t.includeAnnotations),t?.timeout&&(i.numberParameterCheck(t.timeout,"DynamicsWebApi.setConfig","config.timeout"),e.timeout=t.timeout),t?.maxPageSize&&(i.numberParameterCheck(t.maxPageSize,"DynamicsWebApi.setConfig","config.maxPageSize"),e.maxPageSize=t.maxPageSize),t?.returnRepresentation&&(i.boolParameterCheck(t.returnRepresentation,"DynamicsWebApi.setConfig","config.returnRepresentation"),e.returnRepresentation=t.returnRepresentation),t?.useEntityNames&&(i.boolParameterCheck(t.useEntityNames,"DynamicsWebApi.setConfig","config.useEntityNames"),e.useEntityNames=t.useEntityNames),t?.headers&&(e.headers=t.headers)}static default(){return{serverUrl:null,impersonate:null,impersonateAAD:null,onTokenRefresh:null,includeAnnotations:null,maxPageSize:null,returnRepresentation:null,proxy:null,dataApi:{path:"data",version:"9.2",url:""},searchApi:{path:"search",version:"1.0",url:""}}}};P.mergeApiConfigs=_;v();k();v();v();k();var h=class h{static compose(e,t){if(e.path=e.path||"",e.functionName=e.functionName||"",e.url)i.stringParameterCheck(e.url,`DynamicsWebApi.${e.functionName}`,"request.url"),e.path=e.url.replace(t.dataApi.url,"");else if(!e._isUnboundRequest&&!e.collection&&i.parameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.collection!=null&&(i.stringParameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.path=e.collection,e.contentId&&(i.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")&&(e.path=`${e.contentId}/${e.path}`)),e.key&&(e.key=i.keyParameterCheck(e.key,`DynamicsWebApi.${e.functionName}`,"request.key"),e.path+=`(${e.key})`)),e._additionalUrl&&(e.path&&(e.path+="/"),e.path+=e._additionalUrl),e.path=h.composeUrl(e,t,e.path),e.fetchXml){i.stringParameterCheck(e.fetchXml,`DynamicsWebApi.${e.functionName}`,"request.fetchXml");let a=e.path.indexOf("?")===-1?"?":"&";e.path+=`${a}fetchXml=${encodeURIComponent(e.fetchXml)}`}return e.hasOwnProperty("async")&&e.async!=null?i.boolParameterCheck(e.async,`DynamicsWebApi.${e.functionName}`,"request.async"):e.async=!0,e.headers=h.composeHeaders(e,t),e}static composeUrl(e,t,a="",n="&"){let r=[];if(e){if(e.navigationProperty){if(i.stringParameterCheck(e.navigationProperty,`DynamicsWebApi.${e.functionName}`,"request.navigationProperty"),a+="/"+e.navigationProperty,e.navigationPropertyKey){let l=i.keyParameterCheck(e.navigationPropertyKey,`DynamicsWebApi.${e.functionName}`,"request.navigationPropertyKey");a+="("+l+")"}e.navigationProperty==="Attributes"&&e.metadataAttributeType&&(i.stringParameterCheck(e.metadataAttributeType,`DynamicsWebApi.${e.functionName}`,"request.metadataAttributeType"),a+="/"+e.metadataAttributeType)}if(e.select?.length&&(i.arrayParameterCheck(e.select,`DynamicsWebApi.${e.functionName}`,"request.select"),e.functionName=="retrieve"&&e.select.length==1&&e.select[0].endsWith("/$ref")?a+="/"+e.select[0]:(e.select[0].startsWith("/")&&e.functionName=="retrieve"&&(e.navigationProperty==null?a+=e.select.shift():e.select.shift()),e.select.length&&r.push("$select="+e.select.join(",")))),e.filter){i.stringParameterCheck(e.filter,`DynamicsWebApi.${e.functionName}`,"request.filter");let l=/[^"']{([\w\d]{8}[-]?(?:[\w\d]{4}[-]?){3}[\w\d]{12})}(?:[^"']|$)/g,o=e.filter,u=null;for(;(u=l.exec(o))!==null;){u.index===l.lastIndex&&l.lastIndex++;let p=u[0].endsWith(")")?")":" ";o=o.replace(u[0]," "+u[1]+p)}r.push("$filter="+encodeURIComponent(o))}if(e.fieldName&&(i.stringParameterCheck(e.fieldName,`DynamicsWebApi.${e.functionName}`,"request.fieldName"),a+="/"+e.fieldName),e.savedQuery&&r.push("savedQuery="+i.guidParameterCheck(e.savedQuery,`DynamicsWebApi.${e.functionName}`,"request.savedQuery")),e.userQuery&&r.push("userQuery="+i.guidParameterCheck(e.userQuery,`DynamicsWebApi.${e.functionName}`,"request.userQuery")),e.apply&&(i.stringParameterCheck(e.apply,`DynamicsWebApi.${e.functionName}`,"request.apply"),r.push("$apply="+e.apply)),e.count&&(i.boolParameterCheck(e.count,`DynamicsWebApi.${e.functionName}`,"request.count"),r.push("$count="+e.count)),e.top&&e.top>0&&(i.numberParameterCheck(e.top,`DynamicsWebApi.${e.functionName}`,"request.top"),r.push("$top="+e.top)),e.orderBy!=null&&e.orderBy.length&&(i.arrayParameterCheck(e.orderBy,`DynamicsWebApi.${e.functionName}`,"request.orderBy"),r.push("$orderby="+e.orderBy.join(","))),e.partitionId&&(i.stringParameterCheck(e.partitionId,`DynamicsWebApi.${e.functionName}`,"request.partitionId"),r.push("partitionid='"+e.partitionId+"'")),e.downloadSize&&(i.stringParameterCheck(e.downloadSize,`DynamicsWebApi.${e.functionName}`,"request.downloadSize"),r.push("size="+e.downloadSize)),e.queryParams?.length&&(i.arrayParameterCheck(e.queryParams,`DynamicsWebApi.${e.functionName}`,"request.queryParams"),r.push(e.queryParams.join("&"))),e.fileName&&(i.stringParameterCheck(e.fileName,`DynamicsWebApi.${e.functionName}`,"request.fileName"),r.push("x-ms-file-name="+e.fileName)),e.data&&i.parameterCheck(e.data,`DynamicsWebApi.${e.functionName}`,"request.data"),e.isBatch&&i.boolParameterCheck(e.isBatch,`DynamicsWebApi.${e.functionName}`,"request.isBatch"),c.isNull(e.inChangeSet)||i.boolParameterCheck(e.inChangeSet,`DynamicsWebApi.${e.functionName}`,"request.inChangeSet"),e.isBatch&&c.isNull(e.inChangeSet)&&(e.inChangeSet=!0),e.timeout&&i.numberParameterCheck(e.timeout,`DynamicsWebApi.${e.functionName}`,"request.timeout"),e.expand?.length)if(i.stringOrArrayParameterCheck(e.expand,`DynamicsWebApi.${e.functionName}`,"request.expand"),typeof e.expand=="string")r.push("$expand="+e.expand);else{let l=[];for(let o=0;o0&&(i.numberParameterCheck(r,`DynamicsWebApi.${e.functionName}`,"request.maxPageSize"),u.push("odata.maxpagesize="+r)),l&&(i.boolParameterCheck(l,`DynamicsWebApi.${e.functionName}`,"request.trackChanges"),u.push("odata.track-changes")),o&&(i.boolParameterCheck(o,`DynamicsWebApi.${e.functionName}`,"request.continueOnError"),u.push("odata.continue-on-error")),u.join(",")}static convertToBatch(e,t,a){let n=`dwa_batch_${c.generateUUID()}`,r=[],l=null,o=1e5;e.forEach(p=>{p.functionName="executeBatch",a?.inChangeSet===!1&&(p.inChangeSet=!1);let m=p.method==="GET"?!1:!!p.inChangeSet;if(!m&&l&&(r.push(` --${l}--`),l=null,o=1e5),l||(r.push(` --${n}`),m&&(l=`changeset_${c.generateUUID()}`,r.push("Content-Type: multipart/mixed;boundary="+l))),m&&r.push(` --${l}`),r.push("Content-Type: application/http"),r.push("Content-Transfer-Encoding: binary"),m){let f=p.headers.hasOwnProperty("Content-ID")?p.headers["Content-ID"]:++o;r.push(`Content-ID: ${f}`)}p.path?.startsWith("$")?r.push(` @@ -12,6 +12,6 @@ ${p.method} ${t.dataApi.url}${p.path} HTTP/1.1`),p.method==="GET"?r.push("Accept ${h.processData(p.data,t)}`)}),l&&r.push(` --${l}--`),r.push(` --${n}--`);let u=h.setStandardHeaders(a?.userHeaders);return u["Content-Type"]=`multipart/mixed;boundary=${n}`,{headers:u,body:r.join(` -`)}}static findCollectionName(e){let t=null;if(!c.isNull(h.entityNames)&&(t=h.entityNames[e],c.isNull(t))){for(let a in h.entityNames)if(h.entityNames[a]===e)return e}return t}static processData(e,t){let a=null;if(e){if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array)return e;a=JSON.stringify(e,(n,r)=>{if(n.endsWith("@odata.bind")||n.endsWith("@odata.id")){if(typeof r=="string"&&!r.startsWith("$")){if(/\(\{[\w\d-]+\}\)/g.test(r)&&(r=r.replace(/(.+)\(\{([\w\d-]+)\}\)/g,"$1($2)")),t.useEntityNames){let l=/([\w_]+)(\([\d\w-]+\))$/,o=l.exec(r);if(o&&o.length>2){let u=h.findCollectionName(o[1]);c.isNull(u)||(r=r.replace(l,u+"$2"))}}r.startsWith(t.dataApi.url)||(n.endsWith("@odata.bind")?r.startsWith("/")||(r="/"+r):r=t.dataApi.url+r.replace(/^\//,""))}}else(n.startsWith("oData")||n.endsWith("_Formatted")||n.endsWith("_NavigationProperty")||n.endsWith("_LogicalName"))&&(r=void 0);return r}),a=a.replace(/[\u007F-\uFFFF]/g,function(n){return"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})}return a}static setStandardHeaders(e={}){return e.Accept||(e.Accept="application/json"),e["OData-MaxVersion"]||(e["OData-MaxVersion"]="4.0"),e["OData-Version"]||(e["OData-Version"]="4.0"),e["Content-Range"]?e["Content-Type"]="application/octet-stream":e["Content-Type"]||(e["Content-Type"]="application/json; charset=utf-8"),e}},y=h;y.entityNames=null;k();async function re(s){return(ie(),X(ae)).executeRequest(s)}var se=(s,e)=>{N[s]?N[s].push(e):N[s]=[e]},ke=(s,e)=>{P[s]?P[s].push(e):P[s]=[e]},L=s=>{delete N[s],P.hasOwnProperty(s)&&delete P[s]},oe=async(s,e)=>{try{let t=await R.sendRequest(s,e);return L(s.requestId),t}catch(t){throw L(s.requestId),t}finally{L(s.requestId)}},P={},N={},R=class{static async sendRequest(e,t){e.headers=e.headers||{},e.responseParameters=e.responseParameters||{},e.requestId=e.requestId||c.generateUUID(),se(e.requestId,e.responseParameters);let a=null,n=e.responseParameters?.convertedToBatch;if(e.path==="$batch"&&!n){let o=P[e.requestId];if(!o)throw i.batchIsEmpty();let u=y.convertToBatch(o,t,e);a=u.body,e.headers={...u.headers,...e.headers},delete P[e.requestId]}else a=n?e.data:y.processData(e.data,t),n||(e.headers=y.setStandardHeaders(e.headers));t.impersonate&&!e.headers.MSCRMCallerID&&(e.headers.MSCRMCallerID=t.impersonate),t.impersonateAAD&&!e.headers.CallerObjectId&&(e.headers.CallerObjectId=t.impersonateAAD);let r=null;if(t.onTokenRefresh&&(!e.headers||e.headers&&!e.headers.Authorization)&&(r=await t.onTokenRefresh(),!r))throw new Error("Token is empty. Request is aborted.");r&&(e.headers.Authorization="Bearer "+(r.hasOwnProperty("accessToken")?r.accessToken:r)),c.isRunningWithinPortals()&&(e.headers.__RequestVerificationToken=await window.shell.getTokenDeferred());let l=e.apiConfig?e.apiConfig.url:t.dataApi.url;return await re({method:e.method,uri:l+e.path,data:a,additionalHeaders:e.headers,responseParams:N,isAsync:e.async,timeout:e.timeout||t.timeout,proxy:t.proxy,requestId:e.requestId,abortSignal:e.signal})}static async _getCollectionNames(e,t){if(!c.isNull(y.entityNames))return y.findCollectionName(e)||e;let a=y.compose({method:"GET",collection:"EntityDefinitions",select:["EntitySetName","LogicalName"],noCache:!0,functionName:"retrieveMultiple"},t),n=await oe(a,t);y.entityNames={};for(let r=0;r-1}static async _checkCollectionName(e,t){if(!e||R._isEntityNameException(e)||(e=e.toLowerCase(),!t.useEntityNames))return e;try{return await R._getCollectionNames(e,t)}catch(a){throw new Error("Unable to fetch Collection Names. Error: "+a.message)}}static async makeRequest(e,t){if(e.responseParameters=e.responseParameters||{},e.userHeaders=e.headers,delete e.headers,!e.isBatch){let a=await R._checkCollectionName(e.collection,t);if(e.collection=a,y.compose(e,t),e.responseParameters.convertedToBatch=!1,e.path.length>2e3){let n=y.convertToBatch([e],t);e.method="POST",e.path="$batch",e.data=n.body,e.headers={...n.headers,...e.userHeaders},e.responseParameters.convertedToBatch=!0}return oe(e,t)}y.compose(e,t),se(e.requestId,e.responseParameters),ke(e.requestId,e)}static _clearTestData(){y.entityNames=null,N={},P={}}static getCollectionName(e){return y.findCollectionName(e)}};var w=class{constructor(e){this._config=D.default();this._isBatch=!1;this._batchRequestId=null;this.setConfig=e=>D.merge(this._config,e);this._makeRequest=async e=>(e.isBatch=this._isBatch,this._batchRequestId&&(e.requestId=this._batchRequestId),R.makeRequest(e,this._config));this.create=async e=>{i.parameterCheck(e,"DynamicsWebApi.create","request");let t;return e.functionName?t=e:(t=c.copyRequest(e),t.functionName="create"),t.method="POST",(await this._makeRequest(t))?.data};this.retrieve=async e=>{i.parameterCheck(e,"DynamicsWebApi.retrieve","request");let t;return e.functionName?t=e:(t=c.copyRequest(e),t.functionName="retrieve"),t.method="GET",t.responseParameters={isRef:t.select?.length===1&&t.select[0].endsWith("/$ref")},(await this._makeRequest(t))?.data};this.update=async e=>{i.parameterCheck(e,"DynamicsWebApi.update","request");let t;e.functionName?t=e:(t=c.copyRequest(e),t.functionName="update"),t.method||(t.method=/EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(t.collection||"")?"PUT":"PATCH"),t.responseParameters={valueIfEmpty:!0},t.ifmatch==null&&(t.ifmatch="*");let a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};this.updateSingleProperty=async e=>{i.parameterCheck(e,"DynamicsWebApi.updateSingleProperty","request"),i.parameterCheck(e.fieldValuePair,"DynamicsWebApi.updateSingleProperty","request.fieldValuePair");var t=Object.keys(e.fieldValuePair)[0],a=e.fieldValuePair[t];let n=c.copyRequest(e);return n.navigationProperty=t,n.data={value:a},n.functionName="updateSingleProperty",n.method="PUT",delete n.fieldValuePair,(await this._makeRequest(n))?.data};this.deleteRecord=async e=>{i.parameterCheck(e,"DynamicsWebApi.deleteRecord","request");let t;e.functionName?t=e:(t=c.copyRequest(e),t.functionName="deleteRecord"),t.method="DELETE",t.responseParameters={valueIfEmpty:!0};let a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};this.upsert=async e=>{i.parameterCheck(e,"DynamicsWebApi.upsert","request");let t=c.copyRequest(e);t.method="PATCH",t.functionName="upsert";let a=t.ifnonematch,n=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(r){if(a&&r.status===412)return null;if(n&&r.status===404)return null;throw r}};this._uploadFileChunk=async(e,t,a,n=0)=>{if(c.setFileChunk(e,t,a,n),await this._makeRequest(e),n+=a,n<=t.length)return this._uploadFileChunk(e,t,a,n)};this.uploadFile=async e=>{i.throwBatchIncompatible("DynamicsWebApi.uploadFile",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.uploadFile","request");let t=c.copyRequest(e,["data"]);t.method="PATCH",t.functionName="uploadFile",t.transferMode="chunked";let a=await this._makeRequest(t);return t.url=a?.data.location,delete t.transferMode,delete t.fieldName,delete t.fileName,this._uploadFileChunk(t,e.data,a?.data.chunkSize)};this._downloadFileChunk=async(e,t=0,a="")=>{e.range="bytes="+t+"-"+(t+c.downloadChunkSize-1),e.downloadSize="full";let n=await this._makeRequest(e);return e.url=n?.data.location,a+=n?.data.value,t+=c.downloadChunkSize,t<=n?.data.fileSize?this._downloadFileChunk(e,t,a):{fileName:n?.data.fileName,fileSize:n?.data.fileSize,data:c.convertToFileBuffer(a)}};this.downloadFile=e=>{i.throwBatchIncompatible("DynamicsWebApi.downloadFile",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.downloadFile","request");let t=c.copyRequest(e);return t.method="GET",t.functionName="downloadFile",t.responseParameters={parse:!0},this._downloadFileChunk(t)};this.retrieveMultiple=async(e,t)=>{i.parameterCheck(e,"DynamicsWebApi.retrieveMultiple","request");let a;return e.functionName?a=e:(a=c.copyRequest(e),a.functionName="retrieveMultiple"),a.method="GET",t&&(i.stringParameterCheck(t,"DynamicsWebApi.retrieveMultiple","nextPageLink"),a.url=t),(await this._makeRequest(a))?.data};this._retrieveAllRequest=async(e,t,a=[])=>{let n=await this.retrieveMultiple(e,t);a=a.concat(n.value);let r=n.oDataNextLink;if(r)return this._retrieveAllRequest(e,r,a);let l={value:a};return n.oDataDeltaLink&&(l["@odata.deltaLink"]=n.oDataDeltaLink,l.oDataDeltaLink=n.oDataDeltaLink),l};this.retrieveAll=e=>(i.throwBatchIncompatible("DynamicsWebApi.retrieveAll",this._isBatch),this._retrieveAllRequest(e));this.count=async e=>{i.parameterCheck(e,"DynamicsWebApi.count","request");let t=c.copyRequest(e);return t.method="GET",t.functionName="count",t.filter?.length?t.count=!0:t.navigationProperty="$count",t.responseParameters={toCount:t.count},(await this._makeRequest(t))?.data};this.countAll=async e=>{i.throwBatchIncompatible("DynamicsWebApi.countAll",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.countAll","request");let t=await this._retrieveAllRequest(e);return t&&t.value?t.value.length:0};this.fetch=async e=>{i.parameterCheck(e,"DynamicsWebApi.fetch","request");let t=c.copyRequest(e);if(t.method="GET",t.functionName="fetch",i.stringParameterCheck(t.fetchXml,"DynamicsWebApi.fetch","request.fetchXml"),t.fetchXml&&!/^{i.parameterCheck(e,"DynamicsWebApi.fetchAll","request");let t=async(a,n=[])=>{let r=await this.fetch(a);return n=n.concat(r.value),r.PagingInfo?(a.pageNumber=r.PagingInfo.nextPage,a.pagingCookie=r.PagingInfo.cookie,t(a,n)):{value:n}};return i.throwBatchIncompatible("DynamicsWebApi.fetchAll",this._isBatch),t(e)};this.associate=async e=>{i.parameterCheck(e,"DynamicsWebApi.associate","request");let t=c.copyRequest(e);t.method="POST",t.functionName="associate",i.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associate","request.relatedcollection"),i.stringParameterCheck(e.relationshipName,"DynamicsWebApi.associate","request.relationshipName");let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associate","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associate","request.relatedKey");t.navigationProperty=e.relationshipName+"/$ref",t.key=a,t.data={"@odata.id":`${e.relatedCollection}(${n})`},await this._makeRequest(t)};this.disassociate=async e=>{i.parameterCheck(e,"DynamicsWebApi.disassociate","request");let t=c.copyRequest(e);t.method="DELETE",t.functionName="disassociate",i.stringParameterCheck(e.relationshipName,"DynamicsWebApi.disassociate","request.relationshipName");let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociate","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.disassociate","request.relatedId");t.key=a,t.navigationProperty=`${e.relationshipName}(${n})/$ref`,await this._makeRequest(t)};this.associateSingleValued=async e=>{i.parameterCheck(e,"DynamicsWebApi.associateSingleValued","request");let t=c.copyRequest(e);t.method="PUT",t.functionName="associateSingleValued";let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associateSingleValued","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associateSingleValued","request.relatedKey");i.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.associateSingleValued","request.navigationProperty"),i.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associateSingleValued","request.relatedcollection"),t.navigationProperty+="/$ref",t.key=a,t.data={"@odata.id":`${e.relatedCollection}(${n})`},await this._makeRequest(t)};this.disassociateSingleValued=async e=>{i.parameterCheck(e,"DynamicsWebApi.disassociateSingleValued","request");let t=c.copyRequest(e);t.method="DELETE",t.functionName="disassociateSingleValued";let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociateSingleValued","request.primaryKey");i.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.disassociateSingleValued","request.navigationProperty"),t.navigationProperty+="/$ref",t.key=a,await this._makeRequest(t)};this.callFunction=async e=>{i.parameterCheck(e,"DynamicsWebApi.callFunction","request");let t=c.isObject(e),a=t?"request.functionName":"name",n=t?c.copyObject(e):{functionName:e};return i.stringParameterCheck(n.functionName,"DynamicsWebApi.callFunction",a),n.method="GET",n._additionalUrl=n.functionName+c.buildFunctionParameters(n.parameters),n._isUnboundRequest=!n.collection,n.functionName="callFunction",(await this._makeRequest(n))?.data};this.callAction=async e=>{i.parameterCheck(e,"DynamicsWebApi.callAction","request"),i.stringParameterCheck(e.actionName,"DynamicsWebApi.callAction","request.actionName");let t=c.copyRequest(e,["action"]);return t.method="POST",t.functionName="callAction",t._additionalUrl=e.actionName,t._isUnboundRequest=!t.collection,t.data=e.action,(await this._makeRequest(t))?.data};this.createEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.createEntity","request"),i.parameterCheck(e.data,"DynamicsWebApi.createEntity","request.data");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="createEntity",this.create(t)};this.updateEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.updateEntity","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateEntity","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateEntity","request.data.MetadataId");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.key=t.data.MetadataId,t.functionName="updateEntity",t.method="PUT",this.update(t)};this.retrieveEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveEntity","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.retrieveEntity","request.key");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",this.retrieve(t)};this.retrieveEntities=e=>{let t=e?c.copyRequest(e):{};return t.collection="EntityDefinitions",t.functionName="retrieveEntities",this.retrieveMultiple(t)};this.createAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.createAttribute","request"),i.parameterCheck(e.data,"DynamicsWebApi.createAttribute","request.data"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.createAttribute","request.entityKey");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",t.navigationProperty="Attributes",t.key=e.entityKey,this.create(t)};this.updateAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.updateAttribute","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateAttribute","request.data"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.updateAttribute","request.entityKey"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateAttribute","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateAttribute","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.navigationPropertyKey=e.data.MetadataId,t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="updateAttribute",t.method="PUT",this.update(t)};this.retrieveAttributes=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttributes","request.entityKey"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttributes","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="retrieveAttributes",this.retrieveMultiple(t)};this.retrieveAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttribute","request.entityKey"),i.keyParameterCheck(e.attributeKey,"DynamicsWebApi.retrieveAttribute","request.attributeKey"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttribute","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.navigationPropertyKey=e.attributeKey,t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="retrieveAttribute",this.retrieve(t)};this.createRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.createRelationship","request"),i.parameterCheck(e.data,"DynamicsWebApi.createRelationship","request.data");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="createRelationship",this.create(t)};this.updateRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.updateRelationship","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateRelationship","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateRelationship","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateRelationship","request.castType");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.key=e.data.MetadataId,t.navigationProperty=e.castType,t.functionName="updateRelationship",t.method="PUT",this.update(t)};this.deleteRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.deleteRelationship","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.deleteRelationship","request.key");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="deleteRelationship",this.deleteRecord(t)};this.retrieveRelationships=e=>{let t=e?c.copyRequest(e):{};return t.collection="RelationshipDefinitions",t.functionName="retrieveRelationships",e&&e.castType&&(i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationships","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveRelationship","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.retrieveRelationship","request.key"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationship","request.castType");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveRelationship",this.retrieve(t)};this.createGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.createGlobalOptionSet","request"),i.parameterCheck(e.data,"DynamicsWebApi.createGlobalOptionSet","request.data");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="createGlobalOptionSet",this.create(t)};this.updateGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.updateGlobalOptionSet","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateGlobalOptionSet","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateGlobalOptionSet","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateGlobalOptionSet","request.castType");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.key=e.data.MetadataId,t.functionName="updateGlobalOptionSet",t.method="PUT",this.update(t)};this.deleteGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.deleteGlobalOptionSet","request");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="deleteGlobalOptionSet",this.deleteRecord(t)};this.retrieveGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveGlobalOptionSet","request"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSet","request.castType");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveGlobalOptionSet",this.retrieve(t)};this.retrieveGlobalOptionSets=e=>{let t=e?c.copyRequest(e):{};return t.collection="GlobalOptionSetDefinitions",t.functionName="retrieveGlobalOptionSets",e?.castType&&(i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSets","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveCsdlMetadata=async e=>{let t=e?c.copyRequest(e):{};return t.collection="$metadata",t.functionName="retrieveCsdlMetadata",e?.addAnnotations&&(i.boolParameterCheck(e.addAnnotations,"DynamicsWebApi.retrieveCsdlMetadata","request.addAnnotations"),t.includeAnnotations="*"),(await this._makeRequest(t))?.data};this.search=async e=>{i.parameterCheck(e,"DynamicsWebApi.search","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return i.parameterCheck(n.query,"DynamicsWebApi.search","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.search",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.search",a,100),n.collection="query",n.functionName="search",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.suggest=async e=>{i.parameterCheck(e,"DynamicsWebApi.suggest","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return i.parameterCheck(n.query,"DynamicsWebApi.suggest","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.suggest",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.suggest",a,100),n.functionName=n.collection="suggest",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.autocomplete=async e=>{i.parameterCheck(e,"DynamicsWebApi.autocomplete","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return t&&i.parameterCheck(n.query,"DynamicsWebApi.autocomplete","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.autocomplete",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.autocomplete",a,100),n.functionName=n.collection="autocomplete",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.startBatch=()=>{this._isBatch=!0,this._batchRequestId=c.generateUUID()};this.executeBatch=async e=>{i.throwBatchNotStarted(this._isBatch);let t=e?c.copyRequest(e):{};return t.collection="$batch",t.method="POST",t.functionName="executeBatch",t.requestId=this._batchRequestId,this._batchRequestId=null,this._isBatch=!1,(await this._makeRequest(t))?.data};this.initializeInstance=e=>new w(e||this._config);this.Utility={getCollectionName:e=>R.getCollectionName(e)};D.merge(this._config,e)}};return X(De);})(); +`)}}static findCollectionName(e){let t=null;if(!c.isNull(h.entityNames)&&(t=h.entityNames[e],c.isNull(t))){for(let a in h.entityNames)if(h.entityNames[a]===e)return e}return t}static processData(e,t){let a=null;if(e){if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array)return e;a=JSON.stringify(e,(n,r)=>{if(n.endsWith("@odata.bind")||n.endsWith("@odata.id")){if(typeof r=="string"&&!r.startsWith("$")){if(/\(\{[\w\d-]+\}\)/g.test(r)&&(r=r.replace(/(.+)\(\{([\w\d-]+)\}\)/g,"$1($2)")),t.useEntityNames){let l=/([\w_]+)(\([\d\w-]+\))$/,o=l.exec(r);if(o&&o.length>2){let u=h.findCollectionName(o[1]);c.isNull(u)||(r=r.replace(l,u+"$2"))}}r.startsWith(t.dataApi.url)||(n.endsWith("@odata.bind")?r.startsWith("/")||(r="/"+r):r=t.dataApi.url+r.replace(/^\//,""))}}else(n.startsWith("oData")||n.endsWith("_Formatted")||n.endsWith("_NavigationProperty")||n.endsWith("_LogicalName"))&&(r=void 0);return r}),a=a.replace(/[\u007F-\uFFFF]/g,function(n){return"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})}return a}static setStandardHeaders(e={}){return e.Accept||(e.Accept="application/json"),e["OData-MaxVersion"]||(e["OData-MaxVersion"]="4.0"),e["OData-Version"]||(e["OData-Version"]="4.0"),e["Content-Range"]?e["Content-Type"]="application/octet-stream":e["Content-Type"]||(e["Content-Type"]="application/json; charset=utf-8"),e}};h.entityNames=null;var y=h;k();async function re(s){return(ie(),X(ae)).executeRequest(s)}var se=(s,e)=>{W[s]?W[s].push(e):W[s]=[e]},Pe=(s,e)=>{x[s]?x[s].push(e):x[s]=[e]},V=s=>{delete W[s],x.hasOwnProperty(s)&&delete x[s]},oe=async(s,e)=>{try{let t=await N.sendRequest(s,e);return V(s.requestId),t}catch(t){throw V(s.requestId),t}finally{V(s.requestId)}},x={},W={},N=class s{static async sendRequest(e,t){e.headers=e.headers||{},e.responseParameters=e.responseParameters||{},e.requestId=e.requestId||c.generateUUID(),se(e.requestId,e.responseParameters);let a=null,n=e.responseParameters?.convertedToBatch;if(e.path==="$batch"&&!n){let o=x[e.requestId];if(!o)throw i.batchIsEmpty();let u=y.convertToBatch(o,t,e);a=u.body,e.headers={...u.headers,...e.headers},delete x[e.requestId]}else a=n?e.data:y.processData(e.data,t),n||(e.headers=y.setStandardHeaders(e.headers));t.impersonate&&!e.headers.MSCRMCallerID&&(e.headers.MSCRMCallerID=t.impersonate),t.impersonateAAD&&!e.headers.CallerObjectId&&(e.headers.CallerObjectId=t.impersonateAAD);let r=null;if(t.onTokenRefresh&&(!e.headers||e.headers&&!e.headers.Authorization)&&(r=await t.onTokenRefresh(),!r))throw new Error("Token is empty. Request is aborted.");r&&(e.headers.Authorization="Bearer "+(r.hasOwnProperty("accessToken")?r.accessToken:r)),c.isRunningWithinPortals()&&(e.headers.__RequestVerificationToken=await window.shell.getTokenDeferred());let l=e.apiConfig?e.apiConfig.url:t.dataApi.url;return await re({method:e.method,uri:l.toString()+e.path,data:a,additionalHeaders:e.headers,responseParams:W,isAsync:e.async,timeout:e.timeout||t.timeout,proxy:t.proxy,requestId:e.requestId,abortSignal:e.signal})}static async _getCollectionNames(e,t){if(!c.isNull(y.entityNames))return y.findCollectionName(e)||e;let a=y.compose({method:"GET",collection:"EntityDefinitions",select:["EntitySetName","LogicalName"],noCache:!0,functionName:"retrieveMultiple"},t),n=await oe(a,t);y.entityNames={};for(let r=0;r-1}static async _checkCollectionName(e,t){if(!e||s._isEntityNameException(e)||(e=e.toLowerCase(),!t.useEntityNames))return e;try{return await s._getCollectionNames(e,t)}catch(a){throw new Error("Unable to fetch Collection Names. Error: "+a.message)}}static async makeRequest(e,t){if(e.responseParameters=e.responseParameters||{},e.userHeaders=e.headers,delete e.headers,!e.isBatch){let a=await s._checkCollectionName(e.collection,t);if(e.collection=a,y.compose(e,t),e.responseParameters.convertedToBatch=!1,e.path.length>2e3){let n=y.convertToBatch([e],t);e.method="POST",e.path="$batch",e.data=n.body,e.headers={...n.headers,...e.userHeaders},e.responseParameters.convertedToBatch=!0}return oe(e,t)}y.compose(e,t),se(e.requestId,e.responseParameters),Pe(e.requestId,e)}static _clearTestData(){y.entityNames=null,W={},x={}}static getCollectionName(e){return y.findCollectionName(e)}};var H=class s{constructor(e){this._config=P.default();this._isBatch=!1;this._batchRequestId=null;this.setConfig=e=>P.merge(this._config,e);this._makeRequest=async e=>(e.isBatch=this._isBatch,this._batchRequestId&&(e.requestId=this._batchRequestId),N.makeRequest(e,this._config));this.create=async e=>{i.parameterCheck(e,"DynamicsWebApi.create","request");let t;return e.functionName?t=e:(t=c.copyRequest(e),t.functionName="create"),t.method="POST",(await this._makeRequest(t))?.data};this.retrieve=async e=>{i.parameterCheck(e,"DynamicsWebApi.retrieve","request");let t;return e.functionName?t=e:(t=c.copyRequest(e),t.functionName="retrieve"),t.method="GET",t.responseParameters={isRef:t.select?.length===1&&t.select[0].endsWith("/$ref")},(await this._makeRequest(t))?.data};this.update=async e=>{i.parameterCheck(e,"DynamicsWebApi.update","request");let t;e.functionName?t=e:(t=c.copyRequest(e),t.functionName="update"),t.method||(t.method=/EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(t.collection||"")?"PUT":"PATCH"),t.responseParameters={valueIfEmpty:!0},t.ifmatch==null&&(t.ifmatch="*");let a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};this.updateSingleProperty=async e=>{i.parameterCheck(e,"DynamicsWebApi.updateSingleProperty","request"),i.parameterCheck(e.fieldValuePair,"DynamicsWebApi.updateSingleProperty","request.fieldValuePair");var t=Object.keys(e.fieldValuePair)[0],a=e.fieldValuePair[t];let n=c.copyRequest(e);return n.navigationProperty=t,n.data={value:a},n.functionName="updateSingleProperty",n.method="PUT",delete n.fieldValuePair,(await this._makeRequest(n))?.data};this.deleteRecord=async e=>{i.parameterCheck(e,"DynamicsWebApi.deleteRecord","request");let t;e.functionName?t=e:(t=c.copyRequest(e),t.functionName="deleteRecord"),t.method="DELETE",t.responseParameters={valueIfEmpty:!0};let a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};this.upsert=async e=>{i.parameterCheck(e,"DynamicsWebApi.upsert","request");let t=c.copyRequest(e);t.method="PATCH",t.functionName="upsert";let a=t.ifnonematch,n=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(r){if(a&&r.status===412)return null;if(n&&r.status===404)return null;throw r}};this._uploadFileChunk=async(e,t,a,n=0)=>{if(c.setFileChunk(e,t,a,n),await this._makeRequest(e),n+=a,n<=t.length)return this._uploadFileChunk(e,t,a,n)};this.uploadFile=async e=>{i.throwBatchIncompatible("DynamicsWebApi.uploadFile",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.uploadFile","request");let t=c.copyRequest(e,["data"]);t.method="PATCH",t.functionName="uploadFile",t.transferMode="chunked";let a=await this._makeRequest(t);return t.url=a?.data.location,delete t.transferMode,delete t.fieldName,delete t.fileName,this._uploadFileChunk(t,e.data,a?.data.chunkSize)};this._downloadFileChunk=async(e,t=0,a="")=>{e.range="bytes="+t+"-"+(t+c.downloadChunkSize-1),e.downloadSize="full";let n=await this._makeRequest(e);return e.url=n?.data.location,a+=n?.data.value,t+=c.downloadChunkSize,t<=n?.data.fileSize?this._downloadFileChunk(e,t,a):{fileName:n?.data.fileName,fileSize:n?.data.fileSize,data:c.convertToFileBuffer(a)}};this.downloadFile=e=>{i.throwBatchIncompatible("DynamicsWebApi.downloadFile",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.downloadFile","request");let t=c.copyRequest(e);return t.method="GET",t.functionName="downloadFile",t.responseParameters={parse:!0},this._downloadFileChunk(t)};this.retrieveMultiple=async(e,t)=>{i.parameterCheck(e,"DynamicsWebApi.retrieveMultiple","request");let a;return e.functionName?a=e:(a=c.copyRequest(e),a.functionName="retrieveMultiple"),a.method="GET",t&&(i.stringParameterCheck(t,"DynamicsWebApi.retrieveMultiple","nextPageLink"),a.url=t),(await this._makeRequest(a))?.data};this._retrieveAllRequest=async(e,t,a=[])=>{let n=await this.retrieveMultiple(e,t);a=a.concat(n.value);let r=n.oDataNextLink;if(r)return this._retrieveAllRequest(e,r,a);let l={value:a};return n.oDataDeltaLink&&(l["@odata.deltaLink"]=n.oDataDeltaLink,l.oDataDeltaLink=n.oDataDeltaLink),l};this.retrieveAll=e=>(i.throwBatchIncompatible("DynamicsWebApi.retrieveAll",this._isBatch),this._retrieveAllRequest(e));this.count=async e=>{i.parameterCheck(e,"DynamicsWebApi.count","request");let t=c.copyRequest(e);return t.method="GET",t.functionName="count",t.filter?.length?t.count=!0:t.navigationProperty="$count",t.responseParameters={toCount:t.count},(await this._makeRequest(t))?.data};this.countAll=async e=>{i.throwBatchIncompatible("DynamicsWebApi.countAll",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.countAll","request");let t=await this._retrieveAllRequest(e);return t&&t.value?t.value.length:0};this.fetch=async e=>{i.parameterCheck(e,"DynamicsWebApi.fetch","request");let t=c.copyRequest(e);if(t.method="GET",t.functionName="fetch",i.stringParameterCheck(t.fetchXml,"DynamicsWebApi.fetch","request.fetchXml"),t.fetchXml&&!/^{i.parameterCheck(e,"DynamicsWebApi.fetchAll","request");let t=async(a,n=[])=>{let r=await this.fetch(a);return n=n.concat(r.value),r.PagingInfo?(a.pageNumber=r.PagingInfo.nextPage,a.pagingCookie=r.PagingInfo.cookie,t(a,n)):{value:n}};return i.throwBatchIncompatible("DynamicsWebApi.fetchAll",this._isBatch),t(e)};this.associate=async e=>{i.parameterCheck(e,"DynamicsWebApi.associate","request");let t=c.copyRequest(e);t.method="POST",t.functionName="associate",i.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associate","request.relatedcollection"),i.stringParameterCheck(e.relationshipName,"DynamicsWebApi.associate","request.relationshipName");let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associate","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associate","request.relatedKey");t.navigationProperty=e.relationshipName+"/$ref",t.key=a,t.data={"@odata.id":`${e.relatedCollection}(${n})`},await this._makeRequest(t)};this.disassociate=async e=>{i.parameterCheck(e,"DynamicsWebApi.disassociate","request");let t=c.copyRequest(e);t.method="DELETE",t.functionName="disassociate",i.stringParameterCheck(e.relationshipName,"DynamicsWebApi.disassociate","request.relationshipName");let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociate","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.disassociate","request.relatedId");t.key=a,t.navigationProperty=`${e.relationshipName}(${n})/$ref`,await this._makeRequest(t)};this.associateSingleValued=async e=>{i.parameterCheck(e,"DynamicsWebApi.associateSingleValued","request");let t=c.copyRequest(e);t.method="PUT",t.functionName="associateSingleValued";let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associateSingleValued","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associateSingleValued","request.relatedKey");i.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.associateSingleValued","request.navigationProperty"),i.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associateSingleValued","request.relatedcollection"),t.navigationProperty+="/$ref",t.key=a,t.data={"@odata.id":`${e.relatedCollection}(${n})`},await this._makeRequest(t)};this.disassociateSingleValued=async e=>{i.parameterCheck(e,"DynamicsWebApi.disassociateSingleValued","request");let t=c.copyRequest(e);t.method="DELETE",t.functionName="disassociateSingleValued";let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociateSingleValued","request.primaryKey");i.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.disassociateSingleValued","request.navigationProperty"),t.navigationProperty+="/$ref",t.key=a,await this._makeRequest(t)};this.callFunction=async e=>{i.parameterCheck(e,"DynamicsWebApi.callFunction","request");let t=c.isObject(e),a=t?"request.functionName":"name",n=t?c.copyObject(e):{functionName:e};return i.stringParameterCheck(n.functionName,"DynamicsWebApi.callFunction",a),n.method="GET",n._additionalUrl=n.functionName+c.buildFunctionParameters(n.parameters),n._isUnboundRequest=!n.collection,n.functionName="callFunction",(await this._makeRequest(n))?.data};this.callAction=async e=>{i.parameterCheck(e,"DynamicsWebApi.callAction","request"),i.stringParameterCheck(e.actionName,"DynamicsWebApi.callAction","request.actionName");let t=c.copyRequest(e,["action"]);return t.method="POST",t.functionName="callAction",t._additionalUrl=e.actionName,t._isUnboundRequest=!t.collection,t.data=e.action,(await this._makeRequest(t))?.data};this.createEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.createEntity","request"),i.parameterCheck(e.data,"DynamicsWebApi.createEntity","request.data");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="createEntity",this.create(t)};this.updateEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.updateEntity","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateEntity","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateEntity","request.data.MetadataId");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.key=t.data.MetadataId,t.functionName="updateEntity",t.method="PUT",this.update(t)};this.retrieveEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveEntity","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.retrieveEntity","request.key");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",this.retrieve(t)};this.retrieveEntities=e=>{let t=e?c.copyRequest(e):{};return t.collection="EntityDefinitions",t.functionName="retrieveEntities",this.retrieveMultiple(t)};this.createAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.createAttribute","request"),i.parameterCheck(e.data,"DynamicsWebApi.createAttribute","request.data"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.createAttribute","request.entityKey");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",t.navigationProperty="Attributes",t.key=e.entityKey,this.create(t)};this.updateAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.updateAttribute","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateAttribute","request.data"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.updateAttribute","request.entityKey"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateAttribute","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateAttribute","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.navigationPropertyKey=e.data.MetadataId,t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="updateAttribute",t.method="PUT",this.update(t)};this.retrieveAttributes=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttributes","request.entityKey"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttributes","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="retrieveAttributes",this.retrieveMultiple(t)};this.retrieveAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttribute","request.entityKey"),i.keyParameterCheck(e.attributeKey,"DynamicsWebApi.retrieveAttribute","request.attributeKey"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttribute","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.navigationPropertyKey=e.attributeKey,t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="retrieveAttribute",this.retrieve(t)};this.createRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.createRelationship","request"),i.parameterCheck(e.data,"DynamicsWebApi.createRelationship","request.data");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="createRelationship",this.create(t)};this.updateRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.updateRelationship","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateRelationship","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateRelationship","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateRelationship","request.castType");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.key=e.data.MetadataId,t.navigationProperty=e.castType,t.functionName="updateRelationship",t.method="PUT",this.update(t)};this.deleteRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.deleteRelationship","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.deleteRelationship","request.key");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="deleteRelationship",this.deleteRecord(t)};this.retrieveRelationships=e=>{let t=e?c.copyRequest(e):{};return t.collection="RelationshipDefinitions",t.functionName="retrieveRelationships",e&&e.castType&&(i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationships","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveRelationship","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.retrieveRelationship","request.key"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationship","request.castType");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveRelationship",this.retrieve(t)};this.createGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.createGlobalOptionSet","request"),i.parameterCheck(e.data,"DynamicsWebApi.createGlobalOptionSet","request.data");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="createGlobalOptionSet",this.create(t)};this.updateGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.updateGlobalOptionSet","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateGlobalOptionSet","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateGlobalOptionSet","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateGlobalOptionSet","request.castType");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.key=e.data.MetadataId,t.functionName="updateGlobalOptionSet",t.method="PUT",this.update(t)};this.deleteGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.deleteGlobalOptionSet","request");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="deleteGlobalOptionSet",this.deleteRecord(t)};this.retrieveGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveGlobalOptionSet","request"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSet","request.castType");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveGlobalOptionSet",this.retrieve(t)};this.retrieveGlobalOptionSets=e=>{let t=e?c.copyRequest(e):{};return t.collection="GlobalOptionSetDefinitions",t.functionName="retrieveGlobalOptionSets",e?.castType&&(i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSets","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveCsdlMetadata=async e=>{let t=e?c.copyRequest(e):{};return t.collection="$metadata",t.functionName="retrieveCsdlMetadata",e?.addAnnotations&&(i.boolParameterCheck(e.addAnnotations,"DynamicsWebApi.retrieveCsdlMetadata","request.addAnnotations"),t.includeAnnotations="*"),(await this._makeRequest(t))?.data};this.search=async e=>{i.parameterCheck(e,"DynamicsWebApi.search","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return i.parameterCheck(n.query,"DynamicsWebApi.search","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.search",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.search",a,100),n.collection="query",n.functionName="search",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.suggest=async e=>{i.parameterCheck(e,"DynamicsWebApi.suggest","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return i.parameterCheck(n.query,"DynamicsWebApi.suggest","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.suggest",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.suggest",a,100),n.functionName=n.collection="suggest",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.autocomplete=async e=>{i.parameterCheck(e,"DynamicsWebApi.autocomplete","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return t&&i.parameterCheck(n.query,"DynamicsWebApi.autocomplete","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.autocomplete",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.autocomplete",a,100),n.functionName=n.collection="autocomplete",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.startBatch=()=>{this._isBatch=!0,this._batchRequestId=c.generateUUID()};this.executeBatch=async e=>{i.throwBatchNotStarted(this._isBatch);let t=e?c.copyRequest(e):{};return t.collection="$batch",t.method="POST",t.functionName="executeBatch",t.requestId=this._batchRequestId,this._batchRequestId=null,this._isBatch=!1,(await this._makeRequest(t))?.data};this.initializeInstance=e=>new s(e||this._config);this.Utility={getCollectionName:e=>N.getCollectionName(e)};P.merge(this._config,e)}};return X(De);})(); var DynamicsWebApi = _dynamicsWebApiExports.DynamicsWebApi //# sourceMappingURL=dynamics-web-api.min.js.map diff --git a/dist/dynamics-web-api.min.js.map b/dist/dynamics-web-api.min.js.map index fd249d5..7c7b8c2 100644 --- a/dist/dynamics-web-api.min.js.map +++ b/dist/dynamics-web-api.min.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/helpers/Crypto.ts", "../src/helpers/Regex.ts", "../src/utils/Utility.ts", "../src/helpers/ErrorHelper.ts", "../src/dwa.ts", "../src/client/helpers/dateReviver.ts", "../src/client/helpers/parseResponse.ts", "../src/client/helpers/parseResponseHeaders.ts", "../src/client/xhr.ts", "../src/dynamics-web-api.ts", "../src/utils/Config.ts", "../src/client/RequestClient.ts", "../src/utils/Request.ts", "../src/client/helpers/executeRequest.ts"], - "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): any {\r\n\tconst headers = {};\r\n\tif (!headerStr) {\r\n\t\treturn headers;\r\n\t}\r\n\tconst headerPairs = headerStr.split(\"\\u000d\\u000a\");\r\n\tfor (let i = 0, ilen = headerPairs.length; i < ilen; i++) {\r\n\t\tconst headerPair = headerPairs[i];\r\n\t\tconst index = headerPair.indexOf(\"\\u003a\\u0020\");\r\n\t\tif (index > 0) {\r\n\t\t\theaders[headerPair.substring(0, index)] = headerPair.substring(index + 2);\r\n\t\t}\r\n\t}\r\n\treturn headers;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\nimport { parseResponseHeaders } from \"./helpers/parseResponseHeaders\";\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n if (signal?.aborted) {\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n message: \"The user aborted a request.\",\r\n })\r\n );\r\n\r\n return;\r\n }\r\n\r\n let request = new XMLHttpRequest();\r\n request.open(options.method, options.uri, options.isAsync || false);\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n request.setRequestHeader(key, additionalHeaders[key]);\r\n }\r\n\r\n request.onreadystatechange = function () {\r\n if (request.readyState === 4) {\r\n if (signal) signal.removeEventListener(\"abort\", abort);\r\n\r\n switch (request.status) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: // Success with partial content.\r\n case 304: {\r\n // Success with Not Modified\r\n const responseHeaders = parseResponseHeaders(request.getAllResponseHeaders());\r\n const responseData = parseResponse(request.responseText, responseHeaders, responseParams[options.requestId]);\r\n\r\n const response = {\r\n data: responseData,\r\n headers: responseHeaders,\r\n status: request.status,\r\n };\r\n\r\n request = null as any;\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n case 0:\r\n break; //response will be handled by onerror\r\n default:\r\n if (!request) break; //response was handled somewhere else\r\n\r\n // All other statuses are error cases.\r\n let error;\r\n let headers;\r\n try {\r\n headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n const errorParsed = parseResponse(request.responseText, headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n error = errorParsed.error;\r\n } catch (e) {\r\n if (request.response.length > 0) {\r\n error = { message: request.response };\r\n } else {\r\n error = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n const errorParameters = {\r\n status: request.status,\r\n statusText: request.statusText,\r\n headers: headers,\r\n };\r\n\r\n request = null as any;\r\n\r\n errorCallback(ErrorHelper.handleHttpError(error, errorParameters));\r\n\r\n break;\r\n }\r\n }\r\n };\r\n\r\n if (options.timeout) {\r\n request.timeout = options.timeout;\r\n }\r\n\r\n request.onerror = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Network Error\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n request.ontimeout = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"TimeoutError\",\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Request Timed Out\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //browser abort\r\n request.onabort = function () {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"Request aborted\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //manual abort/cancellation\r\n const abort = () => {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"The user aborted a request.\",\r\n headers: headers,\r\n })\r\n );\r\n\r\n request.abort();\r\n\r\n request = null as any;\r\n };\r\n\r\n if (signal) {\r\n signal.addEventListener(\"abort\", abort);\r\n }\r\n\r\n data ? request.send(data) : request.send();\r\n\r\n //called for testing\r\n if (XhrWrapper.afterSendEvent) XhrWrapper.afterSendEvent();\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n */\r\nexport class XhrWrapper {\r\n //for testing\r\n static afterSendEvent: () => void;\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance.\r\n *\r\n * @param {Config} config - configuration object.\r\n * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName - entity name\r\n * @returns {string | null} a collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n oDataContext?: string;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return `${global.window.location.origin}/_api/`;\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`;\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\",\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\",\r\n },\r\n };\r\n }\r\n}\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], - "mappings": ";qfAAO,SAASA,IAAwB,CACpC,OAA4B,OAAc,MAC9C,CAEO,SAASC,GAAsB,CAClC,OAA4BD,GAAU,EAAE,gBAAgB,IAAI,WAAW,CAAC,CAAC,CAC7E,CANA,IAAAE,EAAAC,EAAA,oBCEO,SAASC,EAAOC,EAAwB,CAE3C,MAAO,CAAC,CADM,IAAI,OAAOC,EAAM,GAAG,EAAE,KAAKD,CAAK,CAElD,CAEO,SAASE,EAAYF,EAA8B,CACtD,IAAMG,EAAQ,IAAI,OAAO,OAASF,EAAO,OAAQ,GAAG,EAAE,KAAKD,CAAK,EAChE,OAAOG,EAAQA,EAAM,CAAC,EAAI,IAC9B,CAEO,SAASC,EAAmBC,EAA4B,CAC3D,IAAMF,EAAQ,IAAI,OAAO,IAAMF,EAAO,QAAS,GAAG,EAAE,KAAKI,CAAG,EAC5D,OAAOF,EAAQA,EAAM,CAAC,EAAI,IAC9B,CAfA,IAAMF,EAANK,EAAAC,EAAA,kBAAMN,EAAO,oDCAb,IAgBMO,GAEOC,EAAAC,EAlBbC,EAAAC,EAAA,kBACAC,IACAC,IAcMN,GAAoB,QAEbC,EAAN,KAAc,CAOjB,OAAO,wBAAwBM,EAA0B,CACrD,GAAIA,EAAY,CACZ,IAAMC,EAAiB,OAAO,KAAKD,CAAU,EACzCE,EAAqB,GACrBC,EAAW,GAEf,QAASC,EAAI,EAAGA,GAAKH,EAAe,OAAQG,IAAK,CAC7C,IAAMC,EAAgBJ,EAAeG,EAAI,CAAC,EACtCE,EAAQN,EAAWK,CAAa,EAEhCC,GAAS,OAET,OAAOA,GAAU,UAAY,CAACA,EAAM,WAAW,wBAAwB,GAAK,CAACC,EAAOD,CAAK,EACzFA,EAAQ,IAAMA,EAAQ,IACf,OAAOA,GAAU,WACxBA,EAAQ,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C,EAE1D,OAAAG,EAAgB,WAAa,SAC7BA,EAAgB,OAAS,OACzBA,EAAgB,aAAe,eAC/BA,EAAgB,UAAY,KAAK,gBAEjC,KAAK,gBAAkB,KACvB,KAAK,SAAW,IAEC,MAAM,KAAK,aAAaA,CAAe,IACvC,IACrB,EAQA,wBAAsBL,GAAoC,IAAID,EAAeC,GAAU,KAAK,OAAO,EAEnG,aAAU,CAQN,kBAAoB4B,GAAsCzB,EAAc,kBAAkByB,CAAU,CACxG,EArnCI3B,EAAqB,MAAM,KAAK,QAASD,CAAM,CACnD,CAqnCJ", - "names": ["getCrypto", "generateRandomBytes", "init_Crypto", "__esmMin", "isUuid", "value", "uuid", "extractUuid", "match", "extractUuidFromUrl", "url", "init_Regex", "__esmMin", "downloadChunkSize", "_Utility", "Utility", "init_Utility", "__esmMin", "init_Crypto", "init_Regex", "parameters", "parameterNames", "functionParameters", "urlQuery", "i", "parameterName", "value", "isUuid", "extractUuid", "pageCookies", "currentPageNumber", "info", "page", "responseData", "result", "c", "generateRandomBytes", "clientUrl", "obj", "src", "excludeProps", "target", "prop", "request", "fileBuffer", "chunkSize", "offset", "count", "content", "binaryString", "bytes", "throwParameterError", "functionName", "parameterName", "type", "ErrorHelper", "init_ErrorHelper", "__esmMin", "init_Regex", "req", "parameter", "maxLength", "parsedError", "parameters", "error", "k", "match", "extractUuid", "alternateKeys", "i", "callbackParameter", "isBatch", "_a", "_b", "_DWA", "DWA", "init_dwa", "__esmMin", "annotation", "dateReviver", "key", "value", "a", "init_dateReviver", "__esmMin", "getFormattedKeyValue", "keyName", "value", "newKey", "format", "DWA", "parseData", "object", "parseParams", "Utility", "keys", "i", "currentKey", "j", "formattedKeyValue", "aliasKeys", "parseBatchHeaders", "text", "ctx", "headers", "parts", "line", "pos", "readLine", "responseHeaderRegex", "readTo", "str", "start", "end", "parseBatchResponse", "response", "requestNumber", "delimiter", "batchResponseParts", "result", "batchResponse", "batchToProcess", "httpStatusReg", "httpStatus", "httpStatusMessage", "responseData", "parsedResponse", "dateReviver", "responseHeaders", "ErrorHelper", "plainContentReg", "plainContent", "entityUrl", "guidResult", "extractUuidFromUrl", "base64ToString", "base64", "parseFileResponse", "data", "parseResult", "hasHeader", "getHeader", "name", "parseResponse", "batch", "init_parseResponse", "__esmMin", "init_dwa", "init_Utility", "init_ErrorHelper", "init_dateReviver", "init_Regex", "parseResponseHeaders", "headerStr", "headers", "headerPairs", "i", "ilen", "headerPair", "index", "init_parseResponseHeaders", "__esmMin", "xhr_exports", "__export", "XhrWrapper", "executeRequest", "options", "resolve", "reject", "_executeRequest", "successCallback", "errorCallback", "data", "additionalHeaders", "responseParams", "signal", "ErrorHelper", "request", "key", "abort", "responseHeaders", "parseResponseHeaders", "response", "parseResponse", "error", "headers", "errorParsed", "errorParameters", "init_xhr", "__esmMin", "init_ErrorHelper", "init_parseResponse", "init_parseResponseHeaders", "dynamics_web_api_exports", "__export", "DynamicsWebApi", "init_Utility", "init_ErrorHelper", "getApiUrl", "serverUrl", "apiConfig", "Utility", "mergeApiConfigs", "apiType", "internalConfig", "internalApiConfig", "ErrorHelper", "ConfigurationUtility", "config", "init_Utility", "init_ErrorHelper", "init_Utility", "init_Utility", "init_ErrorHelper", "_RequestUtility", "request", "config", "ErrorHelper", "join", "url", "joinSymbol", "queryArray", "navigationKey", "removeBracketsFromGuidReg", "filterResult", "m", "replacement", "Utility", "expandQueryArray", "i", "expand", "expandConverted", "headers", "prefer", "returnRepresentation", "includeAnnotations", "maxPageSize", "trackChanges", "continueOnError", "item", "requests", "batchRequest", "batchBoundary", "batchBody", "currentChangeSet", "contentId", "internalRequest", "inChangeSet", "contentIdValue", "key", "entityName", "collectionName", "data", "stringifiedData", "value", "regularExpression", "valueParts", "chr", "RequestUtility", "init_ErrorHelper", "executeRequest", "options", "_addResponseParams", "requestId", "responseParams", "_responseParseParams", "_addRequestToBatchCollection", "request", "_batchRequestCollection", "_clearRequestData", "_runRequest", "config", "result", "RequestClient", "error", "Utility", "processedData", "isBatchConverted", "batchRequest", "ErrorHelper", "batchResult", "RequestUtility", "token", "url", "executeRequest", "entityName", "i", "collectionName", "DynamicsWebApi", "config", "ConfigurationUtility", "request", "RequestClient", "ErrorHelper", "internalRequest", "Utility", "ifmatch", "error", "field", "fieldValue", "ifnonematch", "fileBytes", "chunkSize", "offset", "response", "bytesDownloaded", "data", "nextPageLink", "records", "pageLink", "result", "replacementString", "_executeFetchXmlAll", "primaryKey", "relatedKey", "isObject", "parameterName", "entityName"] + "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): any {\r\n\tconst headers = {};\r\n\tif (!headerStr) {\r\n\t\treturn headers;\r\n\t}\r\n\tconst headerPairs = headerStr.split(\"\\u000d\\u000a\");\r\n\tfor (let i = 0, ilen = headerPairs.length; i < ilen; i++) {\r\n\t\tconst headerPair = headerPairs[i];\r\n\t\tconst index = headerPair.indexOf(\"\\u003a\\u0020\");\r\n\t\tif (index > 0) {\r\n\t\t\theaders[headerPair.substring(0, index)] = headerPair.substring(index + 2);\r\n\t\t}\r\n\t}\r\n\treturn headers;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\nimport { parseResponseHeaders } from \"./helpers/parseResponseHeaders\";\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n if (signal?.aborted) {\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n message: \"The user aborted a request.\",\r\n })\r\n );\r\n\r\n return;\r\n }\r\n\r\n let request = new XMLHttpRequest();\r\n request.open(options.method, options.uri, options.isAsync || false);\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n request.setRequestHeader(key, additionalHeaders[key]);\r\n }\r\n\r\n request.onreadystatechange = function () {\r\n if (request.readyState === 4) {\r\n if (signal) signal.removeEventListener(\"abort\", abort);\r\n\r\n switch (request.status) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: // Success with partial content.\r\n case 304: {\r\n // Success with Not Modified\r\n const responseHeaders = parseResponseHeaders(request.getAllResponseHeaders());\r\n const responseData = parseResponse(request.responseText, responseHeaders, responseParams[options.requestId]);\r\n\r\n const response = {\r\n data: responseData,\r\n headers: responseHeaders,\r\n status: request.status,\r\n };\r\n\r\n request = null as any;\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n case 0:\r\n break; //response will be handled by onerror\r\n default:\r\n if (!request) break; //response was handled somewhere else\r\n\r\n // All other statuses are error cases.\r\n let error;\r\n let headers;\r\n try {\r\n headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n const errorParsed = parseResponse(request.responseText, headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n error = errorParsed.error;\r\n } catch (e) {\r\n if (request.response.length > 0) {\r\n error = { message: request.response };\r\n } else {\r\n error = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n const errorParameters = {\r\n status: request.status,\r\n statusText: request.statusText,\r\n headers: headers,\r\n };\r\n\r\n request = null as any;\r\n\r\n errorCallback(ErrorHelper.handleHttpError(error, errorParameters));\r\n\r\n break;\r\n }\r\n }\r\n };\r\n\r\n if (options.timeout) {\r\n request.timeout = options.timeout;\r\n }\r\n\r\n request.onerror = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Network Error\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n request.ontimeout = function () {\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"TimeoutError\",\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: request.responseText || \"Request Timed Out\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //browser abort\r\n request.onabort = function () {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"Request aborted\",\r\n headers: headers,\r\n })\r\n );\r\n request = null as any;\r\n };\r\n\r\n //manual abort/cancellation\r\n const abort = () => {\r\n if (!request) return;\r\n\r\n const headers = parseResponseHeaders(request.getAllResponseHeaders());\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError({\r\n name: \"AbortError\",\r\n code: 20,\r\n status: request.status,\r\n statusText: request.statusText,\r\n message: \"The user aborted a request.\",\r\n headers: headers,\r\n })\r\n );\r\n\r\n request.abort();\r\n\r\n request = null as any;\r\n };\r\n\r\n if (signal) {\r\n signal.addEventListener(\"abort\", abort);\r\n }\r\n\r\n data ? request.send(data) : request.send();\r\n\r\n //called for testing\r\n if (XhrWrapper.afterSendEvent) XhrWrapper.afterSendEvent();\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n */\r\nexport class XhrWrapper {\r\n //for testing\r\n static afterSendEvent: () => void;\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance.\r\n *\r\n * @param {Config} config configuration object.\r\n * @returns {DynamicsWebApi} A new instance of DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName entity name\r\n * @returns {string | null} collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n \"@odata.count\"?: number;\r\n oDataContext?: string;\r\n \"@odata.context\"?: number;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n \"@odata.deltaLink\"?: string;\r\n \"@odata.nextLink\"?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\"\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\"\r\n },\r\n };\r\n }\r\n}\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url!.toString() + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], + "mappings": ";qfAAO,SAASA,IAAwB,CACpC,OAA4B,OAAc,MAC9C,CAEO,SAASC,GAAsB,CAClC,OAA4BD,GAAU,EAAE,gBAAgB,IAAI,WAAW,CAAC,CAAC,CAC7E,CANA,IAAAE,EAAAC,EAAA,oBCEO,SAASC,EAAOC,EAAwB,CAE3C,MAAO,CAAC,CADM,IAAI,OAAOC,EAAM,GAAG,EAAE,KAAKD,CAAK,CAElD,CAEO,SAASE,EAAYF,EAA8B,CACtD,IAAMG,EAAQ,IAAI,OAAO,OAASF,EAAO,OAAQ,GAAG,EAAE,KAAKD,CAAK,EAChE,OAAOG,EAAQA,EAAM,CAAC,EAAI,IAC9B,CAEO,SAASC,EAAmBC,EAA4B,CAC3D,IAAMF,EAAQ,IAAI,OAAO,IAAMF,EAAO,QAAS,GAAG,EAAE,KAAKI,CAAG,EAC5D,OAAOF,EAAQA,EAAM,CAAC,EAAI,IAC9B,CAfA,IAAMF,EAANK,EAAAC,EAAA,kBAAMN,EAAO,oDCAb,IAgBMO,GAEOC,EAAAC,EAlBbC,EAAAC,EAAA,kBACAC,IACAC,IAcMN,GAAoB,QAEbC,EAAN,MAAMA,CAAQ,CAOjB,OAAO,wBAAwBM,EAA0B,CACrD,GAAIA,EAAY,CACZ,IAAMC,EAAiB,OAAO,KAAKD,CAAU,EACzCE,EAAqB,GACrBC,EAAW,GAEf,QAASC,EAAI,EAAGA,GAAKH,EAAe,OAAQG,IAAK,CAC7C,IAAMC,EAAgBJ,EAAeG,EAAI,CAAC,EACtCE,EAAQN,EAAWK,CAAa,EAEhCC,GAAS,OAET,OAAOA,GAAU,UAAY,CAACA,EAAM,WAAW,wBAAwB,GAAK,C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QAASD,CAAM,CACnD,CAqnCJ", + "names": ["getCrypto", "generateRandomBytes", "init_Crypto", "__esmMin", "isUuid", "value", "uuid", "extractUuid", "match", "extractUuidFromUrl", "url", "init_Regex", "__esmMin", "downloadChunkSize", "_Utility", "Utility", "init_Utility", "__esmMin", "init_Crypto", "init_Regex", "parameters", "parameterNames", "functionParameters", "urlQuery", "i", "parameterName", "value", "isUuid", "extractUuid", "pageCookies", "currentPageNumber", "info", "page", "responseData", "result", "c", "generateRandomBytes", "clientUrl", "obj", "src", "excludeProps", "target", "prop", "request", "fileBuffer", "chunkSize", "offset", "count", "content", "binaryString", "bytes", "throwParameterError", "functionName", "parameterName", "type", "ErrorHelper", "init_ErrorHelper", "__esmMin", "init_Regex", "_ErrorHelper", "req", "parameter", "maxLength", "parsedError", "parameters", "error", "k", "match", "extractUuid", "alternateKeys", "i", "callbackParameter", "isBatch", "_a", "_b", "_DWA", "DWA", "init_dwa", "__esmMin", "annotation", "dateReviver", "key", "value", "a", "init_dateReviver", "__esmMin", "getFormattedKeyValue", "keyName", "value", "newKey", "format", "DWA", "parseData", "object", "parseParams", "Utility", "keys", "i", "currentKey", "j", "formattedKeyValue", "aliasKeys", "parseBatchHeaders", "text", "ctx", "headers", "parts", "line", "pos", "readLine", "responseHeaderRegex", "readTo", "str", "start", "end", "parseBatchResponse", "response", "requestNumber", "delimiter", "batchResponseParts", "result", "batchResponse", "batchToProcess", "httpStatusReg", "httpStatus", "httpStatusMessage", "responseData", "parsedResponse", "dateReviver", "responseHeaders", "ErrorHelper", "plainContentReg", "plainContent", "entityUrl", "guidResult", "extractUuidFromUrl", "base64ToString", "base64", "parseFileResponse", "data", "parseResult", "hasHeader", "getHeader", "name", "parseResponse", "batch", "init_parseResponse", "__esmMin", "init_dwa", "init_Utility", "init_ErrorHelper", "init_dateReviver", "init_Regex", "parseResponseHeaders", "headerStr", "headers", "headerPairs", "i", "ilen", "headerPair", "index", "init_parseResponseHeaders", "__esmMin", "xhr_exports", "__export", "XhrWrapper", "executeRequest", "options", "resolve", "reject", "_executeRequest", "successCallback", "errorCallback", "data", "additionalHeaders", "responseParams", "signal", "ErrorHelper", "request", "key", "abort", "responseHeaders", "parseResponseHeaders", "response", "parseResponse", "error", "headers", "errorParsed", "errorParameters", "init_xhr", "__esmMin", "init_ErrorHelper", "init_parseResponse", "init_parseResponseHeaders", "dynamics_web_api_exports", "__export", "DynamicsWebApi", "init_Utility", "init_ErrorHelper", "getApiUrl", "serverUrl", "apiConfig", "Utility", "mergeApiConfigs", "apiType", "internalConfig", "internalApiConfig", "ErrorHelper", "ConfigurationUtility", "config", "init_Utility", "init_ErrorHelper", "init_Utility", "init_Utility", "init_ErrorHelper", "_RequestUtility", "request", "config", "ErrorHelper", "join", "url", "joinSymbol", "queryArray", "navigationKey", "removeBracketsFromGuidReg", "filterResult", "m", "replacement", "Utility", "expandQueryArray", "i", "expand", "expandConverted", "headers", "prefer", "returnRepresentation", "includeAnnotations", "maxPageSize", "trackChanges", "continueOnError", "item", "requests", "batchRequest", "batchBoundary", "batchBody", "currentChangeSet", "contentId", "internalRequest", "inChangeSet", "contentIdValue", "key", "entityName", "collectionName", "data", "stringifiedData", "value", "regularExpression", "valueParts", "chr", "RequestUtility", "init_ErrorHelper", "executeRequest", "options", "_addResponseParams", "requestId", "responseParams", "_responseParseParams", "_addRequestToBatchCollection", "request", "_batchRequestCollection", "_clearRequestData", "_runRequest", "config", "result", "RequestClient", "error", "_RequestClient", "Utility", "processedData", "isBatchConverted", "batchRequest", "ErrorHelper", "batchResult", "RequestUtility", "token", "url", "executeRequest", "entityName", "i", "collectionName", "DynamicsWebApi", "_DynamicsWebApi", "config", "ConfigurationUtility", "request", "RequestClient", "ErrorHelper", "internalRequest", "Utility", "ifmatch", "error", "field", "fieldValue", "ifnonematch", "fileBytes", "chunkSize", "offset", "response", "bytesDownloaded", "data", "nextPageLink", "records", "pageLink", "result", "replacementString", "_executeFetchXmlAll", "primaryKey", "relatedKey", "isObject", "parameterName", "entityName"] } diff --git a/dist/esm/dynamics-web-api.mjs b/dist/esm/dynamics-web-api.mjs index e2df8ee..18c2c41 100644 --- a/dist/esm/dynamics-web-api.mjs +++ b/dist/esm/dynamics-web-api.mjs @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.1.1 (c) 2023 Aleksandr Rogov */ +/*! dynamics-web-api v2.1.2 (c) 2023 Aleksandr Rogov */ var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; @@ -57,8 +57,8 @@ function extractUuid(value) { const match = new RegExp("^{?(" + uuid + ")}?$", "i").exec(value); return match ? match[1] : null; } -function extractUuidFromUrl(url2) { - const match = new RegExp("(" + uuid + ")\\)$", "i").exec(url2); +function extractUuidFromUrl(url) { + const match = new RegExp("(" + uuid + ")\\)$", "i").exec(url); return match ? match[1] : null; } var uuid; @@ -77,7 +77,7 @@ var init_Utility = __esm({ init_Crypto(); init_Regex(); downloadChunkSize = 4194304; - _Utility = class { + _Utility = class _Utility { /** * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]' * @@ -246,9 +246,9 @@ var init_Utility = __esm({ return bytes; } }; - Utility = _Utility; // static isNodeEnv = isNodeEnv; - Utility.downloadChunkSize = downloadChunkSize; + _Utility.downloadChunkSize = downloadChunkSize; + Utility = _Utility; } }); @@ -263,7 +263,7 @@ var init_ErrorHelper = __esm({ "src/helpers/ErrorHelper.ts"() { "use strict"; init_Regex(); - ErrorHelper = class { + ErrorHelper = class _ErrorHelper { static handleErrorResponse(req) { throw new Error(`Error: ${req.status}: ${req.message}`); } @@ -343,7 +343,7 @@ var init_ErrorHelper = __esm({ } static keyParameterCheck(parameter, functionName, parameterName) { try { - ErrorHelper.stringParameterCheck(parameter, functionName, parameterName); + _ErrorHelper.stringParameterCheck(parameter, functionName, parameterName); const match = extractUuid(parameter); if (match) return match; @@ -386,15 +386,15 @@ var _a, _b, _DWA, DWA; var init_dwa = __esm({ "src/dwa.ts"() { "use strict"; - _DWA = class { + _DWA = class _DWA { }; - DWA = _DWA; - DWA.Prefer = (_b = class { + _DWA.Prefer = (_b = class { static get(annotation) { return `${_DWA.Prefer.IncludeAnnotations}="${annotation}"`; } }, _b.ReturnRepresentation = "return=representation", _b.Annotations = (_a = class { }, _a.AssociatedNavigationProperty = "Microsoft.Dynamics.CRM.associatednavigationproperty", _a.LookupLogicalName = "Microsoft.Dynamics.CRM.lookuplogicalname", _a.All = "*", _a.FormattedValue = "OData.Community.Display.V1.FormattedValue", _a.FetchXmlPagingCookie = "Microsoft.Dynamics.CRM.fetchxmlpagingcookie", _a), _b.IncludeAnnotations = "odata.include-annotations", _b); + DWA = _DWA; } }); @@ -671,7 +671,6 @@ __export(http_exports, { }); import * as http from "http"; import * as https from "https"; -import * as url from "url"; import HttpProxyAgent from "http-proxy-agent"; import HttpsProxyAgent from "https-proxy-agent"; function executeRequest(options) { @@ -694,13 +693,13 @@ function _executeRequest(options, successCallback, errorCallback) { for (let key in additionalHeaders) { headers[key] = additionalHeaders[key]; } - const parsedUrl = url.parse(options.uri); + const parsedUrl = new URL(options.uri); const protocol = ((_a2 = parsedUrl.protocol) == null ? void 0 : _a2.slice(0, -1)) || "https"; const protocolInterface = protocol === "http" ? http : https; const internalOptions = { hostname: parsedUrl.hostname, port: parsedUrl.port, - path: parsedUrl.path, + path: parsedUrl.pathname + parsedUrl.search, method: options.method, timeout: options.timeout || 0, headers, @@ -823,11 +822,11 @@ init_Utility(); init_ErrorHelper(); var getApiUrl = (serverUrl, apiConfig) => { if (Utility.isRunningWithinPortals()) { - return `${global.window.location.origin}/_api/`; + return new URL("_api", global.window.location.origin).toString() + "/"; } else { if (!serverUrl) serverUrl = Utility.getClientUrl(); - return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`; + return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + "/"; } }; var mergeApiConfigs = (apiConfig, apiType, internalConfig) => { @@ -931,7 +930,7 @@ init_Utility(); // src/utils/Request.ts init_Utility(); init_ErrorHelper(); -var _RequestUtility = class { +var _RequestUtility = class _RequestUtility { /** * Converts a request object to URL link * @@ -975,7 +974,6 @@ var _RequestUtility = class { } else { ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, "request.url"); request.path = request.url.replace(config.dataApi.url, ""); - request.path = _RequestUtility.composeUrl(request, config, request.path); } if (request.hasOwnProperty("async") && request.async != null) { ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, "request.async"); @@ -995,20 +993,20 @@ var _RequestUtility = class { * @param {Object} [config] - DynamicsWebApi config * @returns {ConvertedRequestOptions} Additional options in request */ - static composeUrl(request, config, url2 = "", joinSymbol = "&") { + static composeUrl(request, config, url = "", joinSymbol = "&") { var _a2, _b2, _c; const queryArray = []; if (request) { if (request.navigationProperty) { ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, "request.navigationProperty"); - url2 += "/" + request.navigationProperty; + url += "/" + request.navigationProperty; if (request.navigationPropertyKey) { let navigationKey = ErrorHelper.keyParameterCheck( request.navigationPropertyKey, `DynamicsWebApi.${request.functionName}`, "request.navigationPropertyKey" ); - url2 += "(" + navigationKey + ")"; + url += "(" + navigationKey + ")"; } if (request.navigationProperty === "Attributes") { if (request.metadataAttributeType) { @@ -1017,18 +1015,18 @@ var _RequestUtility = class { `DynamicsWebApi.${request.functionName}`, "request.metadataAttributeType" ); - url2 += "/" + request.metadataAttributeType; + url += "/" + request.metadataAttributeType; } } } if ((_a2 = request.select) == null ? void 0 : _a2.length) { ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, "request.select"); if (request.functionName == "retrieve" && request.select.length == 1 && request.select[0].endsWith("/$ref")) { - url2 += "/" + request.select[0]; + url += "/" + request.select[0]; } else { if (request.select[0].startsWith("/") && request.functionName == "retrieve") { if (request.navigationProperty == null) { - url2 += request.select.shift(); + url += request.select.shift(); } else { request.select.shift(); } @@ -1054,7 +1052,7 @@ var _RequestUtility = class { } if (request.fieldName) { ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, "request.fieldName"); - url2 += "/" + request.fieldName; + url += "/" + request.fieldName; } if (request.savedQuery) { queryArray.push( @@ -1135,7 +1133,7 @@ var _RequestUtility = class { } } } - return !queryArray.length ? url2 : url2 + "?" + queryArray.join(joinSymbol); + return !queryArray.length ? url : url + "?" + queryArray.join(joinSymbol); } static composeHeaders(request, config) { const headers = { ...config.headers, ...request.userHeaders }; @@ -1408,8 +1406,8 @@ ${_RequestUtility.processData(internalRequest.data, config)}`); return headers; } }; +_RequestUtility.entityNames = null; var RequestUtility = _RequestUtility; -RequestUtility.entityNames = null; // src/client/RequestClient.ts init_ErrorHelper(); @@ -1451,7 +1449,7 @@ var _runRequest = async (request, config) => { }; var _batchRequestCollection = {}; var _responseParseParams = {}; -var RequestClient = class { +var RequestClient = class _RequestClient { /** * Sends a request to given URL with given parameters * @@ -1497,10 +1495,10 @@ var RequestClient = class { if (Utility.isRunningWithinPortals()) { request.headers["__RequestVerificationToken"] = await global.window.shell.getTokenDeferred(); } - const url2 = request.apiConfig ? request.apiConfig.url : config.dataApi.url; + const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url; return await executeRequest2({ method: request.method, - uri: url2 + request.path, + uri: url.toString() + request.path, data: processedData, additionalHeaders: request.headers, responseParams: _responseParseParams, @@ -1546,7 +1544,7 @@ var RequestClient = class { return exceptions.indexOf(entityName) > -1; } static async _checkCollectionName(entityName, config) { - if (!entityName || RequestClient._isEntityNameException(entityName)) { + if (!entityName || _RequestClient._isEntityNameException(entityName)) { return entityName; } entityName = entityName.toLowerCase(); @@ -1554,7 +1552,7 @@ var RequestClient = class { return entityName; } try { - return await RequestClient._getCollectionNames(entityName, config); + return await _RequestClient._getCollectionNames(entityName, config); } catch (error) { throw new Error("Unable to fetch Collection Names. Error: " + error.message); } @@ -1564,7 +1562,7 @@ var RequestClient = class { request.userHeaders = request.headers; delete request.headers; if (!request.isBatch) { - const collectionName = await RequestClient._checkCollectionName(request.collection, config); + const collectionName = await _RequestClient._checkCollectionName(request.collection, config); request.collection = collectionName; RequestUtility.compose(request, config); request.responseParameters.convertedToBatch = false; @@ -1593,7 +1591,7 @@ var RequestClient = class { }; // src/dynamics-web-api.ts -var DynamicsWebApi = class { +var DynamicsWebApi = class _DynamicsWebApi { /** * Initializes a new instance of DynamicsWebApi * @param config - Configuration object @@ -2494,19 +2492,19 @@ var DynamicsWebApi = class { return response == null ? void 0 : response.data; }; /** - * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance. + * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance. * - * @param {Config} config - configuration object. - * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi + * @param {Config} config configuration object. + * @returns {DynamicsWebApi} A new instance of DynamicsWebApi */ - this.initializeInstance = (config) => new DynamicsWebApi(config || this._config); + this.initializeInstance = (config) => new _DynamicsWebApi(config || this._config); this.Utility = { /** * Searches for a collection name by provided entity name in a cached entity metadata. * The returned collection name can be null. * - * @param {string} entityName - entity name - * @returns {string | null} a collection name + * @param {string} entityName entity name + * @returns {string | null} collection name */ getCollectionName: (entityName) => RequestClient.getCollectionName(entityName) }; diff --git a/dist/esm/dynamics-web-api.mjs.map b/dist/esm/dynamics-web-api.mjs.map index e70d233..1c75916 100644 --- a/dist/esm/dynamics-web-api.mjs.map +++ b/dist/esm/dynamics-web-api.mjs.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/helpers/crypto/node.ts", "../../src/helpers/Crypto.ts", "../../src/helpers/Regex.ts", "../../src/utils/Utility.ts", "../../src/helpers/ErrorHelper.ts", "../../src/dwa.ts", "../../src/client/helpers/dateReviver.ts", "../../src/client/helpers/parseResponse.ts", "../../src/client/http.ts", "../../src/utils/Config.ts", "../../src/dynamics-web-api.ts", "../../src/client/RequestClient.ts", "../../src/utils/Request.ts", "../../src/client/helpers/executeRequest.ts"], - "sourcesContent": ["//had to move getCrypto for node to a different local module,\r\n//because esbuild does not support external require in esm format\r\nimport nCrypto from \"node:crypto\";\r\n\r\nexport function getCrypto () {\r\n return nCrypto;\r\n}", "export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFimport * as http from \"http\";\r\nimport * as https from \"https\";\r\nimport * as url from \"url\";\r\nimport HttpProxyAgent from \"http-proxy-agent\";\r\nimport HttpsProxyAgent from \"https-proxy-agent\";\r\nimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\n\r\nconst agents: { [key: string]: http.Agent } = {};\r\n\r\nconst getAgent = (options: Core.RequestOptions, protocol: string): http.Agent => {\r\n const isHttp = protocol === \"http\";\r\n const proxy = options.proxy;\r\n const agentName = proxy ? proxy.url : protocol;\r\n\r\n if (!agents[agentName]) {\r\n if (proxy) {\r\n const parsedProxyUrl = new URL(proxy.url);\r\n const proxyAgent = isHttp ? HttpProxyAgent.HttpProxyAgent : HttpsProxyAgent.HttpsProxyAgent;\r\n\r\n const proxyOptions: HttpProxyAgent.HttpProxyAgentOptions | HttpsProxyAgent.HttpsProxyAgentOptions = {\r\n host: parsedProxyUrl.hostname,\r\n port: parsedProxyUrl.port,\r\n protocol: parsedProxyUrl.protocol,\r\n };\r\n\r\n if (proxy.auth) proxyOptions.auth = proxy.auth.username + \":\" + proxy.auth.password;\r\n else if (parsedProxyUrl.username && parsedProxyUrl.password) proxyOptions.auth = `${parsedProxyUrl.username}:${parsedProxyUrl.password}`;\r\n\r\n agents[agentName] = new proxyAgent(proxyOptions);\r\n } else {\r\n const protocolInterface = isHttp ? http : https;\r\n\r\n agents[agentName] = new protocolInterface.Agent({\r\n keepAlive: true,\r\n maxSockets: Infinity,\r\n });\r\n }\r\n }\r\n\r\n return agents[agentName];\r\n};\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n *\r\n */\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n const headers: http.OutgoingHttpHeaders = {};\r\n\r\n if (data) {\r\n headers[\"Content-Type\"] = additionalHeaders[\"Content-Type\"];\r\n headers[\"Content-Length\"] = data.length;\r\n\r\n delete additionalHeaders[\"Content-Type\"];\r\n }\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n headers[key] = additionalHeaders[key];\r\n }\r\n const parsedUrl = url.parse(options.uri);\r\n const protocol = parsedUrl.protocol?.slice(0, -1) || \"https\";\r\n const protocolInterface = protocol === \"http\" ? http : https;\r\n\r\n const internalOptions: http.RequestOptions = {\r\n hostname: parsedUrl.hostname,\r\n port: parsedUrl.port,\r\n path: parsedUrl.path,\r\n method: options.method,\r\n timeout: options.timeout || 0,\r\n headers: headers,\r\n signal: signal,\r\n };\r\n\r\n //support environment variables\r\n if (!options.proxy && process.env[`${protocol}_proxy`]) {\r\n options.proxy = {\r\n url: process.env[`${protocol}_proxy`]!,\r\n };\r\n }\r\n\r\n internalOptions.agent = getAgent(options, protocol);\r\n\r\n if (options.proxy) {\r\n const hostHeader =new URL(options.proxy.url).host;\r\n if (hostHeader) headers.host = hostHeader;\r\n }\r\n\r\n const request = protocolInterface.request(internalOptions, function (res) {\r\n let rawData = \"\";\r\n res.setEncoding(\"utf8\");\r\n res.on(\"data\", function (chunk) {\r\n rawData += chunk;\r\n });\r\n res.on(\"end\", function () {\r\n switch (res.statusCode) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: //Success with partial content\r\n case 304: {\r\n // Success with Not Modified\r\n let responseData = parseResponse(rawData, res.headers, responseParams[options.requestId]);\r\n\r\n let response = {\r\n data: responseData,\r\n headers: res.headers as any,\r\n status: res.statusCode,\r\n };\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n default:\r\n // All other statuses are error cases.\r\n let crmError;\r\n try {\r\n var errorParsed = parseResponse(rawData, res.headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n crmError = errorParsed.hasOwnProperty(\"error\") && errorParsed.error ? errorParsed.error : { message: errorParsed.Message };\r\n } catch (e) {\r\n if (rawData.length > 0) {\r\n crmError = { message: rawData };\r\n } else {\r\n crmError = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError(crmError, {\r\n status: res.statusCode,\r\n statusText: \"\",\r\n statusMessage: res.statusMessage,\r\n headers: res.headers,\r\n })\r\n );\r\n break;\r\n }\r\n });\r\n });\r\n\r\n if (internalOptions.timeout) {\r\n request.setTimeout(internalOptions.timeout, function () {\r\n request.destroy();\r\n });\r\n }\r\n\r\n request.on(\"error\", function (error) {\r\n errorCallback(error);\r\n });\r\n\r\n if (data) {\r\n request.write(data);\r\n }\r\n\r\n request.end();\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return `${global.window.location.origin}/_api/`;\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`;\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\",\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\",\r\n },\r\n };\r\n }\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance.\r\n *\r\n * @param {Config} config - configuration object.\r\n * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName - entity name\r\n * @returns {string | null} a collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n oDataContext?: string;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAEA,OAAO,aAAa;AAEb,SAAS,YAAa;AACzB,SAAO;AACX;AANA;AAAA;AAAA;AAAA;AAAA;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A;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,cAAc,kBAAkB,UAAU;AAAA,IACxG;AArnCI,yBAAqB,MAAM,KAAK,SAAS,MAAM;AAAA,EACnD;AAqnCJ;", - "names": ["getCrypto", "url", "_a", "url", "_a", "_b", "executeRequest", "_a", "url", "executeRequest", "_a", "request"] + "sourcesContent": ["//had to move getCrypto for node to a different local module,\r\n//because esbuild does not support external require in esm format\r\nimport nCrypto from \"node:crypto\";\r\n\r\nexport function getCrypto () {\r\n return nCrypto;\r\n}", "export function getCrypto(): T {\r\n return global.DWA_BROWSER ? global.window.crypto : require(\"./crypto/node\").getCrypto();\r\n}\r\n\r\nexport function generateRandomBytes() {\r\n return global.DWA_BROWSER ? getCrypto().getRandomValues(new Uint8Array(1)) : getCrypto().randomBytes(1);\r\n}\r\n", "const uuid = \"[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}\";\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = new RegExp(uuid, \"i\").exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = new RegExp(\"^{?(\" + uuid + \")}?$\", \"i\").exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url: string): string | null {\r\n const match = new RegExp(\"(\" + uuid + \")\\\\)$\", \"i\").exec(url);\r\n return match ? match[1] : null;\r\n}\r\n", "\uFEFFimport { Core } from \"../types\";\r\nimport { generateRandomBytes } from \"../helpers/Crypto\";\r\nimport { isUuid, extractUuid } from \"../helpers/Regex\";\r\n\r\ndeclare var GetGlobalContext: any;\r\ndeclare var Xrm: any;\r\n\r\n// function isNodeEnv(): boolean {\r\n// // tslint:disable:strict-type-predicates\r\n// return Object.prototype.toString.call(typeof process !== \"undefined\" ? process : 0) === \"[object process]\";\r\n// }\r\n\r\n// function getGlobalObject(): T {\r\n// return (isNodeEnv() ? global : typeof window !== \"undefined\" ? window : typeof self !== \"undefined\" ? self : {}) as T;\r\n// }\r\n\r\nconst downloadChunkSize = 4194304;\r\n\r\nexport class Utility {\r\n /**\r\n * Builds parametes for a funciton. Returns '()' (if no parameters) or '([params])?[query]'\r\n *\r\n * @param {Object} [parameters] - Function's input parameters. Example: { param1: \"test\", param2: 3 }.\r\n * @returns {string}\r\n */\r\n static buildFunctionParameters(parameters?: any): string {\r\n if (parameters) {\r\n const parameterNames = Object.keys(parameters);\r\n let functionParameters = \"\";\r\n let urlQuery = \"\";\r\n\r\n for (var i = 1; i <= parameterNames.length; i++) {\r\n const parameterName = parameterNames[i - 1];\r\n let value = parameters[parameterName];\r\n\r\n if (value == null) continue;\r\n\r\n if (typeof value === \"string\" && !value.startsWith(\"Microsoft.Dynamics.CRM\") && !isUuid(value)) {\r\n value = \"'\" + value + \"'\";\r\n } else if (typeof value === \"object\") {\r\n value = JSON.stringify(value);\r\n }\r\n\r\n if (i > 1) {\r\n functionParameters += \",\";\r\n urlQuery += \"&\";\r\n }\r\n\r\n functionParameters += parameterName + \"=@p\" + i;\r\n urlQuery += \"@p\" + i + \"=\" + (extractUuid(value) || value);\r\n }\r\n\r\n if (urlQuery) urlQuery = \"?\" + urlQuery;\r\n\r\n return \"(\" + functionParameters + \")\" + urlQuery;\r\n } else {\r\n return \"()\";\r\n }\r\n }\r\n\r\n /**\r\n * Parses a paging cookie returned in response\r\n *\r\n * @param {string} pageCookies - Page cookies returned in @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.\r\n * @param {number} currentPageNumber - A current page number. Fix empty paging-cookie for complex fetch xmls.\r\n * @returns {{cookie: \"\", number: 0, next: 1}}\r\n */\r\n static getFetchXmlPagingCookie(pageCookies: string = \"\", currentPageNumber: number = 1): Core.FetchXmlCookie {\r\n //get the page cokies\r\n pageCookies = decodeURIComponent(decodeURIComponent(pageCookies));\r\n\r\n const info = /pagingcookie=\"()/.exec(pageCookies);\r\n\r\n if (info != null) {\r\n let page = parseInt(info[2]);\r\n return {\r\n cookie: info[1]\r\n .replace(//g, \">\")\r\n .replace(/\\\"/g, \"'\")\r\n .replace(/\\'/g, \"&\" + \"quot;\"),\r\n page: page,\r\n nextPage: page + 1,\r\n };\r\n } else {\r\n //http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: \"\",\r\n page: currentPageNumber,\r\n nextPage: currentPageNumber + 1,\r\n };\r\n }\r\n }\r\n\r\n // static isNodeEnv = isNodeEnv;\r\n\r\n static downloadChunkSize = downloadChunkSize;\r\n\r\n /**\r\n * Converts a response to a reference object\r\n *\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\n static convertToReferenceObject(responseData: any): Core.ReferenceObject {\r\n const result = /\\/(\\w+)\\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n }\r\n\r\n /**\r\n * Checks whether the value is JS Null.\r\n * @param {Object} value\r\n * @returns {boolean}\r\n */\r\n static isNull(value: any): boolean {\r\n return typeof value === \"undefined\" || value == null;\r\n }\r\n\r\n /** Generates UUID */\r\n static generateUUID(): string {\r\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (generateRandomBytes()[0] & (15 >> (c / 4)))).toString(16));\r\n }\r\n\r\n static getXrmContext(): any {\r\n if (typeof GetGlobalContext !== \"undefined\") {\r\n return GetGlobalContext();\r\n } else {\r\n if (typeof Xrm !== \"undefined\") {\r\n //d365 v.9.0\r\n if (!Utility.isNull(Xrm.Utility) && !Utility.isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!Utility.isNull(Xrm.Page) && !Utility.isNull(Xrm.Page.context)) {\r\n return Xrm.Page.context;\r\n }\r\n }\r\n }\r\n\r\n throw new Error(\r\n \"Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.\"\r\n );\r\n }\r\n\r\n // static getXrmUtility(): any {\r\n // return typeof Xrm !== \"undefined\" ? Xrm.Utility : null;\r\n // }\r\n\r\n static getClientUrl(): string {\r\n const context = Utility.getXrmContext();\r\n\r\n let clientUrl = context.getClientUrl();\r\n\r\n if (clientUrl.match(/\\/$/)) {\r\n clientUrl = clientUrl.substring(0, clientUrl.length - 1);\r\n }\r\n return clientUrl;\r\n }\r\n\r\n /**\r\n * Checks whether the app is currently running in a Dynamics Portals Environment.\r\n *\r\n * In that case we switch to the Web API for Dynamics Portals.\r\n * @returns {boolean}\r\n */\r\n static isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n }\r\n\r\n static isObject(obj: any): boolean {\r\n return typeof obj === \"object\" && !!obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== \"[object Date]\";\r\n }\r\n\r\n static copyObject(src: any, excludeProps?: string[]): T {\r\n let target = {};\r\n for (let prop in src) {\r\n if (src.hasOwnProperty(prop) && !excludeProps?.includes(prop)) {\r\n // if the value is a nested object, recursively copy all its properties\r\n if (Utility.isObject(src[prop])) {\r\n target[prop] = Utility.copyObject(src[prop]);\r\n } else if (Array.isArray(src[prop])) {\r\n target[prop] = src[prop].slice();\r\n } else {\r\n target[prop] = src[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n }\r\n\r\n static copyRequest(src: any, excludeProps: string[] = []): Core.InternalRequest {\r\n //todo: do we need to include \"data\" in here?\r\n if (!excludeProps.includes(\"signal\")) excludeProps.push(\"signal\");\r\n\r\n const result = Utility.copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n }\r\n\r\n static setFileChunk(request: Core.InternalRequest, fileBuffer: Uint8Array | Buffer, chunkSize: number, offset: number): void {\r\n offset = offset || 0;\r\n\r\n const count = offset + chunkSize > fileBuffer.length ? fileBuffer.length % chunkSize : chunkSize;\r\n\r\n let content: any;\r\n\r\n if (global.DWA_BROWSER) {\r\n content = new Uint8Array(count);\r\n for (let i = 0; i < count; i++) {\r\n content[i] = fileBuffer[offset + i];\r\n }\r\n } else {\r\n content = fileBuffer.slice(offset, offset + count);\r\n }\r\n\r\n request.data = content;\r\n request.contentRange = \"bytes \" + offset + \"-\" + (offset + count - 1) + \"/\" + fileBuffer.length;\r\n }\r\n\r\n static convertToFileBuffer(binaryString: string): Uint8Array | Buffer {\r\n if (!global.DWA_BROWSER) return Buffer.from(binaryString, \"binary\");\r\n\r\n const bytes = new Uint8Array(binaryString.length);\r\n for (var i = 0; i < binaryString.length; i++) {\r\n bytes[i] = binaryString.charCodeAt(i);\r\n }\r\n return bytes;\r\n }\r\n}\r\n", "\uFEFFimport { AccessToken } from \"../dynamics-web-api\";\r\nimport { extractUuid } from \"./Regex\";\r\n\r\nexport interface DynamicsWebApiError extends Error {\r\n status: number;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): void {\r\n throw new Error(\r\n type ? `${functionName} requires a ${parameterName} parameter to be of type ${type}.` : `${functionName} requires a ${parameterName} parameter.`\r\n );\r\n}\r\n\r\nexport class ErrorHelper {\r\n static handleErrorResponse(req): void {\r\n throw new Error(`Error: ${req.status}: ${req.message}`);\r\n }\r\n\r\n static parameterCheck(parameter: any, functionName: string, parameterName: string, type?: string): void {\r\n if (typeof parameter === \"undefined\" || parameter === null || parameter === \"\") {\r\n throwParameterError(functionName, parameterName, type);\r\n }\r\n }\r\n\r\n static stringParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String\");\r\n }\r\n }\r\n\r\n static maxLengthStringParameterCheck(parameter: string | null, functionName: string, parameterName: string, maxLength: number): void {\r\n if (!parameter) return;\r\n\r\n if (parameter.length > maxLength) {\r\n throw new Error(`${parameterName} has a ${maxLength} character limit.`);\r\n }\r\n }\r\n\r\n static arrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array) {\r\n throwParameterError(functionName, parameterName, \"Array\");\r\n }\r\n }\r\n\r\n static stringOrArrayParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (parameter.constructor !== Array && typeof parameter !== \"string\") {\r\n throwParameterError(functionName, parameterName, \"String or Array\");\r\n }\r\n }\r\n\r\n static numberParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"number\") {\r\n if (typeof parameter === \"string\" && parameter) {\r\n if (!isNaN(parseInt(parameter))) {\r\n return;\r\n }\r\n }\r\n throwParameterError(functionName, parameterName, \"Number\");\r\n }\r\n }\r\n\r\n static batchIsEmpty(): Error[] {\r\n return [\r\n new Error(\r\n \"Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.\"\r\n ),\r\n ];\r\n }\r\n\r\n static handleHttpError(parsedError: any, parameters?: any): DynamicsWebApiError {\r\n const error = new Error();\r\n\r\n Object.keys(parsedError).forEach((k) => {\r\n error[k] = parsedError[k];\r\n });\r\n\r\n if (parameters) {\r\n Object.keys(parameters).forEach((k) => {\r\n error[k] = parameters[k];\r\n });\r\n }\r\n\r\n return error;\r\n }\r\n\r\n static boolParameterCheck(parameter: any, functionName: string, parameterName: string): void {\r\n if (typeof parameter != \"boolean\") {\r\n throwParameterError(functionName, parameterName, \"Boolean\");\r\n }\r\n }\r\n\r\n /**\r\n * Private function used to check whether required parameter is a valid GUID\r\n * @param parameter The GUID parameter to check\r\n * @param functionName\r\n * @param parameterName\r\n * @returns\r\n */\r\n static guidParameterCheck(parameter: any, functionName: string, parameterName: string): string {\r\n const match = extractUuid(parameter);\r\n if (!match) throwParameterError(functionName, parameterName, \"GUID String\");\r\n\r\n return match!;\r\n }\r\n\r\n static keyParameterCheck(parameter: any, functionName: string, parameterName: string): string | undefined {\r\n try {\r\n ErrorHelper.stringParameterCheck(parameter, functionName, parameterName);\r\n\r\n //check if the param is a guid\r\n const match = extractUuid(parameter);\r\n if (match) return match;\r\n\r\n //check the alternate key\r\n const alternateKeys = parameter.split(\",\");\r\n\r\n if (alternateKeys.length) {\r\n for (let i = 0; i < alternateKeys.length; i++) {\r\n alternateKeys[i] = alternateKeys[i].trim().replace(/\"/g, \"'\");\r\n /^[\\w\\d\\_]+\\=(.+)$/i.exec(alternateKeys[i])![0];\r\n }\r\n }\r\n\r\n return alternateKeys.join(\",\");\r\n } catch (error) {\r\n throwParameterError(functionName, parameterName, \"String representing GUID or Alternate Key\");\r\n }\r\n }\r\n\r\n static callbackParameterCheck(callbackParameter: () => Promise, functionName: string, parameterName: string): void {\r\n if (typeof callbackParameter != \"function\") {\r\n throwParameterError(functionName, parameterName, \"Function\");\r\n }\r\n }\r\n\r\n static throwBatchIncompatible(functionName: string, isBatch: boolean): void {\r\n if (isBatch) {\r\n isBatch = false;\r\n throw new Error(functionName + \" cannot be used in a BATCH request.\");\r\n }\r\n }\r\n\r\n static throwBatchNotStarted(isBatch: boolean): void {\r\n if (!isBatch) {\r\n throw new Error(\r\n \"Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.\"\r\n );\r\n }\r\n }\r\n}\r\n", "class DWA {\r\n\tstatic Prefer = class {\r\n\t\tstatic ReturnRepresentation: string = \"return=representation\";\r\n\t\tstatic Annotations = class {\r\n\t\t\tstatic AssociatedNavigationProperty: string = \"Microsoft.Dynamics.CRM.associatednavigationproperty\";\r\n\t\t\tstatic LookupLogicalName: string = \"Microsoft.Dynamics.CRM.lookuplogicalname\";\r\n\t\t\tstatic All: string = \"*\";\r\n\t\t\tstatic FormattedValue: string = \"OData.Community.Display.V1.FormattedValue\";\r\n\t\t\tstatic FetchXmlPagingCookie: string = \"Microsoft.Dynamics.CRM.fetchxmlpagingcookie\";\r\n\t\t};\r\n\t\tstatic IncludeAnnotations: string = \"odata.include-annotations\";\r\n\t\tstatic get(annotation: string) {\r\n\t\t\treturn `${DWA.Prefer.IncludeAnnotations}=\"${annotation}\"`;\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport { DWA };\r\n", "\uFEFFexport function dateReviver(key: string, value: any): Date {\r\n\tif (typeof value === \"string\") {\r\n\t\tconst a = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:Z|[-+]\\d{2}:\\d{2})$/.exec(value);\r\n\t\tif (a) {\r\n\t\t\treturn new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n\t\t}\r\n\t}\r\n\treturn value;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { Utility } from \"../../utils/Utility\";\r\nimport { ErrorHelper, DynamicsWebApiError } from \"../../helpers/ErrorHelper\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport { Core } from \"../../types\";\r\nimport { extractUuidFromUrl } from \"../../helpers/Regex\";\r\n\r\nfunction getFormattedKeyValue(keyName: string, value: any): any[] {\r\n let newKey: string | null = null;\r\n if (keyName.indexOf(\"@\") !== -1) {\r\n const format = keyName.split(\"@\");\r\n switch (format[1]) {\r\n case \"odata.context\":\r\n newKey = \"oDataContext\";\r\n break;\r\n case \"odata.count\":\r\n newKey = \"oDataCount\";\r\n value = value != null ? parseInt(value) : 0;\r\n break;\r\n case \"odata.nextLink\":\r\n newKey = \"oDataNextLink\";\r\n break;\r\n case \"odata.deltaLink\":\r\n newKey = \"oDataDeltaLink\";\r\n break;\r\n case DWA.Prefer.Annotations.FormattedValue:\r\n newKey = format[0] + \"_Formatted\";\r\n break;\r\n case DWA.Prefer.Annotations.AssociatedNavigationProperty:\r\n newKey = format[0] + \"_NavigationProperty\";\r\n break;\r\n case DWA.Prefer.Annotations.LookupLogicalName:\r\n newKey = format[0] + \"_LogicalName\";\r\n break;\r\n }\r\n }\r\n\r\n return [newKey, value];\r\n}\r\n\r\n/**\r\n *\r\n * @param {any} object - parsed JSON object\r\n * @param {any} parseParams - parameters for parsing the response\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseData(object: any, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return Utility.convertToReferenceObject(object);\r\n }\r\n\r\n if (parseParams.toCount) {\r\n return getFormattedKeyValue(\"@odata.count\", object[\"@odata.count\"])[1] || 0;\r\n }\r\n }\r\n\r\n const keys = Object.keys(object);\r\n\r\n for (let i = 0; i < keys.length; i++) {\r\n const currentKey = keys[i];\r\n\r\n if (object[currentKey] != null) {\r\n if (object[currentKey].constructor === Array) {\r\n for (var j = 0; j < object[currentKey].length; j++) {\r\n object[currentKey][j] = parseData(object[currentKey][j]);\r\n }\r\n } else if (typeof object[currentKey] === \"object\") {\r\n parseData(object[currentKey]);\r\n }\r\n }\r\n\r\n //parse formatted values\r\n let formattedKeyValue = getFormattedKeyValue(currentKey, object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n\r\n //parse aliased values\r\n if (currentKey.indexOf(\"_x002e_\") !== -1) {\r\n const aliasKeys = currentKey.split(\"_x002e_\");\r\n\r\n if (!object.hasOwnProperty(aliasKeys[0])) {\r\n object[aliasKeys[0]] = { _dwaType: \"alias\" };\r\n }\r\n //throw an error if there is already a property which is not an 'alias'\r\n else if (\r\n typeof object[aliasKeys[0]] !== \"object\" ||\r\n (typeof object[aliasKeys[0]] === \"object\" && !object[aliasKeys[0]].hasOwnProperty(\"_dwaType\"))\r\n ) {\r\n throw new Error(\"The alias name of the linked entity must be unique!\");\r\n }\r\n\r\n object[aliasKeys[0]][aliasKeys[1]] = object[currentKey];\r\n\r\n //aliases also contain formatted values\r\n formattedKeyValue = getFormattedKeyValue(aliasKeys[1], object[currentKey]);\r\n if (formattedKeyValue[0]) {\r\n object[aliasKeys[0]][formattedKeyValue[0]] = formattedKeyValue[1];\r\n }\r\n }\r\n }\r\n\r\n if (parseParams) {\r\n if (parseParams.hasOwnProperty(\"pageNumber\") && object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie] != null) {\r\n object.PagingInfo = Utility.getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\r\n}\r\n\r\nconst responseHeaderRegex = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction parseBatchHeaders(text: string): any {\r\n const ctx = { position: 0 };\r\n const headers = {};\r\n let parts;\r\n let line;\r\n let pos;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n parts = responseHeaderRegex.exec(line);\r\n if (parts !== null) {\r\n headers[parts[1].toLowerCase()] = parts[2];\r\n } else {\r\n // Whatever was found is not a header, so reset the context position.\r\n ctx.position = pos;\r\n }\r\n } while (line && parts);\r\n\r\n return headers;\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readLine(text: string, ctx: { position: number }): string | null {\r\n return readTo(text, ctx, \"\\r\\n\");\r\n}\r\n\r\n//partially taken from http://olingo.apache.org/doc/javascript/apidoc/batch.js.html\r\nfunction readTo(text: string, ctx: { position: number }, str: string): string | null {\r\n const start = ctx.position || 0;\r\n let end = text.length;\r\n if (str) {\r\n end = text.indexOf(str, start);\r\n if (end === -1) {\r\n return null;\r\n }\r\n ctx.position = end + str.length;\r\n } else {\r\n ctx.position = end;\r\n }\r\n\r\n return text.substring(start, end);\r\n}\r\n\r\n//partially taken from https://github.com/emiltholin/google-api-batch-utils\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @param {Number} [requestNumber] - number of the request\r\n * @returns {any} parsed batch response\r\n */\r\nfunction parseBatchResponse(response: string, parseParams: any, requestNumber: number = 0): (string | undefined | DynamicsWebApiError | Number)[] {\r\n // Not the same delimiter in the response as we specify ourselves in the request,\r\n // so we have to extract it.\r\n const delimiter = response.substr(0, response.indexOf(\"\\r\\n\"));\r\n const batchResponseParts = response.split(delimiter);\r\n // The first part will always be an empty string. Just remove it.\r\n batchResponseParts.shift();\r\n // The last part will be the \"--\". Just remove it.\r\n batchResponseParts.pop();\r\n\r\n let result: (string | undefined | DynamicsWebApiError | Number)[] = [];\r\n for (let i = 0; i < batchResponseParts.length; i++) {\r\n let batchResponse = batchResponseParts[i];\r\n if (batchResponse.indexOf(\"--changesetresponse_\") > -1) {\r\n batchResponse = batchResponse.trim();\r\n const batchToProcess = batchResponse.substring(batchResponse.indexOf(\"\\r\\n\") + 1).trim();\r\n\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber));\r\n } else {\r\n //check http status\r\n const httpStatusReg = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/gm.exec(batchResponse);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n const httpStatus = parseInt(httpStatusReg![1]);\r\n const httpStatusMessage = httpStatusReg![2].trim();\r\n\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n if (!responseData) {\r\n if (/Content-Type: text\\/plain/i.test(batchResponse)) {\r\n const plainContentReg = /\\w+$/gi.exec(batchResponse.trim());\r\n const plainContent = plainContentReg && plainContentReg.length ? plainContentReg[0] : undefined;\r\n\r\n //check if a plain content is a number or not\r\n result.push(isNaN(Number(plainContent)) ? plainContent : Number(plainContent));\r\n } else {\r\n if (parseParams.length && parseParams[requestNumber] && parseParams[requestNumber].hasOwnProperty(\"valueIfEmpty\")) {\r\n result.push(parseParams[requestNumber].valueIfEmpty);\r\n } else {\r\n const entityUrl = /OData-EntityId.+/i.exec(batchResponse);\r\n\r\n if (entityUrl && entityUrl.length) {\r\n const guidResult = extractUuidFromUrl(entityUrl[0]);\r\n result.push(guidResult ? guidResult : undefined);\r\n } else {\r\n result.push(undefined);\r\n }\r\n }\r\n }\r\n } else {\r\n const parsedResponse = parseData(JSON.parse(responseData, dateReviver), parseParams[requestNumber]);\r\n\r\n if (httpStatus >= 400) {\r\n const responseHeaders = parseBatchHeaders(\r\n //todo: add error handler for httpStatusReg; remove \"!\" operator\r\n batchResponse.substring(batchResponse.indexOf(httpStatusReg![0]) + httpStatusReg![0].length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n result.push(\r\n ErrorHelper.handleHttpError(parsedResponse, {\r\n status: httpStatus,\r\n statusText: httpStatusMessage,\r\n statusMessage: httpStatusMessage,\r\n headers: responseHeaders,\r\n })\r\n );\r\n } else {\r\n result.push(parsedResponse);\r\n }\r\n }\r\n }\r\n\r\n requestNumber++;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction base64ToString(base64: string): string {\r\n return global.DWA_BROWSER ? global.window.atob(base64) : Buffer.from(base64, \"base64\").toString(\"binary\");\r\n}\r\n\r\nfunction parseFileResponse(response: any, responseHeaders: any, parseParams: any): Core.FileParseResult {\r\n let data = response;\r\n\r\n if (parseParams.hasOwnProperty(\"parse\")) {\r\n data = JSON.parse(data).value;\r\n data = base64ToString(data);\r\n }\r\n\r\n var parseResult: Core.FileParseResult = {\r\n value: data,\r\n };\r\n\r\n if (responseHeaders[\"x-ms-file-name\"]) parseResult.fileName = responseHeaders[\"x-ms-file-name\"];\r\n\r\n if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n\r\n if (hasHeader(responseHeaders, \"Location\")) parseResult.location = getHeader(responseHeaders, \"Location\");\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction hasHeader(headers: any, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nfunction getHeader(headers: any, name: string): string {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\r\n/**\r\n *\r\n * @param {string} response - response that needs to be parsed\r\n * @param {Array} responseHeaders - response headers\r\n * @param {Array} parseParams - parameters for parsing the response\r\n * @returns {any} parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: any, parseParams: any[]): any {\r\n let parseResult: any = undefined;\r\n if (response.length) {\r\n if (response.indexOf(\"--batchresponse_\") > -1) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n\r\n parseResult = parseParams.length === 1 && parseParams[0].convertedToBatch ? batch[0] : batch;\r\n } else {\r\n if (hasHeader(responseHeaders, \"Content-Disposition\")) {\r\n parseResult = parseFileResponse(response, responseHeaders, parseParams[0]);\r\n } else {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n if (contentType.startsWith(\"application/json\")) {\r\n parseResult = parseData(JSON.parse(response, dateReviver), parseParams[0]);\r\n } else {\r\n parseResult = isNaN(Number(response)) ? response : Number(response);\r\n }\r\n }\r\n }\r\n } else {\r\n if (parseParams.length && parseParams[0].hasOwnProperty(\"valueIfEmpty\")) {\r\n parseResult = parseParams[0].valueIfEmpty;\r\n } else if (hasHeader(responseHeaders, \"OData-EntityId\")) {\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n\r\n const guidResult = extractUuidFromUrl(entityUrl);\r\n\r\n if (guidResult) {\r\n parseResult = guidResult;\r\n }\r\n } else if (hasHeader(responseHeaders, \"Location\")) {\r\n parseResult = {\r\n location: getHeader(responseHeaders, \"Location\"),\r\n };\r\n\r\n if (responseHeaders[\"x-ms-chunk-size\"]) parseResult.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n }\r\n\r\n return parseResult;\r\n}\r\n", "\uFEFFimport * as http from \"http\";\r\nimport * as https from \"https\";\r\nimport HttpProxyAgent from \"http-proxy-agent\";\r\nimport HttpsProxyAgent from \"https-proxy-agent\";\r\nimport { Core } from \"../types\";\r\nimport { ErrorHelper } from \"./../helpers/ErrorHelper\";\r\nimport { parseResponse } from \"./helpers/parseResponse\";\r\n\r\nconst agents: { [key: string]: http.Agent } = {};\r\n\r\nconst getAgent = (options: Core.RequestOptions, protocol: string): http.Agent => {\r\n const isHttp = protocol === \"http\";\r\n const proxy = options.proxy;\r\n const agentName = proxy ? proxy.url : protocol;\r\n\r\n if (!agents[agentName]) {\r\n if (proxy) {\r\n const parsedProxyUrl = new URL(proxy.url);\r\n const proxyAgent = isHttp ? HttpProxyAgent.HttpProxyAgent : HttpsProxyAgent.HttpsProxyAgent;\r\n\r\n const proxyOptions: HttpProxyAgent.HttpProxyAgentOptions | HttpsProxyAgent.HttpsProxyAgentOptions = {\r\n host: parsedProxyUrl.hostname,\r\n port: parsedProxyUrl.port,\r\n protocol: parsedProxyUrl.protocol,\r\n };\r\n\r\n if (proxy.auth) proxyOptions.auth = proxy.auth.username + \":\" + proxy.auth.password;\r\n else if (parsedProxyUrl.username && parsedProxyUrl.password) proxyOptions.auth = `${parsedProxyUrl.username}:${parsedProxyUrl.password}`;\r\n\r\n agents[agentName] = new proxyAgent(proxyOptions);\r\n } else {\r\n const protocolInterface = isHttp ? http : https;\r\n\r\n agents[agentName] = new protocolInterface.Agent({\r\n keepAlive: true,\r\n maxSockets: Infinity,\r\n });\r\n }\r\n }\r\n\r\n return agents[agentName];\r\n};\r\n\r\nexport function executeRequest(options: Core.RequestOptions): Promise {\r\n return new Promise((resolve, reject) => {\r\n _executeRequest(options, resolve, reject);\r\n });\r\n}\r\n\r\n/**\r\n * Sends a request to given URL with given parameters\r\n *\r\n */\r\nfunction _executeRequest(\r\n options: Core.RequestOptions,\r\n successCallback: (response: Core.WebApiResponse) => void,\r\n errorCallback: (error: Core.WebApiErrorResponse | Core.WebApiErrorResponse[]) => void\r\n) {\r\n const data = options.data;\r\n const additionalHeaders = options.additionalHeaders;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n const headers: http.OutgoingHttpHeaders = {};\r\n\r\n if (data) {\r\n headers[\"Content-Type\"] = additionalHeaders[\"Content-Type\"];\r\n headers[\"Content-Length\"] = data.length;\r\n\r\n delete additionalHeaders[\"Content-Type\"];\r\n }\r\n\r\n //set additional headers\r\n for (let key in additionalHeaders) {\r\n headers[key] = additionalHeaders[key];\r\n }\r\n const parsedUrl = new URL(options.uri);\r\n const protocol = parsedUrl.protocol?.slice(0, -1) || \"https\";\r\n const protocolInterface = protocol === \"http\" ? http : https;\r\n\r\n const internalOptions: http.RequestOptions = {\r\n hostname: parsedUrl.hostname,\r\n port: parsedUrl.port,\r\n path: parsedUrl.pathname + parsedUrl.search,\r\n method: options.method,\r\n timeout: options.timeout || 0,\r\n headers: headers,\r\n signal: signal,\r\n };\r\n\r\n //support environment variables\r\n if (!options.proxy && process.env[`${protocol}_proxy`]) {\r\n options.proxy = {\r\n url: process.env[`${protocol}_proxy`]!,\r\n };\r\n }\r\n\r\n internalOptions.agent = getAgent(options, protocol);\r\n\r\n if (options.proxy) {\r\n const hostHeader = new URL(options.proxy.url).host;\r\n if (hostHeader) headers.host = hostHeader;\r\n }\r\n\r\n const request = protocolInterface.request(internalOptions, function (res) {\r\n let rawData = \"\";\r\n res.setEncoding(\"utf8\");\r\n res.on(\"data\", function (chunk) {\r\n rawData += chunk;\r\n });\r\n res.on(\"end\", function () {\r\n switch (res.statusCode) {\r\n case 200: // Success with content returned in response body.\r\n case 201: // Success with content returned in response body.\r\n case 204: // Success with no content returned in response body.\r\n case 206: //Success with partial content\r\n case 304: {\r\n // Success with Not Modified\r\n let responseData = parseResponse(rawData, res.headers, responseParams[options.requestId]);\r\n\r\n let response = {\r\n data: responseData,\r\n headers: res.headers as any,\r\n status: res.statusCode,\r\n };\r\n\r\n successCallback(response);\r\n break;\r\n }\r\n default:\r\n // All other statuses are error cases.\r\n let crmError;\r\n try {\r\n var errorParsed = parseResponse(rawData, res.headers, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n break;\r\n }\r\n\r\n crmError = errorParsed.hasOwnProperty(\"error\") && errorParsed.error ? errorParsed.error : { message: errorParsed.Message };\r\n } catch (e) {\r\n if (rawData.length > 0) {\r\n crmError = { message: rawData };\r\n } else {\r\n crmError = { message: \"Unexpected Error\" };\r\n }\r\n }\r\n\r\n errorCallback(\r\n ErrorHelper.handleHttpError(crmError, {\r\n status: res.statusCode,\r\n statusText: \"\",\r\n statusMessage: res.statusMessage,\r\n headers: res.headers,\r\n })\r\n );\r\n break;\r\n }\r\n });\r\n });\r\n\r\n if (internalOptions.timeout) {\r\n request.setTimeout(internalOptions.timeout, function () {\r\n request.destroy();\r\n });\r\n }\r\n\r\n request.on(\"error\", function (error) {\r\n errorCallback(error);\r\n });\r\n\r\n if (data) {\r\n request.write(data);\r\n }\r\n\r\n request.end();\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config } from \"../dynamics-web-api\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\";\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n}\r\n\r\nconst getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (Utility.isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = Utility.getClientUrl();\r\n return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeApiConfigs = (apiConfig: ApiConfig | undefined, apiType: ApiType, internalConfig: InternalConfig): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, \"DynamicsWebApi.setConfig\", `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, \"DynamicsWebApi.setConfig\", `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport class ConfigurationUtility {\r\n static mergeApiConfigs = mergeApiConfigs;\r\n\r\n static merge(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, \"DynamicsWebApi.setConfig\", \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n mergeApiConfigs(config?.dataApi, \"dataApi\", internalConfig);\r\n mergeApiConfigs(config?.searchApi, \"searchApi\", internalConfig);\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, \"DynamicsWebApi.setConfig\", \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, \"DynamicsWebApi.setConfig\", \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, \"DynamicsWebApi.setConfig\", \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, \"DynamicsWebApi.setConfig\", \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, \"DynamicsWebApi.setConfig\", \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, \"DynamicsWebApi.setConfig\", \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, \"DynamicsWebApi.setConfig\", \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, \"DynamicsWebApi.setConfig\", \"config.useEntityNames\");\r\n internalConfig.useEntityNames = config.useEntityNames;\r\n }\r\n\r\n if (config?.headers) {\r\n internalConfig.headers = config.headers;\r\n }\r\n\r\n if (!global.DWA_BROWSER && config?.proxy) {\r\n ErrorHelper.parameterCheck(config.proxy, \"DynamicsWebApi.setConfig\", \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, \"DynamicsWebApi.setConfig\", \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, \"DynamicsWebApi.setConfig\", \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, \"DynamicsWebApi.setConfig\", \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n }\r\n\r\n static default(): InternalConfig {\r\n return {\r\n serverUrl: null,\r\n impersonate: null,\r\n impersonateAAD: null,\r\n onTokenRefresh: null,\r\n includeAnnotations: null,\r\n maxPageSize: null,\r\n returnRepresentation: null,\r\n proxy: null,\r\n dataApi: {\r\n path: \"data\",\r\n version: \"9.2\",\r\n url: \"\"\r\n },\r\n searchApi: {\r\n path: \"search\",\r\n version: \"1.0\",\r\n url: \"\"\r\n },\r\n };\r\n }\r\n}\r\n", "\uFEFFimport { ConfigurationUtility } from \"./utils/Config\";\r\nimport { Utility } from \"./utils/Utility\";\r\nimport { ErrorHelper } from \"./helpers/ErrorHelper\";\r\nimport { RequestClient } from \"./client/RequestClient\";\r\nimport type { Core } from \"./types\";\r\n\r\n/**\r\n * Microsoft Dynamics CRM Web API helper library written in JavaScript.\r\n * It is compatible with: Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n private _config = ConfigurationUtility.default();\r\n private _isBatch = false;\r\n private _batchRequestId: string | null = null;\r\n\r\n /**\r\n * Initializes a new instance of DynamicsWebApi\r\n * @param config - Configuration object\r\n */\r\n constructor(config?: Config) {\r\n ConfigurationUtility.merge(this._config, config);\r\n }\r\n\r\n /**\r\n\t * Merges provided configuration properties with an existing one.\r\n\t *\r\n\t * @param {DynamicsWebApi.Config} config - Configuration\r\n\t * @example\r\n\t dynamicsWebApi.setConfig({ serverUrl: 'https://contoso.api.crm.dynamics.com/' });\r\n\t */\r\n setConfig = (config: Config) => ConfigurationUtility.merge(this._config, config);\r\n\r\n private _makeRequest = async (request: Core.InternalRequest): Promise => {\r\n request.isBatch = this._isBatch;\r\n if (this._batchRequestId) request.requestId = this._batchRequestId;\r\n return RequestClient.makeRequest(request, this._config);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a new record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const lead = {\r\n * subject: \"Test WebAPI\",\r\n * firstname: \"Test\",\r\n * lastname: \"WebAPI\",\r\n * jobtitle: \"Title\"\r\n *};\r\n *\r\n *const request = {\r\n * data: lead,\r\n * collection: \"leads\",\r\n * returnRepresentation: true\r\n *}\r\n *\r\n *const response = await dynamicsWebApi.create(request);\r\n *\r\n */\r\n create = async (request: CreateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.create\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"create\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n * @example\r\n *const request = {\r\n * key: '7d577253-3ef0-4a0a-bb7f-8335c2596e70',\r\n * collection: \"leads\",\r\n * select: [\"fullname\", \"subject\"],\r\n * ifnonematch: 'W/\"468026\"',\r\n * includeAnnotations: \"OData.Community.Display.V1.FormattedValue\"\r\n *};\r\n *\r\n *const response = await dynamicsWebApi.retrieve(request);\r\n */\r\n retrieve = async (request: RetrieveRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieve\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieve\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.responseParameters = {\r\n isRef: internalRequest.select?.length === 1 && internalRequest.select[0].endsWith(\"/$ref\"),\r\n };\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.update\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"update\";\r\n } else internalRequest = request;\r\n\r\n //Metadata definitions, cannot be updated using \"PATCH\" method\r\n if (!internalRequest.method)\r\n internalRequest.method = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(internalRequest.collection || \"\")\r\n ? \"PUT\"\r\n : \"PATCH\";\r\n\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n if (internalRequest.ifmatch == null) {\r\n internalRequest.ifmatch = \"*\"; //to prevent upsert\r\n }\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a single value in the record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateSingleProperty\", \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, \"DynamicsWebApi.updateSingleProperty\", \"request.fieldValuePair\");\r\n\r\n var field = Object.keys(request.fieldValuePair)[0];\r\n var fieldValue = request.fieldValuePair[field];\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = \"updateSingleProperty\";\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a record.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRecord = async (request: DeleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRecord\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"deleteRecord\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifmatch && error.status === 412) {\r\n //precondition failed - not updated\r\n return false; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to upsert a record.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.upsert\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"upsert\";\r\n\r\n //copy locally\r\n const ifnonematch = internalRequest.ifnonematch;\r\n const ifmatch = internalRequest.ifmatch;\r\n try {\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n } catch (error: any) {\r\n if (ifnonematch && error.status === 412) {\r\n //if prevent update\r\n return null; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n };\r\n\r\n private _uploadFileChunk = async (request: Core.InternalRequest, fileBytes: Uint8Array | Buffer, chunkSize: number, offset: number = 0): Promise => {\r\n // offset = offset || 0;\r\n Utility.setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await this._makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return this._uploadFileChunk(request, fileBytes, chunkSize, offset);\r\n }\r\n };\r\n\r\n /**\r\n * Upload file to a File Attribute\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n uploadFile = async (request: UploadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.uploadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.uploadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = \"uploadFile\";\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n internalRequest.url = response?.data.location;\r\n delete internalRequest.transferMode;\r\n delete internalRequest.fieldName;\r\n delete internalRequest.fileName;\r\n return this._uploadFileChunk(internalRequest, request.data, response?.data.chunkSize);\r\n };\r\n\r\n private _downloadFileChunk = async (\r\n request: Core.InternalRequest,\r\n bytesDownloaded: number = 0,\r\n // fileSize: number = 0,\r\n data: string = \"\"\r\n ): Promise => {\r\n // bytesDownloaded = bytesDownloaded || 0;\r\n // fileSize = fileSize || 0;\r\n // data = data || \"\";\r\n\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + Utility.downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await this._makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += Utility.downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return this._downloadFileChunk(request, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: Utility.convertToFileBuffer(data),\r\n };\r\n };\r\n\r\n /**\r\n * Download a file from a File Attribute\r\n * @param request - An object that represents all possible options for a current request.\r\n */\r\n downloadFile = (request: DownloadRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.downloadFile\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.downloadFile\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"downloadFile\";\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return this._downloadFileChunk(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @param {string} [nextPageLink] - Use the value of the @odata.nextLink property with a new GET request to return the next page of data. Pass null to retrieveMultipleOptions.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveMultiple = async (request: RetrieveMultipleRequest, nextPageLink?: string): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveMultiple\", \"request\");\r\n\r\n let internalRequest: Core.InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = Utility.copyRequest(request);\r\n internalRequest.functionName = \"retrieveMultiple\";\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, \"DynamicsWebApi.retrieveMultiple\", \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n };\r\n\r\n private _retrieveAllRequest = async (request: RetrieveMultipleRequest, nextPageLink?: string, records: any[] = []): Promise> => {\r\n const response = await this.retrieveMultiple(request, nextPageLink);\r\n records = records.concat(response.value);\r\n\r\n const pageLink = response.oDataNextLink;\r\n\r\n if (pageLink) {\r\n return this._retrieveAllRequest(request, pageLink, records);\r\n }\r\n\r\n const result: AllResponse = { value: records };\r\n\r\n if (response.oDataDeltaLink) {\r\n result[\"@odata.deltaLink\"] = response.oDataDeltaLink;\r\n result.oDataDeltaLink = response.oDataDeltaLink;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve all records.\r\n *\r\n * @param {DWARequest} request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.retrieveAll\", this._isBatch);\r\n return this._retrieveAllRequest(request);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. IMPORTANT! The count value does not represent the total number of entities in the system. It is limited by the maximum number of entities that can be returned. Returns: Number\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n count = async (request: CountRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.count\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"count\";\r\n\r\n if (internalRequest.filter?.length) {\r\n internalRequest.count = true;\r\n } else {\r\n internalRequest.navigationProperty = \"$count\";\r\n }\r\n\r\n internalRequest.responseParameters = { toCount: internalRequest.count };\r\n\r\n //if filter has not been specified then simplify the request\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to count records. Returns: Number\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n countAll = async (request: CountAllRequest): Promise => {\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.countAll\", this._isBatch);\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.countAll\", \"request\");\r\n\r\n const response = await this._retrieveAllRequest(request);\r\n\r\n return response ? (response.value ? response.value.length : 0) : 0;\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve records. Returns: DWA.Types.FetchXmlResponse\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetch\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = \"fetch\";\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, \"DynamicsWebApi.fetch\", \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !/^(request: FetchAllRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.fetchAll\", \"request\");\r\n\r\n const _executeFetchXmlAll = async (request: FetchXmlRequest, records: any[] = []): Promise> => {\r\n // records = records || [];\r\n\r\n const response = await this.fetch(request);\r\n\r\n records = records.concat(response.value);\r\n\r\n if (response.PagingInfo) {\r\n request.pageNumber = response.PagingInfo.nextPage;\r\n request.pagingCookie = response.PagingInfo.cookie;\r\n\r\n return _executeFetchXmlAll(request, records);\r\n }\r\n\r\n return { value: records };\r\n };\r\n\r\n ErrorHelper.throwBatchIncompatible(\"DynamicsWebApi.fetchAll\", this._isBatch);\r\n return _executeFetchXmlAll(request);\r\n };\r\n\r\n /**\r\n * Associate for a collection-valued navigation property. (1:N or N:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associate = async (request: AssociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"associate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associate\", \"request.relatedcollection\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.associate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associate\", \"request.relatedKey\");\r\n\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Disassociate for a collection-valued navigation property.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociate = async (request: DisassociateRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociate\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociate\";\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, \"DynamicsWebApi.disassociate\", \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociate\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.disassociate\", \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Associate for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n associateSingleValued = async (request: AssociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.associateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = \"associateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.associateSingleValued\", \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, \"DynamicsWebApi.associateSingleValued\", \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.associateSingleValued\", \"request.navigationProperty\");\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, \"DynamicsWebApi.associateSingleValued\", \"request.relatedcollection\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n internalRequest.data = { \"@odata.id\": `${request.relatedCollection}(${relatedKey})` };\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Removes a reference to an entity for a single-valued navigation property. (1:N)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n disassociateSingleValued = async (request: DisassociateSingleValuedRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.disassociateSingleValued\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = \"disassociateSingleValued\";\r\n\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, \"DynamicsWebApi.disassociateSingleValued\", \"request.primaryKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, \"DynamicsWebApi.disassociateSingleValued\", \"request.navigationProperty\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await this._makeRequest(internalRequest);\r\n };\r\n\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callFunction`, \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.functionName\" : \"name\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { functionName: request as string };\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.functionName, `DynamicsWebApi.callFunction`, parameterName);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest._additionalUrl = internalRequest.functionName + Utility.buildFunctionParameters(internalRequest.parameters);\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = \"callFunction\";\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Calls a Web API action\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (\r\n request: BoundActionRequest | UnboundActionRequest\r\n ): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.callAction`, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, `DynamicsWebApi.callAction`, \"request.actionName\");\r\n\r\n const internalRequest = Utility.copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"callAction\";\r\n\r\n internalRequest._additionalUrl = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n /**\r\n * Sends an asynchronous request to create an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, `DynamicsWebApi.createEntity`, \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createEntity\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"createEntity\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateEntity\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateEntity\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateEntity\", \"request.data.MetadataId\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.functionName = \"updateEntity\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveEntity\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveEntity\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve entity definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntities\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.createAttribute\", \"request.entityKey\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update an attribute.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateAttribute\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateAttribute\", \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.updateAttribute\", \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateAttribute\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.data.MetadataId;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"updateAttribute\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttributes\", \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttributes\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttributes\";\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveAttributes\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, \"DynamicsWebApi.retrieveAttribute\", \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, \"DynamicsWebApi.retrieveAttribute\", \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveAttribute\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.navigationPropertyKey = request.attributeKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n internalRequest.key = request.entityKey;\r\n internalRequest.functionName = \"retrieveAttribute\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createRelationship\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"createRelationship\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateRelationship\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateRelationship\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateRelationship\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"updateRelationship\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteRelationship = (request: DeleteRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.deleteRelationship\", \"request.key\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"deleteRelationship\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve relationship definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = \"retrieveRelationships\";\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationships\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve a specific relationship definition.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveRelationship\", \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, \"DynamicsWebApi.retrieveRelationship\", \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveRelationship\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveRelationship\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to create a Global Option Set definition\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.createGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.createGlobalOptionSet\", \"request.data\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"createGlobalOptionSet\";\r\n\r\n return this.create(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to update a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.updateGlobalOptionSet\", \"request\");\r\n ErrorHelper.parameterCheck(request.data, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.updateGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = \"updateGlobalOptionSet\";\r\n internalRequest.method = \"PUT\";\r\n\r\n return this.update(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to delete a Global Option Set.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n deleteGlobalOptionSet = (request: DeleteGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.deleteGlobalOptionSet\", \"request\");\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"deleteGlobalOptionSet\";\r\n\r\n return this.deleteRecord(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSet\", \"request.castType\");\r\n }\r\n\r\n const internalRequest = Utility.copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = \"retrieveGlobalOptionSet\";\r\n\r\n return this.retrieve(internalRequest);\r\n };\r\n\r\n /**\r\n * Sends an asynchronous request to retrieve Global Option Set definitions.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = \"retrieveGlobalOptionSets\";\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, \"DynamicsWebApi.retrieveGlobalOptionSets\", \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return this.retrieveMultiple(internalRequest);\r\n };\r\n\r\n /**\r\n * Retrieves a CSDL Document Metadata\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} A raw CSDL $metadata document.\r\n */\r\n retrieveCsdlMetadata = async (request?: CsdlMetadataRequest): Promise => {\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = \"retrieveCsdlMetadata\";\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, \"DynamicsWebApi.retrieveCsdlMetadata\", \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n search: SearchFunction = async (request: string | SearchRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.search\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.search\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.search\", parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = \"search\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n suggest: SuggestFunction = async (request: string | SuggestRequest): Promise> => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.suggest\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.suggest\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.suggest\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"suggest\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise => {\r\n ErrorHelper.parameterCheck(request, \"DynamicsWebApi.autocomplete\", \"request\");\r\n\r\n const isObject = Utility.isObject(request);\r\n const parameterName = isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: Core.InternalRequest = isObject ? Utility.copyObject(request) : { query: { search: request as string } };\r\n\r\n if (isObject) ErrorHelper.parameterCheck(internalRequest.query, \"DynamicsWebApi.autocomplete\", \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, `DynamicsWebApi.autocomplete`, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, \"DynamicsWebApi.autocomplete\", parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = \"autocomplete\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = internalRequest.query;\r\n internalRequest.apiConfig = this._config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Starts/executes a batch request.\r\n */\r\n startBatch = (): void => {\r\n this._isBatch = true;\r\n this._batchRequestId = Utility.generateUUID();\r\n };\r\n\r\n /**\r\n * Executes a batch request. Please call DynamicsWebApi.startBatch() first to start a batch request.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n executeBatch = async (request?: BatchRequest): Promise => {\r\n ErrorHelper.throwBatchNotStarted(this._isBatch);\r\n\r\n const internalRequest: Core.InternalRequest = !request ? {} : Utility.copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = \"executeBatch\";\r\n internalRequest.requestId = this._batchRequestId;\r\n\r\n this._batchRequestId = null;\r\n this._isBatch = false;\r\n\r\n const response = await this._makeRequest(internalRequest);\r\n return response?.data;\r\n };\r\n\r\n /**\r\n * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance.\r\n *\r\n * @param {Config} config configuration object.\r\n * @returns {DynamicsWebApi} A new instance of DynamicsWebApi\r\n */\r\n initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config);\r\n\r\n Utility = {\r\n /**\r\n * Searches for a collection name by provided entity name in a cached entity metadata.\r\n * The returned collection name can be null.\r\n *\r\n * @param {string} entityName entity name\r\n * @returns {string | null} collection name\r\n */\r\n getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName),\r\n };\r\n}\r\n\r\nexport interface Expand {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**An Array(of Strings) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**A name of a single-valued navigation property which needs to be expanded. */\r\n property?: string;\r\n /**An Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface BaseRequest {\r\n /**XHR requests only! Indicates whether the requests should be made synchronously or asynchronously.Default value is 'true'(asynchronously). */\r\n async?: boolean;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string;\r\n /**If set to 'true', DynamicsWebApi adds a request header 'Cache-Control: no-cache'.Default value is 'false'. */\r\n noCache?: boolean;\r\n /** Authorization Token. If set, onTokenRefresh will not be called. */\r\n token?: string;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number;\r\n /**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */\r\n signal?: AbortSignal;\r\n /**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's \"true\", except for GET operations - they are not allowed in Change Sets. */\r\n inChangeSet?: boolean;\r\n /**Headers to supply with a request. These headers will override configuraiton headers if the identical ones were set. */\r\n headers?: HeaderCollection;\r\n /**Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\". Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n}\r\n\r\nexport interface BatchRequest extends BaseRequest {\r\n /** Sets Prefer header to \"odata.continue-on-error\" that allows more requests be processed when errors occur. The batch request will return '200 OK' and individual response errors will be returned in the batch response body. */\r\n continueOnError?: boolean;\r\n}\r\n\r\nexport interface Request extends BaseRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\r\n}\r\n\r\nexport interface CRUDRequest extends Request {\r\n /**A String representing collection record's Primary Key (GUID) or Alternate Key(s). */\r\n key?: string;\r\n}\r\n\r\nexport interface CountRequest extends Request {\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface CountAllRequest extends CountRequest {\r\n /**An Array (of strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n}\r\n\r\nexport interface FetchAllRequest extends Request {\r\n /**Sets FetchXML - a proprietary query language that provides capabilities to perform aggregation. */\r\n fetchXml: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation. Annotations provide additional information about lookups, options sets and other complex attribute types. For example: * or Microsoft.Dynamics.CRM.fetchxmlpagingcookie */\r\n includeAnnotations?: string;\r\n}\r\n\r\nexport interface FetchXmlRequest extends FetchAllRequest {\r\n /**Page number. */\r\n pageNumber?: number;\r\n /**Paging cookie. To retrive the first page, pagingCookie must be null. */\r\n pagingCookie?: string;\r\n}\r\n\r\nexport interface CreateRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequestBase extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Web API v9+ only! Boolean that enables duplicate detection. */\r\n duplicateDetection?: boolean;\r\n /**A JavaScript object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data?: T;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface UpdateRequest extends UpdateRequestBase {\r\n /**If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false' */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface UpdateSinglePropertyRequest extends CRUDRequest {\r\n /**Object with a logical name of the field as a key and a value to update with. Example: {subject: \"Update Record\"} */\r\n fieldValuePair: { [key: string]: any };\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request. */\r\n returnRepresentation?: boolean;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n}\r\n\r\nexport interface UpsertRequest extends UpdateRequestBase {\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n}\r\n\r\nexport interface DeleteRequest extends CRUDRequest {\r\n /**If set to true, the request bypasses custom business logic, all synchronous plug-ins and real-time workflows are disabled. Check for special exceptions in Microsft Docs. */\r\n bypassCustomPluginExecution?: boolean;\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set. */\r\n contentId?: string;\r\n /**Field name that needs to be cleared (for example File Field) */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests.*/\r\n ifmatch?: string;\r\n /**Sets If-None-Match header value that enables to use conditional retrieval in applicable requests. */\r\n ifnonematch?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Casts the AttributeMetadata to a specific type. (Used in requests to Attribute Metadata). */\r\n metadataAttributeType?: string;\r\n /**A String representing the name of a single - valued navigation property.Useful when needed to retrieve information about a related record in a single request. */\r\n navigationProperty?: string;\r\n /**A String representing navigation property's Primary Key (GUID) or Alternate Key(s). (For example, to retrieve Attribute Metadata). */\r\n navigationPropertyKey?: string;\r\n /**A String representing the GUID value of the saved query. */\r\n savedQuery?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**A String representing the GUID value of the user query. */\r\n userQuery?: string;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleRequest extends Request {\r\n /**Use the $apply to aggregate and group your data dynamically */\r\n apply?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n /**Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000(per page).Do not use $top with $count! */\r\n count?: boolean;\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types. */\r\n includeAnnotations?: string;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number;\r\n /**An Array(of string) representing the order in which items are returned using the $orderby system query option.Use the asc or desc suffix to specify ascending or descending order respectively.The default is ascending if the suffix isn't applied. */\r\n orderBy?: string[];\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Limit the number of results returned by using the $top system query option.Do not use $top with $count! */\r\n top?: number;\r\n /**Sets Prefer header with value 'odata.track-changes' to request that a delta link be returned which can subsequently be used to retrieve entity changes. */\r\n trackChanges?: boolean;\r\n /**A unique partition key value of a logical partition for non-relational custom entity data stored in NoSql tables of Azure heterogenous storage. */\r\n partitionId?: string;\r\n}\r\n\r\nexport interface AssociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface AssociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**Related name of the Entity Collection or Entity Logical name. */\r\n relatedCollection: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**Related entity record id/key. */\r\n relatedKey: string;\r\n}\r\n\r\nexport interface DisassociateSingleValuedRequest extends Request {\r\n /**Primary entity record id/key. */\r\n primaryKey: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n}\r\n\r\nexport interface UnboundFunctionRequest extends BaseRequest {\r\n /**Name of the function. */\r\n functionName: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\r\n}\r\n\r\nexport interface BoundFunctionRequest extends UnboundFunctionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface UnboundActionRequest extends BaseRequest {\r\n /**A name of the Web API action. */\r\n actionName: string;\r\n /**An object that represents a Dynamics 365 action. */\r\n action?: TAction;\r\n}\r\n\r\nexport interface BoundActionRequest extends UnboundActionRequest, Request {\r\n /**A String representing the GUID value for the record. */\r\n key?: string;\r\n}\r\n\r\nexport interface CreateEntityRequest extends BaseRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateEntityRequest extends CRUDRequest {\r\n /**An object with properties corresponding to the logical name of entity attributes(exceptions are lookups and single-valued navigation properties). */\r\n data: any;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveEntityRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveEntitiesRequest extends BaseRequest {\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateAttributeRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Attribute metadata object. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateAttributeRequest extends CreateAttributeRequest {\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface RetrieveAttributesRequest extends BaseRequest {\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveAttributeRequest extends BaseRequest {\r\n /**An Attribute MetadataId or Alternate Key (such as LogicalName). */\r\n attributeKey: string;\r\n /**An Entity MetadataId or Alternate Key (such as LogicalName). */\r\n entityKey: string;\r\n /**Use this parameter to cast the Attribute to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateRelationshipRequest extends BaseRequest {\r\n /**Relationship Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateRelationshipRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveRelationshipsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveRelationshipRequest extends BaseRequest {\r\n /**A Relationship MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Relationship metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface CreateGlobalOptionSetRequest extends BaseRequest {\r\n /**Global Option Set Definition. */\r\n data: any;\r\n}\r\n\r\nexport interface UpdateGlobalOptionSetRequest extends CreateRelationshipRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false. */\r\n mergeLabels?: boolean;\r\n}\r\n\r\nexport interface DeleteGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetsRequest extends BaseRequest {\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**Use the $filter system query option to set criteria for which entities will be returned. */\r\n filter?: string;\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface RetrieveGlobalOptionSetRequest extends BaseRequest {\r\n /**A Global Option Set MetadataId or Alternate Key (such as LogicalName). */\r\n key: string;\r\n /**Use this parameter to cast the Global Option Set metadata to a specific type. */\r\n castType?: string;\r\n /**An Array(of Strings) representing the $select OData System Query Option to control which attributes will be returned. */\r\n select?: string[];\r\n /**An array of Expand Objects(described below the table) representing the $expand OData System Query Option value to control which related records are also returned. */\r\n expand?: Expand[];\r\n}\r\n\r\nexport interface UploadRequest extends CRUDRequest {\r\n /**Binary Buffer*/\r\n data: Uint8Array | Buffer;\r\n /**Name of the file */\r\n fileName: string;\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**File Field Name */\r\n fieldName: string;\r\n}\r\n\r\nexport interface CsdlMetadataRequest extends BaseRequest {\r\n /**If set to \"true\" the document will include many different kinds of annotations that can be useful. Most annotations are not included by default because they increase the total size of the document. */\r\n addAnnotations?: boolean;\r\n}\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport interface SearchQueryBase {\r\n /**The search parameter value contains the term to be searched for and has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**The default table list searches across all Dataverse search\u2013configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[];\r\n /**Filters are applied while searching data and are specified in standard OData syntax. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Search extends SearchQueryBase {\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string[];\r\n /**Specify true to return the total record count; otherwise false. The default is false. */\r\n returnTotalRecordCount?: boolean;\r\n /**Specifies the number of search results to skip. */\r\n skip?: number;\r\n /**Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n /**Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'. */\r\n searchMode?: SearchMode;\r\n /**The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'. */\r\n searchType?: SearchType;\r\n}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n /**Number of suggestions to retrieve. The default is 5. */\r\n top?: number;\r\n /**A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence. */\r\n orderBy?: string[];\r\n}\r\n\r\nexport interface Autocomplete extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface SearchRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Search;\r\n}\r\n\r\nexport interface SuggestRequest extends BaseRequest {\r\n /**Suggestion query object */\r\n query: Suggest;\r\n}\r\n\r\nexport interface AutocompleteRequest extends BaseRequest {\r\n /**Autocomplete query object */\r\n query: Autocomplete;\r\n}\r\n\r\nexport interface ApiConfig {\r\n /** API Version to use, for example: \"9.2\" or \"1.0\" */\r\n version?: string;\r\n /** API Path, for example: \"data\" or \"search\" */\r\n path?: string;\r\n}\r\n\r\nexport interface AccessToken {\r\n /** Access Token */\r\n accessToken: string;\r\n}\r\n\r\nexport interface Config {\r\n /**The url to Dataverse API server, for example: https://contoso.api.crm.dynamics.com/. It is required when used in Node.js application. */\r\n serverUrl?: string | null;\r\n /**Impersonates a user based on their systemuserid by adding \"MSCRMCallerID\" header. A String representing the GUID value for the Dynamics 365 systemuserid. */\r\n impersonate?: string | null;\r\n /**Impersonates a user based on their Azure Active Directory (AAD) object id by passing that value along with the header \"CallerObjectId\". A String should represent a GUID value. */\r\n impersonateAAD?: string | null;\r\n /**A function that is called when a security token needs to be refreshed. */\r\n onTokenRefresh?: (() => Promise) | null;\r\n /**Sets Prefer header with value \"odata.include-annotations=\" and the specified annotation.Annotations provide additional information about lookups, options sets and other complex attribute types.*/\r\n includeAnnotations?: string | null;\r\n /**Sets the odata.maxpagesize preference value to request the number of entities returned in the response. */\r\n maxPageSize?: number | null;\r\n /**Sets Prefer header request with value \"return=representation\".Use this property to return just created or updated entity in a single request.*/\r\n returnRepresentation?: boolean | null;\r\n /**Indicates whether to use Entity Logical Names instead of Collection Logical Names.*/\r\n useEntityNames?: boolean | null;\r\n /**Sets a number of milliseconds before a request times out. */\r\n timeout?: number | null;\r\n /**Proxy configuration object. */\r\n proxy?: ProxyConfig | null;\r\n /**Configuration object for Dataverse Web API (with path \"data\"). */\r\n dataApi?: ApiConfig;\r\n /**Configuration object for Dataverse Search API (with path \"search\"). */\r\n searchApi?: ApiConfig;\r\n /**Default headers to supply with each request. */\r\n headers?: HeaderCollection;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = {\r\n /**key-value */\r\n [key: string]: string;\r\n};\r\n\r\nexport interface ProxyConfig {\r\n /**Proxy server url */\r\n url: string;\r\n /**Basic authentication credentials */\r\n auth?: {\r\n /**Username */\r\n username: string;\r\n /**Password */\r\n password: string;\r\n };\r\n}\r\n\r\n/** Callback with an acquired token called by DynamicsWebApi; \"token\" argument can be a string or an object with a property {accessToken: } */\r\n// export interface OnTokenAcquiredCallback {\r\n// (token: any): void;\r\n// }\r\n\r\nexport interface RequestError extends Error {\r\n /**The name of the error */\r\n name: string;\r\n /**This code is not related to the http status code and is frequently empty */\r\n code?: string;\r\n /**A message describing the error */\r\n message: string;\r\n /**HTTP status code */\r\n status?: number;\r\n /**HTTP status text. Frequently empty */\r\n statusText?: string;\r\n /**HTTP Response headers */\r\n headers?: any;\r\n /**Details about an error */\r\n innererror?: {\r\n /**A message describing the error, this is frequently the same as the outer message */\r\n message?: string;\r\n /**Microsoft.Crm.CrmHttpException */\r\n type?: string;\r\n /**Details from the server about where the error occurred */\r\n stacktrace?: string;\r\n };\r\n}\r\n\r\nexport interface MultipleResponse {\r\n /**Multiple respone entities */\r\n value: T[];\r\n oDataCount?: number;\r\n \"@odata.count\"?: number;\r\n oDataContext?: string;\r\n \"@odata.context\"?: number;\r\n}\r\n\r\nexport interface AllResponse extends MultipleResponse {\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n}\r\n\r\nexport interface RetrieveMultipleResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**@odata.nextLink value */\r\n oDataNextLink?: string;\r\n /**@odata.deltaLink value */\r\n oDataDeltaLink?: string;\r\n \"@odata.deltaLink\"?: string;\r\n \"@odata.nextLink\"?: string;\r\n}\r\n\r\nexport interface FetchXmlResponse extends MultipleResponse {\r\n \"@Microsoft.Dynamics.CRM.totalrecordcount\"?: number;\r\n \"@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded\"?: boolean;\r\n /**Paging information */\r\n PagingInfo?: {\r\n /**Number of the next page */\r\n nextPage?: number;\r\n /**Next page cookie */\r\n cookie?: string;\r\n };\r\n}\r\n\r\nexport interface DownloadResponse {\r\n /**The name of the file */\r\n fileName: string;\r\n /**File size */\r\n fileSize: number;\r\n /**File Data */\r\n data: Uint8Array | Buffer;\r\n}\r\n\r\nexport interface SearchResponse {\r\n /**Search results*/\r\n value: TValue[];\r\n facets: any | null;\r\n totalrecordcount: number;\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface SuggestResponseValue {\r\n text: string;\r\n document: TDocument;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**Suggestions*/\r\n value: SuggestResponseValue[];\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**Autocomplete result*/\r\n value: string | null;\r\n querycontext: any | null;\r\n}\r\n\r\n//function overloads\r\n\r\ntype CallFunction = {\r\n /**\r\n * Calls a Web API function\r\n *\r\n * @param name - The name of a function.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (name: string): Promise;\r\n /**\r\n * Calls a bound Web API function\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundFunctionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API function (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundFunctionRequest): Promise;\r\n};\r\n\r\ntype CallAction = {\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {T} Type of the value in a response\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n /**\r\n * Calls a bound Web API action (bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: BoundActionRequest): Promise;\r\n /**\r\n * Calls an unbound Web API action (not bound to a particular table row)\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @type {TResponse} Type of the value in a response\r\n * @type {TAction} Type of an action object\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n (request: UnboundActionRequest): Promise;\r\n};\r\n\r\ntype SearchFunction = {\r\n /**\r\n * Provides a search results page.\r\n * @param term - The term to be searched for and has a max 100-character limit.\r\n * @returns {Promise} Search result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides a search results page.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Search result\r\n */\r\n (request: SearchRequest): Promise>;\r\n};\r\n\r\ntype SuggestFunction = {\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param term - The term to be searched for and has min 3 characters to a max 100-character limit.\r\n * @returns {Promise} Suggestions result\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides suggestions as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise>} Suggestions result\r\n */\r\n (request: SuggestRequest): Promise>;\r\n};\r\n\r\ntype AutocompleteFunction = {\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param term - The term to be searched for and has a 100-character limit.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (term: string): Promise;\r\n /**\r\n * Provides autocompletion of input as the user enters text into a form field.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Result of autocomplete\r\n */\r\n (request: AutocompleteRequest): Promise;\r\n};\r\n", "import { Utility } from \"../utils/Utility\";\r\nimport { InternalConfig } from \"../utils/Config\";\r\nimport { RequestUtility } from \"../utils/Request\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { AccessToken } from \"../dynamics-web-api\";\r\n\r\nconst _addResponseParams = (requestId, responseParams) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId, request) => {\r\n if (_batchRequestCollection[requestId]) _batchRequestCollection[requestId].push(request);\r\n else _batchRequestCollection[requestId] = [request];\r\n};\r\n\r\nconst _clearRequestData = (requestId: string): void => {\r\n delete _responseParseParams[requestId];\r\n if (_batchRequestCollection.hasOwnProperty(requestId)) delete _batchRequestCollection[requestId];\r\n};\r\n\r\nconst _runRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n try {\r\n const result = await RequestClient.sendRequest(request, config);\r\n _clearRequestData(request.requestId!);\r\n\r\n return result;\r\n } catch (error) {\r\n _clearRequestData(request.requestId!);\r\n throw error;\r\n } finally {\r\n _clearRequestData(request.requestId!);\r\n }\r\n};\r\n\r\nlet _batchRequestCollection: Core.BatchRequestCollection = {};\r\nlet _responseParseParams: { [key: string]: any[] } = {};\r\n\r\nexport class RequestClient {\r\n /**\r\n * Sends a request to given URL with given parameters\r\n *\r\n * @param {InternalRequest} request - Composed request to D365 Web Api\r\n * @param {InternalConfig} config - DynamicsWebApi config.\r\n */\r\n static async sendRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || Utility.generateUUID();\r\n\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n\r\n //stringify passed data\r\n let processedData = null;\r\n\r\n const isBatchConverted = request.responseParameters?.convertedToBatch;\r\n\r\n if (request.path === \"$batch\" && !isBatchConverted) {\r\n const batchRequest = _batchRequestCollection[request.requestId];\r\n\r\n if (!batchRequest) throw ErrorHelper.batchIsEmpty();\r\n\r\n const batchResult = RequestUtility.convertToBatch(batchRequest, config, request);\r\n\r\n processedData = batchResult.body;\r\n request.headers = { ...batchResult.headers, ...request.headers };\r\n\r\n //clear an array of requests\r\n delete _batchRequestCollection[request.requestId];\r\n } else {\r\n processedData = !isBatchConverted ? RequestUtility.processData(request.data, config) : request.data;\r\n\r\n if (!isBatchConverted) request.headers = RequestUtility.setStandardHeaders(request.headers);\r\n }\r\n\r\n if (config.impersonate && !request.headers![\"MSCRMCallerID\"]) {\r\n request.headers![\"MSCRMCallerID\"] = config.impersonate;\r\n }\r\n\r\n if (config.impersonateAAD && !request.headers![\"CallerObjectId\"]) {\r\n request.headers![\"CallerObjectId\"] = config.impersonateAAD;\r\n }\r\n\r\n let token: AccessToken | string | null = null;\r\n\r\n //call a token refresh callback only if it is set and there is no \"Authorization\" header set yet\r\n if (config.onTokenRefresh && (!request.headers || (request.headers && !request.headers[\"Authorization\"]))) {\r\n token = await config.onTokenRefresh();\r\n if (!token) throw new Error(\"Token is empty. Request is aborted.\");\r\n }\r\n\r\n if (token) {\r\n request.headers![\"Authorization\"] = \"Bearer \" + (token.hasOwnProperty(\"accessToken\") ? (token as AccessToken).accessToken : token);\r\n }\r\n\r\n if (Utility.isRunningWithinPortals()) {\r\n request.headers![\"__RequestVerificationToken\"] = await global.window.shell!.getTokenDeferred();\r\n }\r\n\r\n const url = request.apiConfig ? request.apiConfig.url : config.dataApi.url;\r\n\r\n return await executeRequest({\r\n method: request.method!,\r\n uri: url!.toString() + request.path,\r\n data: processedData,\r\n additionalHeaders: request.headers,\r\n responseParams: _responseParseParams,\r\n isAsync: request.async,\r\n timeout: request.timeout || config.timeout,\r\n proxy: config.proxy,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n });\r\n }\r\n\r\n private static async _getCollectionNames(entityName: string, config: InternalConfig): Promise {\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = RequestUtility.compose(\r\n {\r\n method: \"GET\",\r\n collection: \"EntityDefinitions\",\r\n select: [\"EntitySetName\", \"LogicalName\"],\r\n noCache: true,\r\n functionName: \"retrieveMultiple\",\r\n },\r\n config\r\n );\r\n\r\n const result = await _runRequest(request, config);\r\n RequestUtility.entityNames = {};\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n RequestUtility.entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return RequestUtility.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n private static _isEntityNameException(entityName: string): boolean {\r\n const exceptions = [\r\n \"$metadata\",\r\n \"EntityDefinitions\",\r\n \"RelationshipDefinitions\",\r\n \"GlobalOptionSetDefinitions\",\r\n \"ManagedPropertyDefinitions\",\r\n \"query\",\r\n \"suggest\",\r\n \"autocomplete\",\r\n ];\r\n\r\n return exceptions.indexOf(entityName) > -1;\r\n }\r\n\r\n private static async _checkCollectionName(entityName: string | null | undefined, config: InternalConfig): Promise {\r\n if (!entityName || RequestClient._isEntityNameException(entityName)) {\r\n return entityName;\r\n }\r\n\r\n entityName = entityName.toLowerCase();\r\n\r\n if (!config.useEntityNames) {\r\n return entityName;\r\n }\r\n\r\n try {\r\n return await RequestClient._getCollectionNames(entityName, config);\r\n } catch (error: any) {\r\n throw new Error(\"Unable to fetch Collection Names. Error: \" + (error as DynamicsWebApiError).message);\r\n }\r\n }\r\n\r\n static async makeRequest(request: Core.InternalRequest, config: InternalConfig): Promise {\r\n request.responseParameters = request.responseParameters || {};\r\n //we don't want to mix headers set by the library and by the user\r\n request.userHeaders = request.headers;\r\n delete request.headers;\r\n\r\n if (!request.isBatch) {\r\n const collectionName = await RequestClient._checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n RequestUtility.compose(request, config);\r\n request.responseParameters.convertedToBatch = false;\r\n\r\n //the URL contains more characters than max possible limit, convert the request to a batch request\r\n if (request.path!.length > 2000) {\r\n const batchRequest = RequestUtility.convertToBatch([request], config);\r\n\r\n request.method = \"POST\";\r\n request.path = \"$batch\";\r\n request.data = batchRequest.body;\r\n request.headers = { ...batchRequest.headers, ...request.userHeaders };\r\n request.responseParameters.convertedToBatch = true;\r\n }\r\n\r\n return _runRequest(request, config);\r\n }\r\n\r\n //no need to make a request to web api if it's a part of batch\r\n RequestUtility.compose(request, config);\r\n //add response parameters to parse\r\n _addResponseParams(request.requestId, request.responseParameters);\r\n _addRequestToBatchCollection(request.requestId, request);\r\n }\r\n\r\n static _clearTestData(): void {\r\n RequestUtility.entityNames = null;\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n }\r\n\r\n static getCollectionName(entityName: string): string | null {\r\n return RequestUtility.findCollectionName(entityName);\r\n }\r\n}\r\n", "import { Utility } from \"./Utility\";\r\nimport { Config, HeaderCollection } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { Core } from \"../types\";\r\nimport { InternalConfig } from \"./Config\";\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequestOptions\r\n * @property {string} url URL (without query)\r\n * @property {string} query Query String\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n */\r\n\r\n/**\r\n * @typedef {Object} ConvertedRequest\r\n * @property {string} url URL (including Query String)\r\n * @property {Object} headers Heades object (always an Object; can be empty: {})\r\n * @property {boolean} async\r\n */\r\n\r\nexport class RequestUtility {\r\n /**\r\n * Converts a request object to URL link\r\n *\r\n * @param {Object} request - Request object\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequest} Converted request\r\n */\r\n static compose(request: Core.InternalRequest, config: InternalConfig): Core.InternalRequest {\r\n request.path = request.path || \"\";\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n }\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path = request.collection;\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (request.contentId.startsWith(\"$\")) {\r\n request.path = `${request.contentId}/${request.path}`;\r\n }\r\n }\r\n\r\n //add alternate key feature\r\n if (request.key) {\r\n request.key = ErrorHelper.keyParameterCheck(request.key, `DynamicsWebApi.${request.functionName}`, \"request.key\");\r\n request.path += `(${request.key})`;\r\n }\r\n }\r\n\r\n if (request._additionalUrl) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request._additionalUrl;\r\n }\r\n\r\n request.path = RequestUtility.composeUrl(request, config, request.path);\r\n\r\n if (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n let join = request.path.indexOf(\"?\") === -1 ? \"?\" : \"&\";\r\n request.path += `${join}fetchXml=${encodeURIComponent(request.fetchXml)}`;\r\n }\r\n } else {\r\n ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, \"request.url\");\r\n request.path = request.url.replace(config.dataApi.url, \"\");\r\n }\r\n\r\n if (request.hasOwnProperty(\"async\") && request.async != null) {\r\n ErrorHelper.boolParameterCheck(request.async, `DynamicsWebApi.${request.functionName}`, \"request.async\");\r\n } else {\r\n request.async = true;\r\n }\r\n\r\n request.headers = RequestUtility.composeHeaders(request, config);\r\n\r\n return request;\r\n }\r\n\r\n /**\r\n * Converts optional parameters of the request to URL. If expand parameter exists this function is called recursively.\r\n *\r\n * @param {Object} request - Request object\r\n * @param {string} request.functionName - Name of the function that converts a request (for Error Handling)\r\n * @param {string} url - URL beginning (with required parameters)\r\n * @param {string} [joinSymbol] - URL beginning (with required parameters)\r\n * @param {Object} [config] - DynamicsWebApi config\r\n * @returns {ConvertedRequestOptions} Additional options in request\r\n */\r\n static composeUrl(request: Core.InternalRequest, config: Config, url: string = \"\", joinSymbol: string = \"&\"): string {\r\n const queryArray: string[] = [];\r\n\r\n if (request) {\r\n if (request.navigationProperty) {\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, `DynamicsWebApi.${request.functionName}`, \"request.navigationProperty\");\r\n url += \"/\" + request.navigationProperty;\r\n\r\n if (request.navigationPropertyKey) {\r\n let navigationKey = ErrorHelper.keyParameterCheck(\r\n request.navigationPropertyKey,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.navigationPropertyKey\"\r\n );\r\n url += \"(\" + navigationKey + \")\";\r\n }\r\n\r\n if (request.navigationProperty === \"Attributes\") {\r\n if (request.metadataAttributeType) {\r\n ErrorHelper.stringParameterCheck(\r\n request.metadataAttributeType,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.metadataAttributeType\"\r\n );\r\n url += \"/\" + request.metadataAttributeType;\r\n }\r\n }\r\n }\r\n\r\n if (request.select?.length) {\r\n ErrorHelper.arrayParameterCheck(request.select, `DynamicsWebApi.${request.functionName}`, \"request.select\");\r\n\r\n if (request.functionName == \"retrieve\" && request.select.length == 1 && request.select[0].endsWith(\"/$ref\")) {\r\n url += \"/\" + request.select[0];\r\n } else {\r\n if (request.select[0].startsWith(\"/\") && request.functionName == \"retrieve\") {\r\n if (request.navigationProperty == null) {\r\n url += request.select.shift();\r\n } else {\r\n request.select.shift();\r\n }\r\n }\r\n\r\n //check if anything left in the array\r\n if (request.select.length) {\r\n queryArray.push(\"$select=\" + request.select.join(\",\"));\r\n }\r\n }\r\n }\r\n\r\n if (request.filter) {\r\n ErrorHelper.stringParameterCheck(request.filter, `DynamicsWebApi.${request.functionName}`, \"request.filter\");\r\n const removeBracketsFromGuidReg = /[^\"']{([\\w\\d]{8}[-]?(?:[\\w\\d]{4}[-]?){3}[\\w\\d]{12})}(?:[^\"']|$)/g;\r\n let filterResult = request.filter;\r\n\r\n //fix bug 2018-06-11\r\n let m: RegExpExecArray | null = null;\r\n while ((m = removeBracketsFromGuidReg.exec(filterResult)) !== null) {\r\n if (m.index === removeBracketsFromGuidReg.lastIndex) {\r\n removeBracketsFromGuidReg.lastIndex++;\r\n }\r\n\r\n let replacement = m[0].endsWith(\")\") ? \")\" : \" \";\r\n filterResult = filterResult.replace(m[0], \" \" + m[1] + replacement);\r\n }\r\n\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n url += \"/\" + request.fieldName;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\r\n \"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\")\r\n );\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\r\n \"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\")\r\n );\r\n }\r\n\r\n if (request.apply) {\r\n ErrorHelper.stringParameterCheck(request.apply, `DynamicsWebApi.${request.functionName}`, \"request.apply\");\r\n queryArray.push(\"$apply=\" + request.apply);\r\n }\r\n\r\n if (request.count) {\r\n ErrorHelper.boolParameterCheck(request.count, `DynamicsWebApi.${request.functionName}`, \"request.count\");\r\n queryArray.push(\"$count=\" + request.count);\r\n }\r\n\r\n if (request.top && request.top > 0) {\r\n ErrorHelper.numberParameterCheck(request.top, `DynamicsWebApi.${request.functionName}`, \"request.top\");\r\n queryArray.push(\"$top=\" + request.top);\r\n }\r\n\r\n if (request.orderBy != null && request.orderBy.length) {\r\n ErrorHelper.arrayParameterCheck(request.orderBy, `DynamicsWebApi.${request.functionName}`, \"request.orderBy\");\r\n queryArray.push(\"$orderby=\" + request.orderBy.join(\",\"));\r\n }\r\n\r\n if (request.partitionId) {\r\n ErrorHelper.stringParameterCheck(request.partitionId, `DynamicsWebApi.${request.functionName}`, \"request.partitionId\");\r\n queryArray.push(\"partitionid='\" + request.partitionId + \"'\");\r\n }\r\n\r\n if (request.downloadSize) {\r\n ErrorHelper.stringParameterCheck(request.downloadSize, `DynamicsWebApi.${request.functionName}`, \"request.downloadSize\");\r\n queryArray.push(\"size=\" + request.downloadSize);\r\n }\r\n\r\n if (request.queryParams?.length) {\r\n ErrorHelper.arrayParameterCheck(request.queryParams, `DynamicsWebApi.${request.functionName}`, \"request.queryParams\");\r\n queryArray.push(request.queryParams.join(\"&\"));\r\n }\r\n\r\n if (request.fileName) {\r\n ErrorHelper.stringParameterCheck(request.fileName, `DynamicsWebApi.${request.functionName}`, \"request.fileName\");\r\n queryArray.push(\"x-ms-file-name=\" + request.fileName);\r\n }\r\n\r\n if (request.data) {\r\n ErrorHelper.parameterCheck(request.data, `DynamicsWebApi.${request.functionName}`, \"request.data\");\r\n }\r\n\r\n if (request.isBatch) {\r\n ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, \"request.isBatch\");\r\n }\r\n\r\n if (!Utility.isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;\r\n\r\n if (request.timeout) {\r\n ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, \"request.timeout\");\r\n }\r\n\r\n if (request.expand?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.expand, `DynamicsWebApi.${request.functionName}`, \"request.expand\");\r\n if (typeof request.expand === \"string\") {\r\n queryArray.push(\"$expand=\" + request.expand);\r\n } else {\r\n const expandQueryArray: string[] = [];\r\n for (let i = 0; i < request.expand.length; i++) {\r\n if (request.expand[i].property) {\r\n const expand = request.expand[i];\r\n expand.functionName = `${request.functionName} $expand`;\r\n let expandConverted = RequestUtility.composeUrl(expand, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted.substr(1)})`;\r\n }\r\n expandQueryArray.push(request.expand[i].property + expandConverted);\r\n }\r\n }\r\n if (expandQueryArray.length) {\r\n queryArray.push(\"$expand=\" + expandQueryArray.join(\",\"));\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n }\r\n\r\n static composeHeaders(request: Core.InternalRequest, config: Config): HeaderCollection {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = RequestUtility.composePreferHeader(request, config);\r\n if (prefer.length) {\r\n headers[\"Prefer\"] = prefer;\r\n }\r\n\r\n if (request.collection === \"$metadata\") {\r\n headers[\"Accept\"] = \"application/xml\";\r\n }\r\n\r\n if (request.transferMode) {\r\n headers[\"x-ms-transfer-mode\"] = request.transferMode;\r\n }\r\n\r\n if (request.ifmatch != null && request.ifnonematch != null) {\r\n throw new Error(\r\n `DynamicsWebApi.${request.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`\r\n );\r\n }\r\n\r\n if (request.ifmatch) {\r\n ErrorHelper.stringParameterCheck(request.ifmatch, `DynamicsWebApi.${request.functionName}`, \"request.ifmatch\");\r\n headers[\"If-Match\"] = request.ifmatch;\r\n }\r\n\r\n if (request.ifnonematch) {\r\n ErrorHelper.stringParameterCheck(request.ifnonematch, `DynamicsWebApi.${request.functionName}`, \"request.ifnonematch\");\r\n headers[\"If-None-Match\"] = request.ifnonematch;\r\n }\r\n\r\n if (request.impersonate) {\r\n ErrorHelper.stringParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n headers[\"MSCRMCallerID\"] = ErrorHelper.guidParameterCheck(request.impersonate, `DynamicsWebApi.${request.functionName}`, \"request.impersonate\");\r\n }\r\n\r\n if (request.impersonateAAD) {\r\n ErrorHelper.stringParameterCheck(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\r\n headers[\"CallerObjectId\"] = ErrorHelper.guidParameterCheck(\r\n request.impersonateAAD,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.impersonateAAD\"\r\n );\r\n }\r\n\r\n if (request.token) {\r\n ErrorHelper.stringParameterCheck(request.token, `DynamicsWebApi.${request.functionName}`, \"request.token\");\r\n headers[\"Authorization\"] = \"Bearer \" + request.token;\r\n }\r\n\r\n if (request.duplicateDetection) {\r\n ErrorHelper.boolParameterCheck(request.duplicateDetection, `DynamicsWebApi.${request.functionName}`, \"request.duplicateDetection\");\r\n headers[\"MSCRM.SuppressDuplicateDetection\"] = \"false\";\r\n }\r\n\r\n if (request.bypassCustomPluginExecution) {\r\n ErrorHelper.boolParameterCheck(\r\n request.bypassCustomPluginExecution,\r\n `DynamicsWebApi.${request.functionName}`,\r\n \"request.bypassCustomPluginExecution\"\r\n );\r\n headers[\"MSCRM.BypassCustomPluginExecution\"] = \"true\";\r\n }\r\n\r\n if (request.noCache) {\r\n ErrorHelper.boolParameterCheck(request.noCache, `DynamicsWebApi.${request.functionName}`, \"request.noCache\");\r\n headers[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (request.mergeLabels) {\r\n ErrorHelper.boolParameterCheck(request.mergeLabels, `DynamicsWebApi.${request.functionName}`, \"request.mergeLabels\");\r\n headers[\"MSCRM.MergeLabels\"] = \"true\";\r\n }\r\n\r\n if (request.contentId) {\r\n ErrorHelper.stringParameterCheck(request.contentId, `DynamicsWebApi.${request.functionName}`, \"request.contentId\");\r\n if (!request.contentId.startsWith(\"$\")) {\r\n headers[\"Content-ID\"] = request.contentId;\r\n }\r\n }\r\n\r\n if (request.contentRange) {\r\n ErrorHelper.stringParameterCheck(request.contentRange, `DynamicsWebApi.${request.functionName}`, \"request.contentRange\");\r\n headers[\"Content-Range\"] = request.contentRange;\r\n }\r\n\r\n if (request.range) {\r\n ErrorHelper.stringParameterCheck(request.range, `DynamicsWebApi.${request.functionName}`, \"request.range\");\r\n headers[\"Range\"] = request.range;\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n static composePreferHeader(request: Core.InternalRequest, config: Config): string {\r\n let returnRepresentation: boolean | null | undefined = request.returnRepresentation;\r\n let includeAnnotations: string | null | undefined = request.includeAnnotations;\r\n let maxPageSize: number | null | undefined = request.maxPageSize;\r\n let trackChanges: boolean | null | undefined = request.trackChanges;\r\n let continueOnError: boolean | null | undefined = request.continueOnError;\r\n\r\n let prefer: string[] = [];\r\n\r\n if (request.prefer && request.prefer.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, `DynamicsWebApi.${request.functionName}`, \"request.prefer\");\r\n if (typeof request.prefer === \"string\") {\r\n prefer = request.prefer.split(\",\");\r\n }\r\n for (let i in prefer) {\r\n let item = prefer[i].trim();\r\n if (item === \"return=representation\") {\r\n returnRepresentation = true;\r\n } else if (item.includes(\"odata.include-annotations=\")) {\r\n includeAnnotations = item.replace(\"odata.include-annotations=\", \"\").replace(/\"/g, \"\");\r\n } else if (item.startsWith(\"odata.maxpagesize=\")) {\r\n maxPageSize = Number(item.replace(\"odata.maxpagesize=\", \"\").replace(/\"/g, \"\")) || 0;\r\n } else if (item.includes(\"odata.track-changes\")) {\r\n trackChanges = true;\r\n } else if (item.includes(\"odata.continue-on-error\")) {\r\n continueOnError = true;\r\n }\r\n }\r\n }\r\n\r\n //clear array\r\n prefer = [];\r\n\r\n if (config) {\r\n if (returnRepresentation == null) {\r\n returnRepresentation = config.returnRepresentation;\r\n }\r\n includeAnnotations = includeAnnotations ? includeAnnotations : config.includeAnnotations;\r\n maxPageSize = maxPageSize ? maxPageSize : config.maxPageSize;\r\n }\r\n\r\n if (returnRepresentation) {\r\n ErrorHelper.boolParameterCheck(returnRepresentation, `DynamicsWebApi.${request.functionName}`, \"request.returnRepresentation\");\r\n prefer.push(\"return=representation\");\r\n }\r\n\r\n if (includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(includeAnnotations, `DynamicsWebApi.${request.functionName}`, \"request.includeAnnotations\");\r\n prefer.push(`odata.include-annotations=\"${includeAnnotations}\"`);\r\n }\r\n\r\n if (maxPageSize && maxPageSize > 0) {\r\n ErrorHelper.numberParameterCheck(maxPageSize, `DynamicsWebApi.${request.functionName}`, \"request.maxPageSize\");\r\n prefer.push(\"odata.maxpagesize=\" + maxPageSize);\r\n }\r\n\r\n if (trackChanges) {\r\n ErrorHelper.boolParameterCheck(trackChanges, `DynamicsWebApi.${request.functionName}`, \"request.trackChanges\");\r\n prefer.push(\"odata.track-changes\");\r\n }\r\n\r\n if (continueOnError) {\r\n ErrorHelper.boolParameterCheck(continueOnError, `DynamicsWebApi.${request.functionName}`, \"request.continueOnError\");\r\n prefer.push(\"odata.continue-on-error\");\r\n }\r\n\r\n return prefer.join(\",\");\r\n }\r\n\r\n static convertToBatch(requests: Core.InternalRequest[], config: InternalConfig, batchRequest?: Core.InternalRequest): Core.InternalBatchRequest {\r\n const batchBoundary = `dwa_batch_${Utility.generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n requests.forEach((internalRequest) => {\r\n internalRequest.functionName = \"executeBatch\";\r\n if (batchRequest?.inChangeSet === false) internalRequest.inChangeSet = false;\r\n const inChangeSet = internalRequest.method === \"GET\" ? false : !!internalRequest.inChangeSet;\r\n\r\n if (!inChangeSet && currentChangeSet) {\r\n //end current change set\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${Utility.generateUUID()}`;\r\n batchBody.push(\"Content-Type: multipart/mixed;boundary=\" + currentChangeSet);\r\n }\r\n }\r\n\r\n if (inChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}`);\r\n }\r\n\r\n batchBody.push(\"Content-Type: application/http\");\r\n batchBody.push(\"Content-Transfer-Encoding: binary\");\r\n\r\n if (inChangeSet) {\r\n const contentIdValue = internalRequest.headers!.hasOwnProperty(\"Content-ID\") ? internalRequest.headers![\"Content-ID\"] : ++contentId;\r\n\r\n batchBody.push(`Content-ID: ${contentIdValue}`);\r\n }\r\n\r\n if (!internalRequest.path?.startsWith(\"$\")) {\r\n batchBody.push(`\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);\r\n }\r\n\r\n if (internalRequest.method === \"GET\") {\r\n batchBody.push(\"Accept: application/json\");\r\n } else {\r\n batchBody.push(\"Content-Type: application/json\");\r\n }\r\n\r\n for (let key in internalRequest.headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n\r\n batchBody.push(`${key}: ${internalRequest.headers[key]}`);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\n${RequestUtility.processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\n--${batchBoundary}--`);\r\n\r\n const headers = RequestUtility.setStandardHeaders(batchRequest?.userHeaders);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\n\") };\r\n }\r\n\r\n static entityNames: any = null;\r\n\r\n static findCollectionName(entityName: string): string | null {\r\n let collectionName = null;\r\n\r\n if (!Utility.isNull(RequestUtility.entityNames)) {\r\n collectionName = RequestUtility.entityNames[entityName];\r\n if (Utility.isNull(collectionName)) {\r\n for (let key in RequestUtility.entityNames) {\r\n if (RequestUtility.entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n }\r\n\r\n static processData(data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null {\r\n let stringifiedData: string | null = null;\r\n if (data) {\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key.endsWith(\"@odata.bind\") || key.endsWith(\"@odata.id\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n //remove brackets in guid\r\n if (/\\(\\{[\\w\\d-]+\\}\\)/g.test(value)) {\r\n value = value.replace(/(.+)\\(\\{([\\w\\d-]+)\\}\\)/g, \"$1($2)\");\r\n }\r\n\r\n if (config.useEntityNames) {\r\n //replace entity name with collection name\r\n const regularExpression = /([\\w_]+)(\\([\\d\\w-]+\\))$/;\r\n const valueParts = regularExpression.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = RequestUtility.findCollectionName(valueParts[1]);\r\n\r\n if (!Utility.isNull(collectionName)) {\r\n value = value.replace(regularExpression, collectionName + \"$2\");\r\n }\r\n }\r\n }\r\n\r\n if (!value.startsWith(config.dataApi.url)) {\r\n //add full web api url if it's not set\r\n if (key.endsWith(\"@odata.bind\")) {\r\n if (!value.startsWith(\"/\")) {\r\n value = \"/\" + value;\r\n }\r\n } else {\r\n value = config.dataApi.url + value.replace(/^\\//, \"\");\r\n }\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n value = undefined;\r\n }\r\n\r\n return value;\r\n });\r\n\r\n stringifiedData = stringifiedData.replace(/[\\u007F-\\uFFFF]/g, function (chr: string) {\r\n return \"\\\\u\" + (\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4);\r\n });\r\n }\r\n\r\n return stringifiedData;\r\n }\r\n\r\n static setStandardHeaders(headers: HeaderCollection = {}): any {\r\n if (!headers[\"Accept\"]) headers[\"Accept\"] = \"application/json\";\r\n if (!headers[\"OData-MaxVersion\"]) headers[\"OData-MaxVersion\"] = \"4.0\";\r\n if (!headers[\"OData-Version\"]) headers[\"OData-Version\"] = \"4.0\";\r\n if (headers[\"Content-Range\"]) headers[\"Content-Type\"] = \"application/octet-stream\";\r\n else if (!headers[\"Content-Type\"]) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n }\r\n}\r\n", "import { Core } from \"../../types\";\r\n\r\nexport async function executeRequest(options: Core.RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAEA,OAAO,aAAa;AAEb,SAAS,YAAa;AACzB,SAAO;AACX;AANA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAASA,aAAwB;AACpC,SAAO,QAAqB,OAAO,OAAO,SAAS,0CAAyB,UAAU;AAC1F;AAEO,SAAS,sBAAsB;AAClC,SAAO,QAAqBA,WAAU,EAAE,gBAAgB,IAAI,WAAW,CAAC,CAAC,IAAIA,WAAU,EAAE,YAAY,CAAC;AAC1G;AANA;AAAA;AAAA;AAAA;AAAA;;;ACEO,SAAS,OAAO,OAAwB;AAC3C,QAAM,QAAQ,IAAI,OAAO,MAAM,GAAG,EAAE,KAAK,KAAK;AAC9C,SAAO,CAAC,CAAC;AACb;AAEO,SAAS,YAAY,OAA8B;AACtD,QAAM,QAAQ,IAAI,OAAO,SAAS,OAAO,QAAQ,GAAG,EAAE,KAAK,KAAK;AAChE,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,mBAAmB,KAA4B;AAC3D,QAAM,QAAQ,IAAI,OAAO,MAAM,OAAO,SAAS,GAAG,EAAE,KAAK,GAAG;AAC5D,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAfA,IAAM;AAAN;AAAA;AAAA;AAAA,IAAM,OAAO;AAAA;AAAA;;;ACAb,IAgBM,mBAEO;AAlBb;AAAA;AAAA;AACA;AACA;AAcA,IAAM,oBAAoB;AAEnB,IAAM,WAAN,MAAM,SAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOjB,OAAO,wBAAwB,YAA0B;AACrD,YAAI,YAAY;AACZ,gBAAM,iBAAiB,OAAO,K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AAEzH,sBAAgB,eAAe,gBAAgB,aAAa;AAC5D,sBAAgB,SAAS;AACzB,sBAAgB,OAAO,gBAAgB;AACvC,sBAAgB,YAAY,KAAK,QAAQ;AAEzC,aAAO,gBAAgB;AAEvB,YAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,aAAO,qCAAU;AAAA,IACrB;AAKA;AAAA;AAAA;AAAA,sBAAa,MAAY;AACrB,WAAK,WAAW;AAChB,WAAK,kBAAkB,QAAQ,aAAa;AAAA,IAChD;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe,OAAO,YAA2C;AAC7D,kBAAY,qBAAqB,KAAK,QAAQ;AAE9C,YAAM,kBAAwC,CAAC,UAAU,CAAC,IAAI,QAAQ,YAAY,OAAO;AAEzF,sBAAgB,aAAa;AAC7B,sBAAgB,SAAS;AACzB,sBAAgB,eAAe;AAC/B,sBAAgB,YAAY,KAAK;AAEjC,WAAK,kBAAkB;AACvB,WAAK,WAAW;AAEhB,YAAM,WAAW,MAAM,KAAK,aAAa,eAAe;AACxD,aAAO,qCAAU;AAAA,IACrB;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,KAAK,OAAO;AAEnG,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,cAAc,kBAAkB,UAAU;AAAA,IACxG;AArnCI,yBAAqB,MAAM,KAAK,SAAS,MAAM;AAAA,EACnD;AAqnCJ;", + "names": ["getCrypto", "_a", "_a", "_b", "executeRequest", "_a", "executeRequest", "_a", "request"] } diff --git a/package.json b/package.json index 580fd22..6fda2a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dynamics-web-api", - "version": "2.1.1", + "version": "2.1.2", "description": "DynamicsWebApi is a Microsoft Dynamics CRM Web API helper library", "keywords": [ "d365", diff --git a/src/client/RequestClient.ts b/src/client/RequestClient.ts index 2448c52..c7590df 100644 --- a/src/client/RequestClient.ts +++ b/src/client/RequestClient.ts @@ -104,7 +104,7 @@ export class RequestClient { return await executeRequest({ method: request.method!, - uri: url + request.path, + uri: url!.toString() + request.path, data: processedData, additionalHeaders: request.headers, responseParams: _responseParseParams, diff --git a/src/client/http.ts b/src/client/http.ts index b242296..93f4335 100644 --- a/src/client/http.ts +++ b/src/client/http.ts @@ -1,6 +1,5 @@ import * as http from "http"; import * as https from "https"; -import * as url from "url"; import HttpProxyAgent from "http-proxy-agent"; import HttpsProxyAgent from "https-proxy-agent"; import { Core } from "../types"; @@ -75,14 +74,14 @@ function _executeRequest( for (let key in additionalHeaders) { headers[key] = additionalHeaders[key]; } - const parsedUrl = url.parse(options.uri); + const parsedUrl = new URL(options.uri); const protocol = parsedUrl.protocol?.slice(0, -1) || "https"; const protocolInterface = protocol === "http" ? http : https; const internalOptions: http.RequestOptions = { hostname: parsedUrl.hostname, port: parsedUrl.port, - path: parsedUrl.path, + path: parsedUrl.pathname + parsedUrl.search, method: options.method, timeout: options.timeout || 0, headers: headers, @@ -99,7 +98,7 @@ function _executeRequest( internalOptions.agent = getAgent(options, protocol); if (options.proxy) { - const hostHeader =new URL(options.proxy.url).host; + const hostHeader = new URL(options.proxy.url).host; if (hostHeader) headers.host = hostHeader; } diff --git a/src/dynamics-web-api.ts b/src/dynamics-web-api.ts index cc127bd..0b179e0 100644 --- a/src/dynamics-web-api.ts +++ b/src/dynamics-web-api.ts @@ -1143,10 +1143,10 @@ export class DynamicsWebApi { }; /** - * Creates a new instance of DynamicsWebApi. If the config is not provided, it is copied from the current instance. + * Creates a new instance of DynamicsWebApi. If config is not provided, it is copied from a current instance. * - * @param {Config} config - configuration object. - * @returns {DynamicsWebApi} The new instance of a DynamicsWebApi + * @param {Config} config configuration object. + * @returns {DynamicsWebApi} A new instance of DynamicsWebApi */ initializeInstance = (config?: Config): DynamicsWebApi => new DynamicsWebApi(config || this._config); @@ -1155,8 +1155,8 @@ export class DynamicsWebApi { * Searches for a collection name by provided entity name in a cached entity metadata. * The returned collection name can be null. * - * @param {string} entityName - entity name - * @returns {string | null} a collection name + * @param {string} entityName entity name + * @returns {string | null} collection name */ getCollectionName: (entityName: string): string | null => RequestClient.getCollectionName(entityName), }; @@ -1760,7 +1760,9 @@ export interface MultipleResponse { /**Multiple respone entities */ value: T[]; oDataCount?: number; + "@odata.count"?: number; oDataContext?: string; + "@odata.context"?: number; } export interface AllResponse extends MultipleResponse { @@ -1775,6 +1777,8 @@ export interface RetrieveMultipleResponse extends MultipleResponse { oDataNextLink?: string; /**@odata.deltaLink value */ oDataDeltaLink?: string; + "@odata.deltaLink"?: string; + "@odata.nextLink"?: string; } export interface FetchXmlResponse extends MultipleResponse { diff --git a/src/utils/Config.ts b/src/utils/Config.ts index bb985a9..df86038 100644 --- a/src/utils/Config.ts +++ b/src/utils/Config.ts @@ -15,10 +15,10 @@ export interface InternalConfig extends Config { const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => { if (Utility.isRunningWithinPortals()) { - return `${global.window.location.origin}/_api/`; + return new URL("_api", global.window.location.origin).toString() + "/"; } else { if (!serverUrl) serverUrl = Utility.getClientUrl(); - return `${serverUrl}/api/${apiConfig.path}/v${apiConfig.version}/`; + return new URL(`api/${apiConfig.path}/v${apiConfig.version}`, serverUrl).toString() + "/"; } }; @@ -122,12 +122,12 @@ export class ConfigurationUtility { dataApi: { path: "data", version: "9.2", - url: "", + url: "" }, searchApi: { path: "search", version: "1.0", - url: "", + url: "" }, }; } diff --git a/src/utils/Request.ts b/src/utils/Request.ts index 36a1d32..73cdd45 100644 --- a/src/utils/Request.ts +++ b/src/utils/Request.ts @@ -68,7 +68,6 @@ export class RequestUtility { } else { ErrorHelper.stringParameterCheck(request.url, `DynamicsWebApi.${request.functionName}`, "request.url"); request.path = request.url.replace(config.dataApi.url, ""); - request.path = RequestUtility.composeUrl(request, config, request.path); } if (request.hasOwnProperty("async") && request.async != null) { diff --git a/tests/main.spec.js b/tests/main.spec.js index af05a52..d2fd090 100644 --- a/tests/main.spec.js +++ b/tests/main.spec.js @@ -646,7 +646,7 @@ describe("dynamicsWebApi.retrieve -", function () { before(function () { var response = mocks.responses.response200; scope = nock(mocks.webApiUrl) - .get(mocks.responses.collectionUrl + "(alternateKey=%27keyValue%27)") + .get(mocks.responses.collectionUrl + "(alternateKey='keyValue')") .reply(response.status, response.responseText, response.responseHeaders); }); @@ -3463,7 +3463,7 @@ describe("dynamicsWebApi.retrieveEntity -", function () { before(function () { var response = mocks.responses.response200; scope = nock(mocks.webApiUrl) - .get(mocks.responses.entityDefinitionsUrl + "(alternateKey=%27keyValue%27)") + .get(mocks.responses.entityDefinitionsUrl + "(alternateKey='keyValue')") .reply(response.status, response.responseText, response.responseHeaders); }); @@ -3838,7 +3838,7 @@ describe("dynamicsWebApi.retrieveAttribute -", function () { before(function () { var response = mocks.responses.response200; scope = nock(mocks.webApiUrl) - .get(mocks.responses.entityDefinitionsUrl + "(SchemaName=%27Test%27)/Attributes(LogicalName=%27Test2%27)") + .get(mocks.responses.entityDefinitionsUrl + "(SchemaName='Test')/Attributes(LogicalName='Test2')") .reply(response.status, response.responseText, response.responseHeaders); }); diff --git a/tests/main.spec.ts b/tests/main.spec.ts index cb79c4b..6a9a363 100644 --- a/tests/main.spec.ts +++ b/tests/main.spec.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import nock from "nock"; import * as mocks from "./stubs"; -import { DynamicsWebApi } from "../src/dynamics-web-api"; +import { DynamicsWebApi, type RetrieveMultipleRequest } from "../src/dynamics-web-api"; const dynamicsWebApiTest = new DynamicsWebApi({ dataApi: { @@ -68,6 +68,115 @@ describe("dynamicsWebApi.retrieveMultiple -", () => { expect(scope2.isDone()).to.be.true; }); }); + describe("when goes by next page link with count", () => { + let scope: nock.Scope; + before(function () { + const response = mocks.responses.multipleWithLinkAndCountResponse; + const url = new URL(mocks.responses.multipleWithLinkAndCount().oDataNextLink); + scope = nock(url.origin, { + reqheaders: { + prefer: "odata.maxpagesize=10" + } + }) + .get(url.pathname + url.search) + .reply((uri, body) => { + const checkUrl = new URL(uri, url.origin); + if ((checkUrl.pathname + checkUrl.search) !== (url.pathname + url.search)) + return + [ + mocks.responses.errorResponse.status, + mocks.responses.errorResponse.responseText, + mocks.responses.errorResponse.responseHeaders + ]; + + return [response.status, response.responseText, response.responseHeaders] + }); + }); + + after(function () { + nock.cleanAll(); + }); + + it("should not have duplicated url params", async () => { + const dwaRequest: RetrieveMultipleRequest = { + collection: "tests", + select: ["name"], + count: true, + maxPageSize: 10 + }; + + try{ + const object = await dynamicsWebApiTest.retrieveMultiple(dwaRequest, mocks.responses.multipleWithLinkAndCount().oDataNextLink) + + expect(object).to.deep.equal(mocks.responses.multipleWithLinkAndCount()); + } + catch(error){ + console.error(error); + throw error; + } + }); + + it("all requests have been made", function () { + expect(scope.isDone()).to.be.true; + }); + }); + + describe("when goes by next page link, with a dash in serverUrl", () => { + let scope: nock.Scope; + before(function () { + const response = mocks.responses.multipleWithLinkAndCountResponse; + const url = new URL(mocks.responses.multipleWithLinkAndCount().oDataNextLink); + scope = nock(url.origin, { + reqheaders: { + prefer: "odata.maxpagesize=10" + } + }) + .get(url.pathname + url.search) + .reply((uri, body) => { + const checkUrl = new URL(uri, url.origin); + if ((checkUrl.pathname + checkUrl.search) !== (url.pathname + url.search)) + return + [ + mocks.responses.errorResponse.status, + mocks.responses.errorResponse.responseText, + mocks.responses.errorResponse.responseHeaders + ]; + + return [response.status, response.responseText, response.responseHeaders] + }); + }); + + after(function () { + nock.cleanAll(); + }); + + it("should not duplicate serverUrl", async () => { + const dwaRequest: RetrieveMultipleRequest = { + collection: "tests", + select: ["name"], + count: true, + maxPageSize: 10 + }; + + try{ + const dynamicsWebApiSlash = dynamicsWebApiTest.initializeInstance(); + dynamicsWebApiSlash.setConfig({ + serverUrl: mocks.serverUrl + "/" + }); + const object = await dynamicsWebApiSlash.retrieveMultiple(dwaRequest, mocks.responses.multipleWithLinkAndCount().oDataNextLink) + + expect(object).to.deep.equal(mocks.responses.multipleWithLinkAndCount()); + } + catch(error){ + console.error(error); + throw error; + } + }); + + it("all requests have been made", function () { + expect(scope.isDone()).to.be.true; + }); + }); }); describe("dynamicsWebApi.executeBatch -", () => { diff --git a/tests/stubs.js b/tests/stubs.js index 868e2be..7937e10 100644 --- a/tests/stubs.js +++ b/tests/stubs.js @@ -177,6 +177,17 @@ const dataStubs = { { name: "name2", subject: "subject2" }, ], }, + multipleWithLinkAndCount: { + "@odata.context": "context", + "@odata.count": 10, + "@odata.nextLink": + webApiUrl + + "tests?$select=name&$count=true&$skiptoken=%3Ccookie%20pagenumber=%222%22%20pagingcookie=%22%253ccookie%2520page%253d%25221%2522%253e%253caccountid%2520last%253d%2522%257b8151925C-CDE2-E411-80DB-00155D2A68CB%257d%2522%2520first%253d%2522%257b7D51925C-CDE2-E411-80DB-00155D2A68CB%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20/%3E", + value: [ + { name: "name1", subject: "subject1" }, + { name: "name2", subject: "subject2" }, + ], + }, multipleWithDeltaLink: { "@odata.context": "context", "@odata.deltaLink": webApiUrl + "tests?$select=name&$deltatoken=919042%2108%2f22%2f2017%2008%3a10%3a44", @@ -239,6 +250,12 @@ const dataStubs = { querycontext: null, value: "{crmhit}test{/crmhit}", }, + error: { + error: { + code: "error_code", + message: "ERROR!" + } + }, batch: "--dwa_batch_XXX\n" + "Content-Type: application/http\n" + @@ -898,6 +915,11 @@ var responseStubs = { responseText: JSON.stringify(dataStubs.multipleWithLink), responseHeaders: dataStubs.defaultResponseHeaders, }, + multipleWithLinkAndCountResponse: { + status: 200, + responseText: JSON.stringify(dataStubs.multipleWithLinkAndCount), + responseHeaders: dataStubs.defaultResponseHeaders, + }, multipleWithDeltaLinkResponse: { status: 200, responseText: JSON.stringify(dataStubs.multipleWithDeltaLink), @@ -1332,6 +1354,13 @@ var responseStubs = { stub.oDataNextLink = stub["@odata.nextLink"]; return stub; }, + multipleWithLinkAndCount: function () { + var stub = dataStubs.multipleWithLinkAndCount; + stub.oDataContext = stub["@odata.context"]; + stub.oDataNextLink = stub["@odata.nextLink"]; + stub.oDataCount = stub["@odata.count"]; + return stub; + }, multipleWithDeltaLink: function () { var stub = dataStubs.multipleWithDeltaLink; stub.oDataContext = stub["@odata.context"]; @@ -1382,6 +1411,11 @@ var responseStubs = { responseText: JSON.stringify(dataStubs.autocompleteResult), responseHeaders: dataStubs.defaultResponseHeaders, }, + errorResponse: { + status: 400, + responseText: JSON.stringify(dataStubs.error), + responseHeaders: dataStubs.defaultResponseHeaders + } }; var utils = {