diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index f372e04..e51b481 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -1,3 +1,16 @@ + +# [v2.4.0](https://github.com/AleksandrRogov/DynamicsWebApi/releases/tag/v2.4.0) - 28 Oct 2025 + +## What's Changed +* Allowing `@odata.id` to have an alternate key format. It used to force an absolute URL which should have only been done in POST requests to `/$ref`. Fixes [#195](https://github.com/AleksandrRogov/DynamicsWebApi/issues/195) . +:warning: This change may be a breaking change in case you were making an _undocumented_ request that included `@odata.id` in the body of the request which will result in the value of the `@odata.id` to not have an absolute URL. A quick fix could be done by using a new utility function: +* `dynamicsWebApi.Utility.toAbsoluteUrl` - a new utility function that prepends a url from the `dataApi` config to a provided value. + +**Full Changelog**: https://github.com/AleksandrRogov/DynamicsWebApi/compare/v2.3.2...v2.4.0 + +[Changes][v2.4.0] + + # [v2.3.2](https://github.com/AleksandrRogov/DynamicsWebApi/releases/tag/v2.3.2) - 20 Aug 2025 @@ -1141,6 +1154,7 @@ Added: [Changes][v1.2.0] +[v2.4.0]: https://github.com/AleksandrRogov/DynamicsWebApi/compare/v2.3.2...v2.4.0 [v2.3.2]: https://github.com/AleksandrRogov/DynamicsWebApi/compare/v2.3.1...v2.3.2 [v2.3.1]: https://github.com/AleksandrRogov/DynamicsWebApi/compare/v2.3.0...v2.3.1 [v2.3.0]: https://github.com/AleksandrRogov/DynamicsWebApi/compare/v2.2.1...v2.3.0 diff --git a/.github/README.md b/.github/README.md index f15f4aa..5b2fed3 100644 --- a/.github/README.md +++ b/.github/README.md @@ -2863,6 +2863,7 @@ the config option "formatted" will enable developers to retrieve all information - [X] Background Operations for custom actions. `Added in v2.3.0` - [X] Support Search API 2.0 [#174](https://github.com/AleksandrRogov/DynamicsWebApi/issues/174). `Added in v2.3.0` - [ ] [Session token](https://learn.microsoft.com/en-ca/power-apps/developer/data-platform/use-elastic-tables?tabs=webapi#work-with-the-session-token) support. `Coming in v2.3.x` +- [ ] Support for a custom logger + a console fallback debug logging. - [ ] Custom requests. Many more features to come! diff --git a/dist/browser/esm/dynamics-web-api.js b/dist/browser/esm/dynamics-web-api.js index cc366ea..99c030d 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.3.2 (c) 2025 Aleksandr Rogov. License: MIT */ +/*! dynamics-web-api v2.4.0 (c) 2025 Aleksandr Rogov. License: MIT */ var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; @@ -85,7 +85,7 @@ function sanitizeCookie(cookie) { return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]); } function removeLeadingSlash(value) { - return value.replace(LEADING_SLASH_REGEX, ""); + return value.startsWith("/") ? value.slice(1) : value; } function escapeUnicodeSymbols(value) { return value.replace(UNICODE_SYMBOLS_REGEX, (chr) => `\\u${("0000" + chr.charCodeAt(0).toString(16)).slice(-4)}`); @@ -103,7 +103,7 @@ function extractPreferCallbackUrl(value) { const match = PREFER_CALLBACK_URL_REGEX.exec(value); return match ? match[1] : null; } -var UUID, UUID_REGEX, EXTRACT_UUID_REGEX, EXTRACT_UUID_FROM_URL_REGEX, REMOVE_BRACKETS_FROM_UUID_REGEX, ENTITY_UUID_REGEX, QUOTATION_MARK_REGEX, PAGING_COOKIE_REGEX, SPECIAL_CHARACTER_REGEX, LEADING_SLASH_REGEX, UNICODE_SYMBOLS_REGEX, DOUBLE_QUOTE_REGEX, BATCH_RESPONSE_HEADERS_REGEX, HTTP_STATUS_REGEX, CONTENT_TYPE_PLAIN_REGEX, ODATA_ENTITYID_REGEX, TEXT_REGEX, LINE_ENDING_REGEX, SEARCH_FOR_ENTITY_NAME_REGEX, SPECIAL_COLLECTION_FOR_UPDATE_REGEX, FETCH_XML_TOP_REGEX, FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, DATE_FORMAT_REGEX, SEARCH_SPECIAL_CHARACTERS_REGEX, PREFER_CALLBACK_URL_REGEX; +var UUID, UUID_REGEX, EXTRACT_UUID_REGEX, EXTRACT_UUID_FROM_URL_REGEX, REMOVE_BRACKETS_FROM_UUID_REGEX, ENTITY_UUID_REGEX, QUOTATION_MARK_REGEX, PAGING_COOKIE_REGEX, SPECIAL_CHARACTER_REGEX, UNICODE_SYMBOLS_REGEX, DOUBLE_QUOTE_REGEX, BATCH_RESPONSE_HEADERS_REGEX, HTTP_STATUS_REGEX, CONTENT_TYPE_PLAIN_REGEX, ODATA_ENTITYID_REGEX, TEXT_REGEX, LINE_ENDING_REGEX, SEARCH_FOR_ENTITY_NAME_REGEX, SPECIAL_COLLECTION_FOR_UPDATE_REGEX, FETCH_XML_TOP_REGEX, FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, DATE_FORMAT_REGEX, SEARCH_SPECIAL_CHARACTERS_REGEX, PREFER_CALLBACK_URL_REGEX; var init_Regex = __esm({ "src/helpers/Regex.ts"() { "use strict"; @@ -116,7 +116,6 @@ var init_Regex = __esm({ QUOTATION_MARK_REGEX = /(["'].*?["'])/; PAGING_COOKIE_REGEX = /pagingcookie="()/; SPECIAL_CHARACTER_REGEX = /[<>"']/g; - LEADING_SLASH_REGEX = /^\//; UNICODE_SYMBOLS_REGEX = /[\u007F-\uFFFF]/g; DOUBLE_QUOTE_REGEX = /"/g; BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/; @@ -262,6 +261,9 @@ function convertToFileBuffer(binaryString) { } return bytes; } +function toAbsoluteUrl(client, value) { + return `${client.config.dataApi.url}${removeLeadingSlash(value)}`; +} var downloadChunkSize; var init_Utility = __esm({ "src/utils/Utility.ts"() { @@ -1422,13 +1424,15 @@ var processData = (data, config) => { return value; }; const stringifiedData = JSON.stringify(data, (key, value) => { - if (key.endsWith("@odata.bind") || key.endsWith("@odata.id")) { + if (key === "@odata.id" || key.endsWith("@odata.bind")) { if (typeof value === "string" && !value.startsWith("$")) { value = removeCurlyBracketsFromUuid(value); if (config.useEntityNames) { value = replaceEntityNameWithCollectionName(value); } - value = addFullWebApiUrl(key, value); + if (key !== "@odata.id") { + value = addFullWebApiUrl(key, value); + } } } else if (key.startsWith("oData") || key.endsWith("_Formatted") || key.endsWith("_NavigationProperty") || key.endsWith("_LogicalName")) { return void 0; @@ -1726,7 +1730,7 @@ var associate = async (request, client) => { if (!client.isBatch || client.isBatch && !request.relatedKey.startsWith("$")) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); internalRequest.method = "POST"; @@ -1751,7 +1755,7 @@ var associateSingleValued = async (request, client) => { if (!client.isBatch || client.isBatch && !request.relatedKey.startsWith("$")) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME2, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME2, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); internalRequest.method = "PUT"; @@ -2896,6 +2900,7 @@ async function cancelBackgroundOperation(backgroundOperationId, client) { } // src/dynamics-web-api.ts +init_Utility(); var _client; var _DynamicsWebApi = class _DynamicsWebApi { /** @@ -3304,7 +3309,13 @@ var _DynamicsWebApi = class _DynamicsWebApi { * @param {string} entityName entity name * @returns {string | null} collection name */ - getCollectionName: (entityName) => getCollectionName(entityName) + getCollectionName: (entityName) => getCollectionName(entityName), + /** + * Adds an absolute Web API URL to the beginning of a provided value. + * @param value The value to modify. + * @returns The absolute URL. + */ + toAbsoluteUrl: (value) => toAbsoluteUrl(__privateGet(this, _client), value) }; __privateSet(this, _client, new DataverseClient(config)); } diff --git a/dist/browser/esm/dynamics-web-api.js.map b/dist/browser/esm/dynamics-web-api.js.map index 42f5cdc..b0b6b8e 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/parseBatchResponse.ts", "../../../src/client/helpers/parseResponse.ts", "../../../src/client/helpers/parseResponseHeaders.ts", "../../../src/client/xhr.ts", "../../../src/utils/Config.ts", "../../../src/requests/constants.ts", "../../../src/client/RequestClient.ts", "../../../src/client/helpers/entityNameMapper.ts", "../../../src/client/helpers/executeRequest.ts", "../../../src/client/request/composers/url.ts", "../../../src/client/request/composers/headers.ts", "../../../src/client/request/composers/preferHeader.ts", "../../../src/client/request/composers/request.ts", "../../../src/client/request/processData.ts", "../../../src/client/helpers/index.ts", "../../../src/client/request/setStandardHeaders.ts", "../../../src/client/request/convertToBatch.ts", "../../../src/client/dataverse.ts", "../../../src/requests/associate.ts", "../../../src/requests/associateSingleValued.ts", "../../../src/requests/callAction.ts", "../../../src/requests/callFunction.ts", "../../../src/requests/create.ts", "../../../src/requests/count.ts", "../../../src/requests/countAll.ts", "../../../src/requests/retrieveAll.ts", "../../../src/requests/retrieveMultiple.ts", "../../../src/requests/disassociate.ts", "../../../src/requests/disassociateSingleValued.ts", "../../../src/requests/retrieve.ts", "../../../src/requests/fetchXml.ts", "../../../src/requests/fetchXmlAll.ts", "../../../src/requests/update.ts", "../../../src/requests/updateSingleProperty.ts", "../../../src/requests/upsert.ts", "../../../src/requests/delete.ts", "../../../src/requests/uploadFile.ts", "../../../src/requests/downloadFile.ts", "../../../src/requests/executeBatch.ts", "../../../src/requests/metadata/createEntity.ts", "../../../src/requests/metadata/updateEntity.ts", "../../../src/requests/metadata/retrieveEntity.ts", "../../../src/requests/metadata/retrieveEntities.ts", "../../../src/requests/metadata/createAttribute.ts", "../../../src/requests/metadata/updateAttribute.ts", "../../../src/requests/metadata/retrieveAttributes.ts", "../../../src/requests/metadata/retrieveAttribute.ts", "../../../src/requests/metadata/createRelationship.ts", "../../../src/requests/metadata/updateRelationship.ts", "../../../src/requests/metadata/deleteRelationship.ts", "../../../src/requests/metadata/retrieveRelationships.ts", "../../../src/requests/metadata/retrieveRelationship.ts", "../../../src/requests/metadata/createGlobalOptionSet.ts", "../../../src/requests/metadata/updateGlobalOptionSet.ts", "../../../src/requests/metadata/deleteGlobalOptionSet.ts", "../../../src/requests/metadata/retrieveGlobalOptionSet.ts", "../../../src/requests/metadata/retrieveGlobalOptionSets.ts", "../../../src/requests/metadata/retrieveCsdlMetadata.ts", "../../../src/requests/search/query.ts", "../../../src/requests/search/convertSearchQuery.ts", "../../../src/requests/search/responseParsers/parseQueryResponse.ts", "../../../src/requests/search/suggest.ts", "../../../src/requests/search/responseParsers/parseSuggestResponse.ts", "../../../src/requests/search/autocomplete.ts", "../../../src/requests/search/responseParsers/parseAutocompleteResponse.ts", "../../../src/requests/backgroundOperation/getStatus.ts", "../../../src/requests/backgroundOperation/cancel.ts", "../../../src/dynamics-web-api.ts"], - "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? (global.window.crypto as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nconst LEADING_SLASH_REGEX = /^\\//;\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.replace(LEADING_SLASH_REGEX, \"\");\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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", "\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): Record {\r\n\tconst headers: Record = {};\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 type * as 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 headers = options.headers;\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 headers) {\r\n request.setRequestHeader(key, headers[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 if (!request || request.status === 0) return; // response was handled elsewhere or will be handled by onerror\r\n\r\n if ((request.status >= 200 && request.status < 300) || request.status === 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 } else {\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 return;\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 }\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 { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const 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 value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "\uFEFFimport { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\r\n};\r\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,YAAwB;AACpC,SAAO,OAAsB,OAAc,SAAe,KAAyB,UAAU;AACjG;AAFA;AAAA;AAAA;AAAA;AAAA;;;ACWO,SAAS,OAAO,OAAwB;AAC3C,QAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,SAAO,CAAC,CAAC;AACb;AAEO,SAAS,YAAY,OAA8B;AACtD,QAAM,QAAQ,mBAAmB,KAAK,KAAK;AAC3C,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,mBAAmB,KAA6B;AAC5D,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,QAAQ,4BAA4B,KAAK,GAAG;AAClD,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,4BAA4B,OAAuB;AAC/D,SAAO,MAAM,QAAQ,iCAAiC,CAAC,QAAQ,OAAO,EAAE;AAC5E;AASO,SAAS,iCAAiC,KAAqB;AAIlE,QAAM,QAAQ,IAAI,MAAM,oBAAoB;AAC5C,SAAO,MACF,IAAI,CAAC,MAAM,UAAU;AAElB,QAAI,QAAQ,MAAM,GAAG;AACjB,aAAO,4BAA4B,IAAI;AAAA,IAC3C;AACA,WAAO;AAAA,EACX,CAAC,EACA,KAAK,EAAE;AAChB;AAOO,SAAS,yBAAyB,cAAoD;AACzF,QAAM,SAAS,kBAAkB,KAAK,aAAa,WAAW,CAAC;AAC/D,SAAO,EAAE,IAAI,OAAQ,CAAC,GAAG,YAAY,OAAQ,CA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AAAA;AAAA;AAAA;AAAA,mBAA2B,OAA6B,YAC1C,QAAQ,SAAS,mBAAK,QAAO;AAO3C;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqC,OAAO,YAC9B,aAAa,SAAS,mBAAK,QAAO;AAOhD;AAAA;AAAA;AAAA;AAAA;AAAA,wCAA+B,OAAO,0BACxB,6BAA6B,uBAAuB,mBAAK,QAAO;AAO9E;AAAA;AAAA;AAAA;AAAA;AAAA,qCAA4B,OAAO,0BACrB,0BAA0B,uBAAuB,mBAAK,QAAO;AAK3E;AAAA;AAAA;AAAA,sBAAa,MAAsB,WAAW,mBAAK,QAAO;AAO1D;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe,OAAO,YAAqD,aAAa,SAAS,mBAAK,QAAO;AAQ7G;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,mBAAK,SAAQ,MAAM;AAE1G,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,kBAAkB,UAAU;AAAA,IAC1F;AAldI,uBAAK,SAAU,IAAI,gBAAgB,MAAM;AAAA,EAC7C;AAkdJ;AA1dI;AADG,IAAM,iBAAN;", + "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? (global.window.crypto as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.startsWith(\"/\") ? value.slice(1) : value;\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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\nexport function toAbsoluteUrl(client: IDataverseClient, value: string): string {\r\n return `${client.config.dataApi.url}${removeLeadingSlash(value)}`;\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): Record {\r\n\tconst headers: Record = {};\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 type * as 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 headers = options.headers;\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 headers) {\r\n request.setRequestHeader(key, headers[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 if (!request || request.status === 0) return; // response was handled elsewhere or will be handled by onerror\r\n\r\n if ((request.status >= 200 && request.status < 300) || request.status === 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 } else {\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 return;\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 }\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 { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key === \"@odata.id\" || key.endsWith(\"@odata.bind\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n\r\n // the full Web API URL is only added in requests to /$ref\r\n // the value itself is set directly in the requests that require it\r\n if (key !== \"@odata.id\") {\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "\uFEFFimport { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\nimport { toAbsoluteUrl } from \"./utils/Utility\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n\r\n /**\r\n * Adds an absolute Web API URL to the beginning of a provided value.\r\n * @param value The value to modify.\r\n * @returns The absolute URL.\r\n */\r\n toAbsoluteUrl: (value: string): string => toAbsoluteUrl(this.#client,value),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Disables enforcement of absolute URLs for @odata.id properties in the request body.\r\n * In some cases, @odata.id has an alternate key format that does not use absolute URLs, for example:\r\n * In an UpsertMultiple action body.\r\n */\r\n disableODataIdAbsoluteUrl?: boolean;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\r\n};\r\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,YAAwB;AACpC,SAAO,OAAsB,OAAc,SAAe,KAAyB,UAAU;AACjG;AAFA;AAAA;AAAA;AAAA;AAAA;;;ACWO,SAAS,OAAO,OAAwB;AAC3C,QAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,SAAO,CAAC,CAAC;AACb;AAEO,SAAS,YAAY,OAA8B;AACtD,QAAM,QAAQ,mBAAmB,KAAK,KAAK;AAC3C,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,mBAAmB,KAA6B;AAC5D,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,QAAQ,4BAA4B,KAAK,GAAG;AAClD,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,4BAA4B,OAAuB;AAC/D,SAAO,MAAM,QAAQ,iCAA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AAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOtF,eAAe,CAAC,UAA0B,cAAc,mBAAK,UAAQ,KAAK;AAAA,IAC9E;AAzdI,uBAAK,SAAU,IAAI,gBAAgB,MAAM;AAAA,EAC7C;AAydJ;AAjeI;AADG,IAAM,iBAAN;", "names": ["count", "headers", "executeRequest", "headers", "batchBody", "executeRequest", "FUNCTION_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "request", "isObject", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "query", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME"] } diff --git a/dist/cjs/dynamics-web-api.js b/dist/cjs/dynamics-web-api.js index e3856f2..e66f563 100644 --- a/dist/cjs/dynamics-web-api.js +++ b/dist/cjs/dynamics-web-api.js @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.3.2 (c) 2025 Aleksandr Rogov. License: MIT */ +/*! dynamics-web-api v2.4.0 (c) 2025 Aleksandr Rogov. License: MIT */ "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; @@ -112,7 +112,7 @@ function sanitizeCookie(cookie) { return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]); } function removeLeadingSlash(value) { - return value.replace(LEADING_SLASH_REGEX, ""); + return value.startsWith("/") ? value.slice(1) : value; } function escapeUnicodeSymbols(value) { return value.replace(UNICODE_SYMBOLS_REGEX, (chr) => `\\u${("0000" + chr.charCodeAt(0).toString(16)).slice(-4)}`); @@ -130,7 +130,7 @@ function extractPreferCallbackUrl(value) { const match = PREFER_CALLBACK_URL_REGEX.exec(value); return match ? match[1] : null; } -var UUID, UUID_REGEX, EXTRACT_UUID_REGEX, EXTRACT_UUID_FROM_URL_REGEX, REMOVE_BRACKETS_FROM_UUID_REGEX, ENTITY_UUID_REGEX, QUOTATION_MARK_REGEX, PAGING_COOKIE_REGEX, SPECIAL_CHARACTER_REGEX, LEADING_SLASH_REGEX, UNICODE_SYMBOLS_REGEX, DOUBLE_QUOTE_REGEX, BATCH_RESPONSE_HEADERS_REGEX, HTTP_STATUS_REGEX, CONTENT_TYPE_PLAIN_REGEX, ODATA_ENTITYID_REGEX, TEXT_REGEX, LINE_ENDING_REGEX, SEARCH_FOR_ENTITY_NAME_REGEX, SPECIAL_COLLECTION_FOR_UPDATE_REGEX, FETCH_XML_TOP_REGEX, FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, DATE_FORMAT_REGEX, SEARCH_SPECIAL_CHARACTERS_REGEX, PREFER_CALLBACK_URL_REGEX; +var UUID, UUID_REGEX, EXTRACT_UUID_REGEX, EXTRACT_UUID_FROM_URL_REGEX, REMOVE_BRACKETS_FROM_UUID_REGEX, ENTITY_UUID_REGEX, QUOTATION_MARK_REGEX, PAGING_COOKIE_REGEX, SPECIAL_CHARACTER_REGEX, UNICODE_SYMBOLS_REGEX, DOUBLE_QUOTE_REGEX, BATCH_RESPONSE_HEADERS_REGEX, HTTP_STATUS_REGEX, CONTENT_TYPE_PLAIN_REGEX, ODATA_ENTITYID_REGEX, TEXT_REGEX, LINE_ENDING_REGEX, SEARCH_FOR_ENTITY_NAME_REGEX, SPECIAL_COLLECTION_FOR_UPDATE_REGEX, FETCH_XML_TOP_REGEX, FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, DATE_FORMAT_REGEX, SEARCH_SPECIAL_CHARACTERS_REGEX, PREFER_CALLBACK_URL_REGEX; var init_Regex = __esm({ "src/helpers/Regex.ts"() { "use strict"; @@ -143,7 +143,6 @@ var init_Regex = __esm({ QUOTATION_MARK_REGEX = /(["'].*?["'])/; PAGING_COOKIE_REGEX = /pagingcookie="()/; SPECIAL_CHARACTER_REGEX = /[<>"']/g; - LEADING_SLASH_REGEX = /^\//; UNICODE_SYMBOLS_REGEX = /[\u007F-\uFFFF]/g; DOUBLE_QUOTE_REGEX = /"/g; BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/; @@ -289,6 +288,9 @@ function convertToFileBuffer(binaryString) { } return bytes; } +function toAbsoluteUrl(client, value) { + return `${client.config.dataApi.url}${removeLeadingSlash(value)}`; +} var downloadChunkSize; var init_Utility = __esm({ "src/utils/Utility.ts"() { @@ -1431,13 +1433,15 @@ var processData = (data, config) => { return value; }; const stringifiedData = JSON.stringify(data, (key, value) => { - if (key.endsWith("@odata.bind") || key.endsWith("@odata.id")) { + if (key === "@odata.id" || key.endsWith("@odata.bind")) { if (typeof value === "string" && !value.startsWith("$")) { value = removeCurlyBracketsFromUuid(value); if (config.useEntityNames) { value = replaceEntityNameWithCollectionName(value); } - value = addFullWebApiUrl(key, value); + if (key !== "@odata.id") { + value = addFullWebApiUrl(key, value); + } } } else if (key.startsWith("oData") || key.endsWith("_Formatted") || key.endsWith("_NavigationProperty") || key.endsWith("_LogicalName")) { return void 0; @@ -1737,7 +1741,7 @@ var associate = async (request, client) => { if (!client.isBatch || client.isBatch && !request.relatedKey.startsWith("$")) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); internalRequest.method = "POST"; @@ -1762,7 +1766,7 @@ var associateSingleValued = async (request, client) => { if (!client.isBatch || client.isBatch && !request.relatedKey.startsWith("$")) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME2, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME2, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); internalRequest.method = "PUT"; @@ -2912,6 +2916,7 @@ async function cancelBackgroundOperation(backgroundOperationId, client) { } // src/dynamics-web-api.ts +init_Utility(); var _client; var _DynamicsWebApi = class _DynamicsWebApi { /** @@ -3320,7 +3325,13 @@ var _DynamicsWebApi = class _DynamicsWebApi { * @param {string} entityName entity name * @returns {string | null} collection name */ - getCollectionName: (entityName) => getCollectionName(entityName) + getCollectionName: (entityName) => getCollectionName(entityName), + /** + * Adds an absolute Web API URL to the beginning of a provided value. + * @param value The value to modify. + * @returns The absolute URL. + */ + toAbsoluteUrl: (value) => toAbsoluteUrl(__privateGet(this, _client), value) }; __privateSet(this, _client, new DataverseClient(config)); } diff --git a/dist/cjs/dynamics-web-api.js.map b/dist/cjs/dynamics-web-api.js.map index cc92bc4..5d00b92 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/parseBatchResponse.ts", "../../src/client/helpers/parseResponse.ts", "../../src/client/http.ts", "../../src/dynamics-web-api.ts", "../../src/utils/Config.ts", "../../src/requests/constants.ts", "../../src/client/RequestClient.ts", "../../src/client/helpers/entityNameMapper.ts", "../../src/client/helpers/executeRequest.ts", "../../src/client/request/composers/url.ts", "../../src/client/request/composers/headers.ts", "../../src/client/request/composers/preferHeader.ts", "../../src/client/request/composers/request.ts", "../../src/client/request/processData.ts", "../../src/client/helpers/index.ts", "../../src/client/request/setStandardHeaders.ts", "../../src/client/request/convertToBatch.ts", "../../src/client/dataverse.ts", "../../src/requests/associate.ts", "../../src/requests/associateSingleValued.ts", "../../src/requests/callAction.ts", "../../src/requests/callFunction.ts", "../../src/requests/create.ts", "../../src/requests/count.ts", "../../src/requests/countAll.ts", "../../src/requests/retrieveAll.ts", "../../src/requests/retrieveMultiple.ts", "../../src/requests/disassociate.ts", "../../src/requests/disassociateSingleValued.ts", "../../src/requests/retrieve.ts", "../../src/requests/fetchXml.ts", "../../src/requests/fetchXmlAll.ts", "../../src/requests/update.ts", "../../src/requests/updateSingleProperty.ts", "../../src/requests/upsert.ts", "../../src/requests/delete.ts", "../../src/requests/uploadFile.ts", "../../src/requests/downloadFile.ts", "../../src/requests/executeBatch.ts", "../../src/requests/metadata/createEntity.ts", "../../src/requests/metadata/updateEntity.ts", "../../src/requests/metadata/retrieveEntity.ts", "../../src/requests/metadata/retrieveEntities.ts", "../../src/requests/metadata/createAttribute.ts", "../../src/requests/metadata/updateAttribute.ts", "../../src/requests/metadata/retrieveAttributes.ts", "../../src/requests/metadata/retrieveAttribute.ts", "../../src/requests/metadata/createRelationship.ts", "../../src/requests/metadata/updateRelationship.ts", "../../src/requests/metadata/deleteRelationship.ts", "../../src/requests/metadata/retrieveRelationships.ts", "../../src/requests/metadata/retrieveRelationship.ts", "../../src/requests/metadata/createGlobalOptionSet.ts", "../../src/requests/metadata/updateGlobalOptionSet.ts", "../../src/requests/metadata/deleteGlobalOptionSet.ts", "../../src/requests/metadata/retrieveGlobalOptionSet.ts", "../../src/requests/metadata/retrieveGlobalOptionSets.ts", "../../src/requests/metadata/retrieveCsdlMetadata.ts", "../../src/requests/search/query.ts", "../../src/requests/search/convertSearchQuery.ts", "../../src/requests/search/responseParsers/parseQueryResponse.ts", "../../src/requests/search/suggest.ts", "../../src/requests/search/responseParsers/parseSuggestResponse.ts", "../../src/requests/search/autocomplete.ts", "../../src/requests/search/responseParsers/parseAutocompleteResponse.ts", "../../src/requests/backgroundOperation/getStatus.ts", "../../src/requests/backgroundOperation/cancel.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 as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nconst LEADING_SLASH_REGEX = /^\\//;\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.replace(LEADING_SLASH_REGEX, \"\");\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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", "\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\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 type * as 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 headers = options.headers;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n const httpHeaders: http.OutgoingHttpHeaders = {};\r\n\r\n if (data) {\r\n httpHeaders[\"Content-Type\"] = headers[\"Content-Type\"];\r\n httpHeaders[\"Content-Length\"] = data.length;\r\n\r\n delete headers[\"Content-Type\"];\r\n }\r\n\r\n //set additional headers\r\n for (let key in headers) {\r\n httpHeaders[key] = headers[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: httpHeaders,\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) httpHeaders.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 if (res.statusCode && ((res.statusCode >= 200 && res.statusCode < 300) || res.statusCode === 304)) {\r\n // Success with Not Modified\r\n let responseData = parseResponse(rawData, res.headers as Record, 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 } else {\r\n // All other statuses are error cases.\r\n let crmError;\r\n try {\r\n var errorParsed = parseResponse(rawData, res.headers as Record, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n return;\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 }\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 { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\r\n};\r\n", "import { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const 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 value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\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,QAAsB,OAAO,OAAO,SAAe,0CAAyB,UAAU;AACjG;AAFA;AAAA;AAAA;AAAA;AAAA;;;ACWO,SAAS,OAAO,OAAwB;AAC3C,QAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,SAAO,CAAC,CAAC;AACb;AAEO,SAAS,YAAY,OAA8B;AACtD,QAAM,QAAQ,mBAAmB,KAAK,KAAK;AAC3C,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,mBAAmB,KAA6B;AAC5D,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,QAAQ,4BAA4B,KAAK,GAAG;AAClD,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,4BAA4B,OAAuB;AAC/D,SAAO,MAAM,QAAQ,iCAAiC,CAAC,QAAQ,OAAO,EAAE;AAC5E;AASO,SAAS,iCAAiC,KAAqB;AAIlE,QAAM,QAAQ,IAAI,MAAM,oBAAo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D;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe,OAAO,YAAqD,aAAa,SAAS,mBAAK,QAAO;AAQ7G;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,mBAAK,SAAQ,MAAM;AAE1G,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,kBAAkB,UAAU;AAAA,IAC1F;AAldI,uBAAK,SAAU,IAAI,gBAAgB,MAAM;AAAA,EAC7C;AAkdJ;AA1dI;AADG,IAAM,iBAAN;", + "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 as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.startsWith(\"/\") ? value.slice(1) : value;\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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\nexport function toAbsoluteUrl(client: IDataverseClient, value: string): string {\r\n return `${client.config.dataApi.url}${removeLeadingSlash(value)}`;\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\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 type * as 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 headers = options.headers;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n const httpHeaders: http.OutgoingHttpHeaders = {};\r\n\r\n if (data) {\r\n httpHeaders[\"Content-Type\"] = headers[\"Content-Type\"];\r\n httpHeaders[\"Content-Length\"] = data.length;\r\n\r\n delete headers[\"Content-Type\"];\r\n }\r\n\r\n //set additional headers\r\n for (let key in headers) {\r\n httpHeaders[key] = headers[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: httpHeaders,\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) httpHeaders.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 if (res.statusCode && ((res.statusCode >= 200 && res.statusCode < 300) || res.statusCode === 304)) {\r\n // Success with Not Modified\r\n let responseData = parseResponse(rawData, res.headers as Record, 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 } else {\r\n // All other statuses are error cases.\r\n let crmError;\r\n try {\r\n var errorParsed = parseResponse(rawData, res.headers as Record, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n return;\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 }\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 { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\nimport { toAbsoluteUrl } from \"./utils/Utility\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n\r\n /**\r\n * Adds an absolute Web API URL to the beginning of a provided value.\r\n * @param value The value to modify.\r\n * @returns The absolute URL.\r\n */\r\n toAbsoluteUrl: (value: string): string => toAbsoluteUrl(this.#client,value),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Disables enforcement of absolute URLs for @odata.id properties in the request body.\r\n * In some cases, @odata.id has an alternate key format that does not use absolute URLs, for example:\r\n * In an UpsertMultiple action body.\r\n */\r\n disableODataIdAbsoluteUrl?: boolean;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\r\n};\r\n", "import { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key === \"@odata.id\" || key.endsWith(\"@odata.bind\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n\r\n // the full Web API URL is only added in requests to /$ref\r\n // the value itself is set directly in the requests that require it\r\n if (key !== \"@odata.id\") {\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\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,QAAsB,OAAO,OAAO,SAAe,0CAAyB,UAAU;AACjG;AAFA;AAAA;AAAA;AAAA;AAAA;;;ACWO,SAAS,OAAO,OAAwB;AAC3C,QAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,SAAO,CAAC,CAAC;AACb;AAEO,SAAS,YAAY,OAA8B;AACtD,QAAM,QAAQ,mBAAmB,KAAK,KAAK;AAC3C,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,mBAAmB,KAA6B;AAC5D,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,QAAQ,4BAA4B,KAAK,GAAG;AAClD,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC9B;AAEO,SAAS,4BAA4B,OAAuB;AAC/D,SAAO,MAAM,QAAQ,iCAAiC,CAAC,QAAQ,OAAO,EAAE;AAC5E;AASO,SAAS,iCAAiC,KAAqB;AAIlE,QAAM,QAAQ,IAAI,MAAM,oBAAoB;AAC5C,SAAO,MACF,IAAI,CAAC,MAAM,UAAU;AAElB,QAAI,QAAQ,MA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AA;AAAA,qCAA4B,OAAO,0BACrB,0BAA0B,uBAAuB,mBAAK,QAAO;AAK3E;AAAA;AAAA;AAAA,sBAAa,MAAsB,WAAW,mBAAK,QAAO;AAO1D;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe,OAAO,YAAqD,aAAa,SAAS,mBAAK,QAAO;AAQ7G;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,mBAAK,SAAQ,MAAM;AAE1G,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOtF,eAAe,CAAC,UAA0B,cAAc,mBAAK,UAAQ,KAAK;AAAA,IAC9E;AAzdI,uBAAK,SAAU,IAAI,gBAAgB,MAAM;AAAA,EAC7C;AAydJ;AAjeI;AADG,IAAM,iBAAN;", "names": ["nCrypto", "getCrypto", "getCrypto", "count", "_a", "_a", "_a", "HttpProxyAgent", "HttpsProxyAgent", "executeRequest", "_a", "_b", "_a", "_b", "headers", "batchBody", "_a", "_a", "executeRequest", "FUNCTION_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "request", "isObject", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "_a", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "_a", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "query", "_a", "FUNCTION_NAME", "REQUEST_NAME", "_a", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME"] } diff --git a/dist/dynamics-web-api.d.ts b/dist/dynamics-web-api.d.ts index 1c1f9bb..8add204 100644 --- a/dist/dynamics-web-api.d.ts +++ b/dist/dynamics-web-api.d.ts @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.3.2 (c) 2025 Aleksandr Rogov. License: MIT */ +/*! dynamics-web-api v2.4.0 (c) 2025 Aleksandr Rogov. License: MIT */ /** * Microsoft Dataverse Web API helper library for Node.js and Browser. * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online. @@ -408,6 +408,12 @@ export declare class DynamicsWebApi { * @returns {string | null} collection name */ getCollectionName: (entityName: string) => string | null; + /** + * Adds an absolute Web API URL to the beginning of a provided value. + * @param value The value to modify. + * @returns The absolute URL. + */ + toAbsoluteUrl: (value: string) => string; }; } export interface Expand { @@ -1058,6 +1064,12 @@ export interface Config { * You can also set a callback URL per request. */ backgroundOperationCallbackUrl?: string; + /** + * Disables enforcement of absolute URLs for @odata.id properties in the request body. + * In some cases, @odata.id has an alternate key format that does not use absolute URLs, for example: + * In an UpsertMultiple action body. + */ + disableODataIdAbsoluteUrl?: boolean; } /**Header collection type */ export type HeaderCollection = Record; diff --git a/dist/dynamics-web-api.js b/dist/dynamics-web-api.js index 4649717..c26c9c5 100644 --- a/dist/dynamics-web-api.js +++ b/dist/dynamics-web-api.js @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.3.2 (c) 2025 Aleksandr Rogov. License: MIT */ +/*! dynamics-web-api v2.4.0 (c) 2025 Aleksandr Rogov. License: MIT */ "use strict"; var _dynamicsWebApiExports = (() => { var __defProp = Object.defineProperty; @@ -87,7 +87,7 @@ var _dynamicsWebApiExports = (() => { return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]); } function removeLeadingSlash(value) { - return value.replace(LEADING_SLASH_REGEX, ""); + return value.startsWith("/") ? value.slice(1) : value; } function escapeUnicodeSymbols(value) { return value.replace(UNICODE_SYMBOLS_REGEX, (chr) => `\\u${("0000" + chr.charCodeAt(0).toString(16)).slice(-4)}`); @@ -105,7 +105,7 @@ var _dynamicsWebApiExports = (() => { const match = PREFER_CALLBACK_URL_REGEX.exec(value); return match ? match[1] : null; } - var UUID, UUID_REGEX, EXTRACT_UUID_REGEX, EXTRACT_UUID_FROM_URL_REGEX, REMOVE_BRACKETS_FROM_UUID_REGEX, ENTITY_UUID_REGEX, QUOTATION_MARK_REGEX, PAGING_COOKIE_REGEX, SPECIAL_CHARACTER_REGEX, LEADING_SLASH_REGEX, UNICODE_SYMBOLS_REGEX, DOUBLE_QUOTE_REGEX, BATCH_RESPONSE_HEADERS_REGEX, HTTP_STATUS_REGEX, CONTENT_TYPE_PLAIN_REGEX, ODATA_ENTITYID_REGEX, TEXT_REGEX, LINE_ENDING_REGEX, SEARCH_FOR_ENTITY_NAME_REGEX, SPECIAL_COLLECTION_FOR_UPDATE_REGEX, FETCH_XML_TOP_REGEX, FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, DATE_FORMAT_REGEX, SEARCH_SPECIAL_CHARACTERS_REGEX, PREFER_CALLBACK_URL_REGEX; + var UUID, UUID_REGEX, EXTRACT_UUID_REGEX, EXTRACT_UUID_FROM_URL_REGEX, REMOVE_BRACKETS_FROM_UUID_REGEX, ENTITY_UUID_REGEX, QUOTATION_MARK_REGEX, PAGING_COOKIE_REGEX, SPECIAL_CHARACTER_REGEX, UNICODE_SYMBOLS_REGEX, DOUBLE_QUOTE_REGEX, BATCH_RESPONSE_HEADERS_REGEX, HTTP_STATUS_REGEX, CONTENT_TYPE_PLAIN_REGEX, ODATA_ENTITYID_REGEX, TEXT_REGEX, LINE_ENDING_REGEX, SEARCH_FOR_ENTITY_NAME_REGEX, SPECIAL_COLLECTION_FOR_UPDATE_REGEX, FETCH_XML_TOP_REGEX, FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, DATE_FORMAT_REGEX, SEARCH_SPECIAL_CHARACTERS_REGEX, PREFER_CALLBACK_URL_REGEX; var init_Regex = __esm({ "src/helpers/Regex.ts"() { "use strict"; @@ -118,7 +118,6 @@ var _dynamicsWebApiExports = (() => { QUOTATION_MARK_REGEX = /(["'].*?["'])/; PAGING_COOKIE_REGEX = /pagingcookie="()/; SPECIAL_CHARACTER_REGEX = /[<>"']/g; - LEADING_SLASH_REGEX = /^\//; UNICODE_SYMBOLS_REGEX = /[\u007F-\uFFFF]/g; DOUBLE_QUOTE_REGEX = /"/g; BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/; @@ -264,6 +263,9 @@ var _dynamicsWebApiExports = (() => { } return bytes; } + function toAbsoluteUrl(client, value) { + return `${client.config.dataApi.url}${removeLeadingSlash(value)}`; + } var downloadChunkSize; var init_Utility = __esm({ "src/utils/Utility.ts"() { @@ -1430,13 +1432,15 @@ var _dynamicsWebApiExports = (() => { return value; }; const stringifiedData = JSON.stringify(data, (key, value) => { - if (key.endsWith("@odata.bind") || key.endsWith("@odata.id")) { + if (key === "@odata.id" || key.endsWith("@odata.bind")) { if (typeof value === "string" && !value.startsWith("$")) { value = removeCurlyBracketsFromUuid(value); if (config.useEntityNames) { value = replaceEntityNameWithCollectionName(value); } - value = addFullWebApiUrl(key, value); + if (key !== "@odata.id") { + value = addFullWebApiUrl(key, value); + } } } else if (key.startsWith("oData") || key.endsWith("_Formatted") || key.endsWith("_NavigationProperty") || key.endsWith("_LogicalName")) { return void 0; @@ -1734,7 +1738,7 @@ ${processData(internalRequest.data, config)}`); if (!client.isBatch || client.isBatch && !request.relatedKey.startsWith("$")) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); internalRequest.method = "POST"; @@ -1759,7 +1763,7 @@ ${processData(internalRequest.data, config)}`); if (!client.isBatch || client.isBatch && !request.relatedKey.startsWith("$")) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME2, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME2, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); internalRequest.method = "PUT"; @@ -2904,6 +2908,7 @@ ${processData(internalRequest.data, config)}`); } // src/dynamics-web-api.ts + init_Utility(); var _client; var _DynamicsWebApi = class _DynamicsWebApi { /** @@ -3312,7 +3317,13 @@ ${processData(internalRequest.data, config)}`); * @param {string} entityName entity name * @returns {string | null} collection name */ - getCollectionName: (entityName) => getCollectionName(entityName) + getCollectionName: (entityName) => getCollectionName(entityName), + /** + * Adds an absolute Web API URL to the beginning of a provided value. + * @param value The value to modify. + * @returns The absolute URL. + */ + toAbsoluteUrl: (value) => toAbsoluteUrl(__privateGet(this, _client), value) }; __privateSet(this, _client, new DataverseClient(config)); } diff --git a/dist/dynamics-web-api.js.map b/dist/dynamics-web-api.js.map index 25f30c9..3a15c80 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/parseBatchResponse.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/requests/constants.ts", "../src/client/RequestClient.ts", "../src/client/helpers/entityNameMapper.ts", "../src/client/helpers/executeRequest.ts", "../src/client/request/composers/url.ts", "../src/client/request/composers/headers.ts", "../src/client/request/composers/preferHeader.ts", "../src/client/request/composers/request.ts", "../src/client/request/processData.ts", "../src/client/helpers/index.ts", "../src/client/request/setStandardHeaders.ts", "../src/client/request/convertToBatch.ts", "../src/client/dataverse.ts", "../src/requests/associate.ts", "../src/requests/associateSingleValued.ts", "../src/requests/callAction.ts", "../src/requests/callFunction.ts", "../src/requests/create.ts", "../src/requests/count.ts", "../src/requests/countAll.ts", "../src/requests/retrieveAll.ts", "../src/requests/retrieveMultiple.ts", "../src/requests/disassociate.ts", "../src/requests/disassociateSingleValued.ts", "../src/requests/retrieve.ts", "../src/requests/fetchXml.ts", "../src/requests/fetchXmlAll.ts", "../src/requests/update.ts", "../src/requests/updateSingleProperty.ts", "../src/requests/upsert.ts", "../src/requests/delete.ts", "../src/requests/uploadFile.ts", "../src/requests/downloadFile.ts", "../src/requests/executeBatch.ts", "../src/requests/metadata/createEntity.ts", "../src/requests/metadata/updateEntity.ts", "../src/requests/metadata/retrieveEntity.ts", "../src/requests/metadata/retrieveEntities.ts", "../src/requests/metadata/createAttribute.ts", "../src/requests/metadata/updateAttribute.ts", "../src/requests/metadata/retrieveAttributes.ts", "../src/requests/metadata/retrieveAttribute.ts", "../src/requests/metadata/createRelationship.ts", "../src/requests/metadata/updateRelationship.ts", "../src/requests/metadata/deleteRelationship.ts", "../src/requests/metadata/retrieveRelationships.ts", "../src/requests/metadata/retrieveRelationship.ts", "../src/requests/metadata/createGlobalOptionSet.ts", "../src/requests/metadata/updateGlobalOptionSet.ts", "../src/requests/metadata/deleteGlobalOptionSet.ts", "../src/requests/metadata/retrieveGlobalOptionSet.ts", "../src/requests/metadata/retrieveGlobalOptionSets.ts", "../src/requests/metadata/retrieveCsdlMetadata.ts", "../src/requests/search/query.ts", "../src/requests/search/convertSearchQuery.ts", "../src/requests/search/responseParsers/parseQueryResponse.ts", "../src/requests/search/suggest.ts", "../src/requests/search/responseParsers/parseSuggestResponse.ts", "../src/requests/search/autocomplete.ts", "../src/requests/search/responseParsers/parseAutocompleteResponse.ts", "../src/requests/backgroundOperation/getStatus.ts", "../src/requests/backgroundOperation/cancel.ts"], - "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? (global.window.crypto as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nconst LEADING_SLASH_REGEX = /^\\//;\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.replace(LEADING_SLASH_REGEX, \"\");\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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", "\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): Record {\r\n\tconst headers: Record = {};\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 type * as 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 headers = options.headers;\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 headers) {\r\n request.setRequestHeader(key, headers[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 if (!request || request.status === 0) return; // response was handled elsewhere or will be handled by onerror\r\n\r\n if ((request.status >= 200 && request.status < 300) || request.status === 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 } else {\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 return;\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 }\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 { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\r\n};\r\n", "import { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const 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 value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,WAAS,YAAwB;AACpC,WAAO,OAAsB,OAAc,SAAe,KAAyB,UAAU;AAAA,EACjG;AAFA;AAAA;AAAA;AAAA;AAAA;;;ACWO,WAAS,OAAO,OAAwB;AAC3C,UAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,WAAO,CAAC,CAAC;AAAA,EACb;AAEO,WAAS,YAAY,OAA8B;AACtD,UAAM,QAAQ,mBAAmB,KAAK,KAAK;AAC3C,WAAO,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC9B;AAEO,WAAS,mBAAmB,KAA6B;AAC5D,QAAI,CAAC,IAAK,QAAO;AACjB,UAAM,QAAQ,4BAA4B,KAAK,GAAG;AAClD,WAAO,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC9B;AAEO,WAAS,4BAA4B,OAAuB;AAC/D,WAAO,MAAM,QAAQ,iCAAiC,CAAC,QAAQ,OAAO,EAAE;AAAA,EAC5E;AASO,WAAS,iCAAiC,KAAqB;AAIlE,UAAM,QAAQ,IAAI,MAAM,oBAAoB;AAC5C,WAAO,MACF,IAAI,CAAC,MAAM,UAAU;AAElB,UAAI,QAAQ,MAAM,GAAG;AACjB,eAAO,4BAA4B,IAAI;AAAA,MAC3C;AACA,aAAO;AAAA,IACX,CAAC,EACA,KAAK,EAAE;AAAA,EAChB;AAOO,WAAS,yBAAyB,cAAoD;AACzF,UAAM,SAAS,kBAAkB,KAAK,aAAa,WAAW,CAAC;AAC/D,WAAO,EAAE,IAAI,OAAQ,CAAC,GAAG,YAAY,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AS,mBAAK,QAAO;AAOhD;AAAA;AAAA;AAAA;AAAA;AAAA,0CAA+B,OAAO,0BACxB,6BAA6B,uBAAuB,mBAAK,QAAO;AAO9E;AAAA;AAAA;AAAA;AAAA;AAAA,uCAA4B,OAAO,0BACrB,0BAA0B,uBAAuB,mBAAK,QAAO;AAK3E;AAAA;AAAA;AAAA,wBAAa,MAAsB,WAAW,mBAAK,QAAO;AAO1D;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAe,OAAO,YAAqD,aAAa,SAAS,mBAAK,QAAO;AAQ7G;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,mBAAK,SAAQ,MAAM;AAE1G,qBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQN,mBAAmB,CAAC,eAAsC,kBAAkB,UAAU;AAAA,MAC1F;AAldI,yBAAK,SAAU,IAAI,gBAAgB,MAAM;AAAA,IAC7C;AAAA,EAkdJ;AA1dI;AADG,MAAM,iBAAN;", + "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? (global.window.crypto as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.startsWith(\"/\") ? value.slice(1) : value;\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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\nexport function toAbsoluteUrl(client: IDataverseClient, value: string): string {\r\n return `${client.config.dataApi.url}${removeLeadingSlash(value)}`;\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): Record {\r\n\tconst headers: Record = {};\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 type * as 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 headers = options.headers;\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 headers) {\r\n request.setRequestHeader(key, headers[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 if (!request || request.status === 0) return; // response was handled elsewhere or will be handled by onerror\r\n\r\n if ((request.status >= 200 && request.status < 300) || request.status === 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 } else {\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 return;\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 }\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 { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\nimport { toAbsoluteUrl } from \"./utils/Utility\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n\r\n /**\r\n * Adds an absolute Web API URL to the beginning of a provided value.\r\n * @param value The value to modify.\r\n * @returns The absolute URL.\r\n */\r\n toAbsoluteUrl: (value: string): string => toAbsoluteUrl(this.#client,value),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Disables enforcement of absolute URLs for @odata.id properties in the request body.\r\n * In some cases, @odata.id has an alternate key format that does not use absolute URLs, for example:\r\n * In an UpsertMultiple action body.\r\n */\r\n disableODataIdAbsoluteUrl?: boolean;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\r\n};\r\n", "import { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key === \"@odata.id\" || key.endsWith(\"@odata.bind\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n\r\n // the full Web API URL is only added in requests to /$ref\r\n // the value itself is set directly in the requests that require it\r\n if (key !== \"@odata.id\") {\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,WAAS,YAAwB;AACpC,WAAO,OAAsB,OAAc,SAAe,KAAyB,UAAU;AAAA,EACjG;AAFA;AAAA;AAAA;AAAA;AAAA;;;ACWO,WAAS,OAAO,OAAwB;AAC3C,UAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,WAAO,CAAC,CAAC;AAAA,EACb;AAEO,WAAS,YAAY,OAA8B;AACtD,UAAM,QAAQ,mBAAmB,KAAK,KAAK;AAC3C,WAAO,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC9B;AAEO,WAAS,mBAAmB,KAA6B;AAC5D,QAAI,CAAC,IAAK,QAAO;AACjB,UAAM,QAAQ,4BAA4B,KAAK,GAAG;AAClD,WAAO,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC9B;AAEO,WAAS,4BAA4B,OAAuB;AAC/D,WAAO,MAAM,QAAQ,iCAAiC,CAAC,QAAQ,OAAO,EAAE;AAAA,EAC5E;AASO,WAAS,iCAAiC,KAAqB;AAIlE,UAAM,QAAQ,IAAI,MAAM,oBAAoB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iBAAN;", "names": ["count", "headers", "executeRequest", "headers", "batchBody", "executeRequest", "FUNCTION_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "request", "isObject", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "query", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME"] } diff --git a/dist/dynamics-web-api.min.js b/dist/dynamics-web-api.min.js index 528717a..f7944df 100644 --- a/dist/dynamics-web-api.min.js +++ b/dist/dynamics-web-api.min.js @@ -1,15 +1,15 @@ -/*! dynamics-web-api v2.3.2 (c) 2025 Aleksandr Rogov. License: MIT */ -"use strict";var _dynamicsWebApiExports=(()=>{var Ce=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Dn=Object.getOwnPropertyNames;var In=Object.prototype.hasOwnProperty;var ze=e=>{throw TypeError(e)};var b=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ye=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},kn=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Dn(t))!In.call(e,n)&&n!==r&&Ce(e,n,{get:()=>t[n],enumerable:!(o=Pn(t,n))||o.enumerable});return e};var Je=e=>kn(Ce({},"__esModule",{value:!0}),e);var je=(e,t,r)=>t.has(e)||ze("Cannot "+r);var m=(e,t,r)=>(je(e,t,"read from private field"),r?r.call(e):t.get(e)),B=(e,t,r)=>t.has(e)?ze("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),L=(e,t,r,o)=>(je(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);function Ze(){return window.crypto}var et=b(()=>{"use strict"});function tt(e){return!!Sn.exec(e)}function V(e){let t=On.exec(e);return t?t[1]:null}function Z(e){if(!e)return null;let t=Mn.exec(e);return t?t[1]:null}function Ae(e){return e.replace(Un,(t,r)=>r)}function rt(e){return e.split($n).map((r,o)=>o%2===0?Ae(r):r).join("")}function nt(e){let t=_n.exec(e["@odata.id"]);return{id:t[2],collection:t[1],oDataContext:e["@odata.context"]}}function ot(e){let t=wn.exec(e);if(!t)return null;let r=parseInt(t[2],10),o=Fn(t[1]);return{page:r,sanitizedCookie:o}}function Fn(e){let t={"<":"<",">":">",'"':""","'":"'"};return e.replace(Bn,r=>t[r])}function at(e){return e.replace(qn,"")}function it(e){return e.replace(Hn,t=>`\\u${("0000"+t.charCodeAt(0).toString(16)).slice(-4)}`)}function Ee(e){return e.replace(Qn,"")}function mt(e){return Ln.test(e??"")?"PUT":"PATCH"}function Rt(e){return e.replace(Wn,"\\$&")}function gt(e){let t=Vn.exec(e);return t?t[1]:null}var W,Sn,On,Mn,Un,_n,$n,wn,Bn,qn,Hn,Qn,st,xe,pt,ct,lt,ee,be,Ln,ut,ft,dt,yt,Wn,Vn,h=b(()=>{"use strict";W="[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}",Sn=new RegExp(W,"i"),On=new RegExp("^{?("+W+")}?$","i"),Mn=new RegExp("("+W+")\\)$","i"),Un=new RegExp(`{(${W})}`,"g"),_n=new RegExp(`\\/(\\w+)\\((${W})`,"i");$n=/(["'].*?["'])/;wn=/pagingcookie="()/,Bn=/[<>"']/g;qn=/^\//;Hn=/[\u007F-\uFFFF]/g;Qn=/"/g;st=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/,xe=/HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/m,pt=/Content-Type: text\/plain/i,ct=/OData-EntityId.+/i,lt=/\w+$/g,ee=/\r?\n/,be=/(\w+)(\([\d\w-]+\))$/,Ln=/EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;ut=/^{let s=e[n];if(s==null)return;s=Gn(s);let p=i+1;r.push(`${n}=@p${p}`),o.push(`@p${p}=${V(s)||s}`)}),{key:`(${r.join(",")})`,queryParams:o}}function ht(e,t){return e.hasOwnProperty(t)||e.hasOwnProperty(t.toLowerCase())}function G(e,t){return e[t]?e[t]:e[t.toLowerCase()]}function Ct(e){return e?Xn(e):{key:"()"}}function At(e="",t=1){e=decodeURIComponent(decodeURIComponent(e));let r=ot(e);return{cookie:r?.sanitizedCookie||"",page:r?.page||t,nextPage:r?.page?r.page+1:t+1}}function R(e){return typeof e>"u"||e==null}function O(){return Ze().randomUUID()}function Kn(){if(typeof GetGlobalContext<"u")return GetGlobalContext();if(typeof Xrm<"u"){if(!R(Xrm.Utility)&&!R(Xrm.Utility.getGlobalContext))return Xrm.Utility.getGlobalContext();if(!R(Xrm.Page)&&!R(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.")}function Et(){let t=Kn().getClientUrl();return t.match(/\/$/)&&(t=t.substring(0,t.length-1)),t}function te(){return!!window.shell}function zn(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&Object.prototype.toString.call(e)!=="[object Date]"}function T(e,t){let r={};for(let o in e)e.hasOwnProperty(o)&&!t?.includes(o)&&(zn(e[o])?r[o]=T(e[o]):Array.isArray(e[o])?r[o]=e[o].slice():r[o]=e[o]);return r}function l(e,t=[]){t.includes("signal")||t.push("signal");let r=T(e,t);return r.signal=e.signal,r}function xt(e,t,r,o){o=o||0;let n=o+r>t.length?t.length%r:r,i;i=new Uint8Array(n);for(let s=0;s{"use strict";et();h();Te=4194304});function D(e,t,r){throw new Error(r?`${e} requires a ${t} parameter to be of type ${r}.`:`${e} requires a ${t} parameter.`)}var a,u=b(()=>{"use strict";h();a=class e{static handleErrorResponse(t){throw new Error(`Error: ${t.status}: ${t.message}`)}static parameterCheck(t,r,o,n){(typeof t>"u"||t===null||t==="")&&D(r,o,n)}static stringParameterCheck(t,r,o){typeof t!="string"&&D(r,o,"String")}static maxLengthStringParameterCheck(t,r,o,n){if(t&&t.length>n)throw new Error(`${o} has a ${n} character limit.`)}static arrayParameterCheck(t,r,o){t.constructor!==Array&&D(r,o,"Array")}static stringOrArrayParameterCheck(t,r,o){t.constructor!==Array&&typeof t!="string"&&D(r,o,"String or Array")}static numberParameterCheck(t,r,o){if(typeof t!="number"){if(typeof t=="string"&&t&&!isNaN(parseInt(t)))return;D(r,o,"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(t,r){let o=new Error;return Object.keys(t).forEach(n=>{o[n]=t[n]}),r&&Object.keys(r).forEach(n=>{o[n]=r[n]}),o}static boolParameterCheck(t,r,o){typeof t!="boolean"&&D(r,o,"Boolean")}static guidParameterCheck(t,r,o){let n=V(t);return n||D(r,o,"GUID String"),n}static keyParameterCheck(t,r,o){try{e.stringParameterCheck(t,r,o);let n=V(t);if(n)return n;let i=t.split(",");if(i.length)for(let s=0;s{"use strict";re=class re{};re.Prefer=(X=class{static get(t){return`${re.Prefer.IncludeAnnotations}="${t}"`}},X.ReturnRepresentation="return=representation",X.Annotations=(M=class{},M.AssociatedNavigationProperty="Microsoft.Dynamics.CRM.associatednavigationproperty",M.LookupLogicalName="Microsoft.Dynamics.CRM.lookuplogicalname",M.All="*",M.FormattedValue="OData.Community.Display.V1.FormattedValue",M.FetchXmlPagingCookie="Microsoft.Dynamics.CRM.fetchxmlpagingcookie",M),X.IncludeAnnotations="odata.include-annotations",X);k=re});function S(e,t){if(typeof t=="string"){let r=yt.exec(t);if(r)return new Date(Date.UTC(+r[1],+r[2]-1,+r[3],+r[4],+r[5],+r[6]))}return t}var Ne=b(()=>{"use strict";h()});function to(e){let t={position:0},r={},o,n,i;do{if(i=t.position,n=ro(e,t),!n)break;o=st.exec(n),o!==null?r[o[1].toLowerCase()]=o[2]:t.position=i}while(n&&o);return r}function ro(e,t){return no(e,t,ee)}function no(e,t,r){let o=t.position||0,n=e.slice(o),i=r.exec(n);if(!i)return null;let s=o+i.index;return t.position=s+i[0].length,e.substring(o,s)}function oo(e){let t=xe.exec(e);return{httpStatusString:t[0],httpStatus:parseInt(t[1]),httpStatusMessage:t[2].trim()}}function ao(e){xe.lastIndex=0;let t=lt.exec(e.trim());return t?.length?t[0]:void 0}function io(e,t,r){let o=ao(e);return ke(o)}function so(e,t,r){if(t?.[r]?.valueIfEmpty!==void 0)return t[r].valueIfEmpty;{let o=ct.exec(e);return Z(o?.[0])??void 0}}function po(e,t,r){let{httpStatusString:o,httpStatus:n,httpStatusMessage:i}=oo(e),s=e.substring(e.indexOf("{"),e.lastIndexOf("}")+1);if(!s)return pt.test(e)?io(e,t,r):so(e,t,r);let p=Ie(s,t,r);if(n<400)return p;let E=to(e.substring(e.indexOf(o)+o.length+1,e.indexOf("{")));return a.handleHttpError(p,{status:n,statusText:i,statusMessage:i,headers:E})}function Pe(e,t,r=0){let o=e.substring(0,e.search(ee)),n=e.split(o);n.shift(),n.pop();let i=[];for(let s of n){if(s.indexOf("--changesetresponse_")===-1){i.push(po(s,t,r++));continue}s=s.trim();let p=s.substring(s.search(ee)+1).trim();i=i.concat(Pe(p,t,r++))}return i}var De=b(()=>{"use strict";u();h();ne()});function Se(e,t){let r=null;if(e.indexOf("@")!==-1){let o=e.split("@");switch(o[1]){case"odata.context":r="oDataContext";break;case"odata.count":r="oDataCount",t=t!=null?parseInt(t):0;break;case"odata.nextLink":r="oDataNextLink";break;case"odata.deltaLink":r="oDataDeltaLink";break;case k.Prefer.Annotations.FormattedValue:r=o[0]+"_Formatted";break;case k.Prefer.Annotations.AssociatedNavigationProperty:r=o[0]+"_NavigationProperty";break;case k.Prefer.Annotations.LookupLogicalName:r=o[0]+"_LogicalName";break}}return[r,t]}function Oe(e,t){if(t){if(t.isRef&&e["@odata.id"]!=null)return nt(e);if(t.toCount)return Se("@odata.count",e["@odata.count"])[1]||0}for(let o in e){if(e[o]!=null)if(Array.isArray(e[o]))for(var r=0;r-1}function uo(e){return ht(e,"Content-Disposition")}function fo(e){return G(e,"Content-Type")?.startsWith("application/json")==!0}function yo(e,t){let r=Pe(e,t);return t?.[0].convertedToBatch?r[0]:r}function Ro(e,t,r){return lo(e,t,r[0])}function Ie(e,t,r=0){return Oe(JSON.parse(e,S),t[r])}function ke(e){let t=Number(e);return isFinite(t)?t:e}function go(e,t){if(t?.[0]?.valueIfEmpty!==void 0)return t[0].valueIfEmpty;let r=G(e,"OData-EntityId");if(r)return Z(r)??void 0;let o=G(e,"Location");if(o){let n={location:o};return e["x-ms-chunk-size"]&&(n.chunkSize=parseInt(e["x-ms-chunk-size"])),e["x-ms-dyn-backgroundoperationid"]&&(n.backgroundOperationId=e["x-ms-dyn-backgroundoperationid"]),n}}function Me(e,t,r){return e.length?mo(e)?yo(e,r):uo(t)?Ro(e,t,r):fo(t)?Ie(e,r):ke(e):go(t,r)}var ne=b(()=>{"use strict";Nt();d();Ne();h();De()});function U(e){let t={};if(!e)return t;let r=e.split(`\r -`);for(let o=0,n=r.length;o0&&(t[i.substring(0,s)]=i.substring(s+2))}return t}var Ue=b(()=>{"use strict"});var Pt={};Ye(Pt,{XhrWrapper:()=>K,executeRequest:()=>ho});function ho(e){return new Promise((t,r)=>{Co(e,t,r)})}function Co(e,t,r){let o=e.data,n=e.headers,i=e.responseParams,s=e.abortSignal;if(s?.aborted){r(a.handleHttpError({name:"AbortError",code:20,message:"The user aborted a request."}));return}let p=new XMLHttpRequest;p.open(e.method,e.uri,e.isAsync||!1);for(let y in n)p.setRequestHeader(y,n[y]);p.onreadystatechange=function(){if(p.readyState===4){if(s&&s.removeEventListener("abort",E),!p||p.status===0)return;if(p.status>=200&&p.status<300||p.status===304){let y=U(p.getAllResponseHeaders()),x={data:Me(p.responseText,y,i[e.requestId]),headers:y,status:p.status};p=null,t(x)}else{let y,A;try{A=U(p.getAllResponseHeaders());let j=Me(p.responseText,A,i[e.requestId]);if(Array.isArray(j)){r(j);return}y=j.error}catch{p.response.length>0?y={message:p.response}:y={message:"Unexpected Error"}}let x={status:p.status,statusText:p.statusText,headers:A};p=null,r(a.handleHttpError(y,x))}}},e.timeout&&(p.timeout=e.timeout),p.onerror=function(){let y=U(p.getAllResponseHeaders());r(a.handleHttpError({status:p.status,statusText:p.statusText,message:p.responseText||"Network Error",headers:y})),p=null},p.ontimeout=function(){let y=U(p.getAllResponseHeaders());r(a.handleHttpError({name:"TimeoutError",status:p.status,statusText:p.statusText,message:p.responseText||"Request Timed Out",headers:y})),p=null},p.onabort=function(){if(!p)return;let y=U(p.getAllResponseHeaders());r(a.handleHttpError({status:p.status,statusText:p.statusText,message:"Request aborted",headers:y})),p=null};let E=()=>{if(!p)return;let y=U(p.getAllResponseHeaders());r(a.handleHttpError({name:"AbortError",code:20,status:p.status,statusText:p.statusText,message:"The user aborted a request.",headers:y})),p.abort(),p=null};s&&s.addEventListener("abort",E),o?p.send(o):p.send(),K.afterSendEvent&&K.afterSendEvent()}var K,Dt=b(()=>{"use strict";u();ne();Ue();K=class{}});var Jo={};Ye(Jo,{DynamicsWebApi:()=>Xe});d();u();var c="DynamicsWebApi";var g=`${c}.setConfig`,Yn=["dataApi","searchApi","serviceApi"],Jn=(e,t)=>{if(te())return new URL("_api",window.location.origin).toString()+"/";{e||(e=Et());let r="api";return t.path&&(r+=`/${t.path}`),t.version&&(r+=`/v${t.version}`),new URL(r,e).toString()+"/"}},jn=(e,t)=>{t&&(t.escapeSpecialCharacters!=null&&(a.boolParameterCheck(t.escapeSpecialCharacters,g,"config.searchApi.options.escapeSpecialCharacters"),e.escapeSpecialCharacters=t.escapeSpecialCharacters),t.enableResponseCompatibility!=null&&(a.boolParameterCheck(t.enableResponseCompatibility,g,"config.searchApi.options.enableResponseCompatibility"),e.enableSearchApiResponseCompatibility=t.enableResponseCompatibility))},Zn=(e,t,r)=>{let o=e[t],n=r?.[t];n?.version&&(a.stringParameterCheck(n.version,g,`config.${t}.version`),o.version=n.version),n?.path&&(a.stringParameterCheck(n.path,g,`config.${t}.path`),o.path=n.path),t==="searchApi"&&jn(o,n?.options),o.url=Jn(e.serverUrl,o)};function ve(e,t){t?.serverUrl&&(a.stringParameterCheck(t.serverUrl,g,"config.serverUrl"),e.serverUrl=t.serverUrl),Yn.forEach(r=>{Zn(e,r,t)}),t?.impersonate&&(e.impersonate=a.guidParameterCheck(t.impersonate,g,"config.impersonate")),t?.impersonateAAD&&(e.impersonateAAD=a.guidParameterCheck(t.impersonateAAD,g,"config.impersonateAAD")),t?.onTokenRefresh&&(a.callbackParameterCheck(t.onTokenRefresh,g,"config.onTokenRefresh"),e.onTokenRefresh=t.onTokenRefresh),t?.includeAnnotations&&(a.stringParameterCheck(t.includeAnnotations,g,"config.includeAnnotations"),e.includeAnnotations=t.includeAnnotations),t?.timeout&&(a.numberParameterCheck(t.timeout,g,"config.timeout"),e.timeout=t.timeout),t?.maxPageSize&&(a.numberParameterCheck(t.maxPageSize,g,"config.maxPageSize"),e.maxPageSize=t.maxPageSize),t?.returnRepresentation!=null&&(a.boolParameterCheck(t.returnRepresentation,g,"config.returnRepresentation"),e.returnRepresentation=t.returnRepresentation),t?.useEntityNames!=null&&(a.boolParameterCheck(t.useEntityNames,g,"config.useEntityNames"),e.useEntityNames=t.useEntityNames),t?.headers&&(e.headers=t.headers)}function Tt(){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:""},serviceApi:{url:""}}}d();d();var I=null,vt=e=>{I=e},F=e=>{if(R(I))return null;let t=I[e];if(!t){for(let r in I)if(I[r]===e)return e}return t};async function It(e){return(Dt(),Je(Pt)).executeRequest(e)}u();u();h();d();var _e=(e,t,r="",o="&")=>{let n=[];if(e){if(e.navigationProperty){if(a.stringParameterCheck(e.navigationProperty,`DynamicsWebApi.${e.functionName}`,"request.navigationProperty"),r+="/"+e.navigationProperty,e.navigationPropertyKey){let i=a.keyParameterCheck(e.navigationPropertyKey,`DynamicsWebApi.${e.functionName}`,"request.navigationPropertyKey");r+="("+i+")"}e.navigationProperty==="Attributes"&&e.metadataAttributeType&&(a.stringParameterCheck(e.metadataAttributeType,`DynamicsWebApi.${e.functionName}`,"request.metadataAttributeType"),r+="/"+e.metadataAttributeType)}if(e.select?.length&&(a.arrayParameterCheck(e.select,`DynamicsWebApi.${e.functionName}`,"request.select"),e.functionName=="retrieve"&&e.select.length==1&&e.select[0].endsWith("/$ref")?r+="/"+e.select[0]:(e.select[0].startsWith("/")&&e.functionName=="retrieve"&&(e.navigationProperty==null?r+=e.select.shift():e.select.shift()),e.select.length&&n.push("$select="+e.select.join(",")))),e.filter){a.stringParameterCheck(e.filter,`DynamicsWebApi.${e.functionName}`,"request.filter");let i=rt(e.filter);n.push("$filter="+encodeURIComponent(i))}if(e.fieldName&&(a.stringParameterCheck(e.fieldName,`DynamicsWebApi.${e.functionName}`,"request.fieldName"),e.property||(e.property=e.fieldName),delete e.fieldName),e.property&&(a.stringParameterCheck(e.property,`DynamicsWebApi.${e.functionName}`,"request.property"),r+="/"+e.property),e.savedQuery&&n.push("savedQuery="+a.guidParameterCheck(e.savedQuery,`DynamicsWebApi.${e.functionName}`,"request.savedQuery")),e.userQuery&&n.push("userQuery="+a.guidParameterCheck(e.userQuery,`DynamicsWebApi.${e.functionName}`,"request.userQuery")),e.apply&&(a.stringParameterCheck(e.apply,`DynamicsWebApi.${e.functionName}`,"request.apply"),n.push("$apply="+e.apply)),e.count&&(a.boolParameterCheck(e.count,`DynamicsWebApi.${e.functionName}`,"request.count"),n.push("$count="+e.count)),e.top&&e.top>0&&(a.numberParameterCheck(e.top,`DynamicsWebApi.${e.functionName}`,"request.top"),n.push("$top="+e.top)),e.orderBy!=null&&e.orderBy.length&&(a.arrayParameterCheck(e.orderBy,`DynamicsWebApi.${e.functionName}`,"request.orderBy"),n.push("$orderby="+e.orderBy.join(","))),e.partitionId&&(a.stringParameterCheck(e.partitionId,`DynamicsWebApi.${e.functionName}`,"request.partitionId"),n.push("partitionid='"+e.partitionId+"'")),e.downloadSize&&(a.stringParameterCheck(e.downloadSize,`DynamicsWebApi.${e.functionName}`,"request.downloadSize"),n.push("size="+e.downloadSize)),e.tag&&(a.stringParameterCheck(e.tag,`DynamicsWebApi.${e.functionName}`,"request.tag"),n.push("tag="+encodeURIComponent(e.tag))),e.queryParams?.length&&(a.arrayParameterCheck(e.queryParams,`DynamicsWebApi.${e.functionName}`,"request.queryParams"),n.push(e.queryParams.join("&"))),e.fileName&&(a.stringParameterCheck(e.fileName,`DynamicsWebApi.${e.functionName}`,"request.fileName"),n.push("x-ms-file-name="+e.fileName)),e.data&&a.parameterCheck(e.data,`DynamicsWebApi.${e.functionName}`,"request.data"),e.isBatch&&a.boolParameterCheck(e.isBatch,`DynamicsWebApi.${e.functionName}`,"request.isBatch"),e.fetchXml&&(a.stringParameterCheck(e.fetchXml,`DynamicsWebApi.${e.functionName}`,"request.fetchXml"),n.push("fetchXml="+encodeURIComponent(e.fetchXml))),R(e.inChangeSet)||a.boolParameterCheck(e.inChangeSet,`DynamicsWebApi.${e.functionName}`,"request.inChangeSet"),e.isBatch&&R(e.inChangeSet)&&(e.inChangeSet=!0),e.timeout&&a.numberParameterCheck(e.timeout,`DynamicsWebApi.${e.functionName}`,"request.timeout"),e.expand?.length)if(a.stringOrArrayParameterCheck(e.expand,`DynamicsWebApi.${e.functionName}`,"request.expand"),typeof e.expand=="string")n.push("$expand="+e.expand);else{let i=[];for(let{property:s,...p}of e.expand){if(!s)continue;let E={functionName:`${e.functionName} $expand`,...p},y=_e(E,t,"",";");y&&(y=`(${y})`),i.push(s+y)}i.length&&n.push("$expand="+i.join(","))}}return n.length?(o==="&"&&(r+="?"),r+n.join(o)):r};u();u();h();var kt=(e,t)=>{let r=`DynamicsWebApi.${e.functionName}`,o={respondAsync:e.respondAsync,backgroundOperationCallbackUrl:e.backgroundOperationCallbackUrl??t?.backgroundOperationCallbackUrl,returnRepresentation:e.returnRepresentation??t?.returnRepresentation,includeAnnotations:e.includeAnnotations??t?.includeAnnotations,maxPageSize:e.maxPageSize??t?.maxPageSize,trackChanges:e.trackChanges,continueOnError:e.continueOnError},n=new Set;if(e.prefer?.length){a.stringOrArrayParameterCheck(e.prefer,r,"request.prefer");let i=typeof e.prefer=="string"?e.prefer.split(","):e.prefer;for(let s of i){let p=s.trim();p.includes("respond-async")?o.respondAsync=!0:p.startsWith("odata.callback")?o.backgroundOperationCallbackUrl=gt(p):p==="return=representation"?o.returnRepresentation=!0:p.includes("odata.include-annotations=")?o.includeAnnotations=Ee(p.replace("odata.include-annotations=","")):p.startsWith("odata.maxpagesize=")?o.maxPageSize=Number(Ee(p.replace("odata.maxpagesize=","")))||0:p.includes("odata.track-changes")?o.trackChanges=!0:p.includes("odata.continue-on-error")?o.continueOnError=!0:n.add(p)}}for(let i in o){let s=Ao[i];s&&o[i]&&(s.validator?.(o[i],r,`request.${i}`),s.condition(o[i],o)&&n.add(s.formatter(o[i],o)))}return Array.from(n).join(",")},Ao={respondAsync:{validator:a.boolParameterCheck,condition:e=>!!e,formatter:()=>"respond-async"},backgroundOperationCallbackUrl:{validator:a.stringParameterCheck,condition:(e,t)=>e&&t.respondAsync,formatter:e=>`odata.callback;url="${e}"`},returnRepresentation:{validator:a.boolParameterCheck,condition:e=>!!e,formatter:()=>"return=representation"},includeAnnotations:{validator:a.stringParameterCheck,condition:e=>!!e,formatter:e=>`odata.include-annotations="${e}"`},maxPageSize:{validator:(e,t)=>e>0?a.numberParameterCheck(e,t,"request.maxPageSize"):void 0,condition:e=>e>0,formatter:e=>`odata.maxpagesize=${e}`},trackChanges:{validator:a.boolParameterCheck,condition:e=>!!e,formatter:()=>"odata.track-changes"},continueOnError:{validator:a.boolParameterCheck,condition:e=>!!e,formatter:()=>"odata.continue-on-error"}};var St=(e,t)=>{let r={...t.headers,...e.userHeaders},o=kt(e,t);if(o.length&&(r.Prefer=o),e.collection==="$metadata"&&(r.Accept="application/xml"),e.transferMode&&(r["x-ms-transfer-mode"]=e.transferMode),e.ifmatch!=null&&e.ifnonematch!=null)throw new Error(`DynamicsWebApi.${e.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`);return e.ifmatch&&(a.stringParameterCheck(e.ifmatch,`DynamicsWebApi.${e.functionName}`,"request.ifmatch"),r["If-Match"]=e.ifmatch),e.ifnonematch&&(a.stringParameterCheck(e.ifnonematch,`DynamicsWebApi.${e.functionName}`,"request.ifnonematch"),r["If-None-Match"]=e.ifnonematch),e.impersonate&&(a.stringParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate"),r.MSCRMCallerID=a.guidParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate")),e.impersonateAAD&&(a.stringParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD"),r.CallerObjectId=a.guidParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD")),e.token&&(a.stringParameterCheck(e.token,`DynamicsWebApi.${e.functionName}`,"request.token"),r.Authorization="Bearer "+e.token),e.duplicateDetection&&(a.boolParameterCheck(e.duplicateDetection,`DynamicsWebApi.${e.functionName}`,"request.duplicateDetection"),r["MSCRM.SuppressDuplicateDetection"]="false"),e.bypassCustomPluginExecution&&(a.boolParameterCheck(e.bypassCustomPluginExecution,`DynamicsWebApi.${e.functionName}`,"request.bypassCustomPluginExecution"),r["MSCRM.BypassCustomPluginExecution"]="true"),e.noCache&&(a.boolParameterCheck(e.noCache,`DynamicsWebApi.${e.functionName}`,"request.noCache"),r["Cache-Control"]="no-cache"),e.mergeLabels&&(a.boolParameterCheck(e.mergeLabels,`DynamicsWebApi.${e.functionName}`,"request.mergeLabels"),r["MSCRM.MergeLabels"]="true"),e.contentId&&(a.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")||(r["Content-ID"]=e.contentId)),e.contentRange&&(a.stringParameterCheck(e.contentRange,`DynamicsWebApi.${e.functionName}`,"request.contentRange"),r["Content-Range"]=e.contentRange),e.range&&(a.stringParameterCheck(e.range,`DynamicsWebApi.${e.functionName}`,"request.range"),r.Range=e.range),r};u();var oe=(e,t)=>(e.path="",e.functionName=e.functionName||"",e.url?(a.stringParameterCheck(e.url,`DynamicsWebApi.${e.functionName}`,"request.url"),e.path=e.url.replace(t.dataApi.url,"")):(!e._isUnboundRequest&&!e.contentId&&!e.collection&&a.parameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.contentId&&(a.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")&&(e.path=e.contentId)),e.collection!=null&&(a.stringParameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.path+=e.path?`/${e.collection}`:e.collection,e.key&&(e.key=a.keyParameterCheck(e.key,`DynamicsWebApi.${e.functionName}`,"request.key"),e.path+=`(${e.key})`)),e.addPath&&(e.path&&(e.path+="/"),e.path+=e.addPath),e.path=_e(e,t,e.path)),e.hasOwnProperty("async")&&e.async!=null?a.boolParameterCheck(e.async,`DynamicsWebApi.${e.functionName}`,"request.async"):e.async=!0,e.headers=St(e,t),e);h();d();Ne();De();ne();Ue();var ae=(e,t)=>{if(!e)return null;if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array)return e;let r=i=>{let s=be.exec(i);if(s&&s.length>2){let p=F(s[1]);if(!R(p))return i.replace(be,`${p}$2`)}return i},o=(i,s)=>(s.startsWith(t.dataApi.url)||(i.endsWith("@odata.bind")?s.startsWith("/")||(s=`/${s}`):s=`${t.dataApi.url}${at(s)}`),s),n=JSON.stringify(e,(i,s)=>{if(i.endsWith("@odata.bind")||i.endsWith("@odata.id"))typeof s=="string"&&!s.startsWith("$")&&(s=Ae(s),t.useEntityNames&&(s=r(s)),s=o(i,s));else if(i.startsWith("oData")||i.endsWith("_Formatted")||i.endsWith("_NavigationProperty")||i.endsWith("_LogicalName"))return;return s});return it(n)};var ie=(e={},t)=>(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"]&&t&&(e["Content-Type"]="application/json; charset=utf-8"),e);d();var $e=(e,t,r)=>{let o=`dwa_batch_${O()}`,n=[],i=null,s=1e5,p=(y,A)=>{for(let x in y)x==="Authorization"||x==="Content-ID"||A.push(`${x}: ${y[x]}`)};e.forEach(y=>{y.functionName="executeBatch",r?.inChangeSet===!1&&(y.inChangeSet=!1);let A=y.method==="GET"?!1:!!y.inChangeSet;if(!A&&i&&(n.push(`\r +/*! dynamics-web-api v2.4.0 (c) 2025 Aleksandr Rogov. License: MIT */ +"use strict";var _dynamicsWebApiExports=(()=>{var Ae=Object.defineProperty;var Dn=Object.getOwnPropertyDescriptor;var In=Object.getOwnPropertyNames;var kn=Object.prototype.hasOwnProperty;var Ye=e=>{throw TypeError(e)};var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var Je=(e,t)=>{for(var r in t)Ae(e,r,{get:t[r],enumerable:!0})},Sn=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of In(t))!kn.call(e,n)&&n!==r&&Ae(e,n,{get:()=>t[n],enumerable:!(o=Dn(t,n))||o.enumerable});return e};var je=e=>Sn(Ae({},"__esModule",{value:!0}),e);var Ze=(e,t,r)=>t.has(e)||Ye("Cannot "+r);var m=(e,t,r)=>(Ze(e,t,"read from private field"),r?r.call(e):t.get(e)),B=(e,t,r)=>t.has(e)?Ye("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),L=(e,t,r,o)=>(Ze(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);function et(){return window.crypto}var tt=x(()=>{"use strict"});function rt(e){return!!On.exec(e)}function V(e){let t=Mn.exec(e);return t?t[1]:null}function Z(e){if(!e)return null;let t=Un.exec(e);return t?t[1]:null}function Ee(e){return e.replace(_n,(t,r)=>r)}function nt(e){return e.split(wn).map((r,o)=>o%2===0?Ee(r):r).join("")}function ot(e){let t=$n.exec(e["@odata.id"]);return{id:t[2],collection:t[1],oDataContext:e["@odata.context"]}}function at(e){let t=Bn.exec(e);if(!t)return null;let r=parseInt(t[2],10),o=qn(t[1]);return{page:r,sanitizedCookie:o}}function qn(e){let t={"<":"<",">":">",'"':""","'":"'"};return e.replace(Fn,r=>t[r])}function ee(e){return e.startsWith("/")?e.slice(1):e}function it(e){return e.replace(Qn,t=>`\\u${("0000"+t.charCodeAt(0).toString(16)).slice(-4)}`)}function be(e){return e.replace(Hn,"")}function mt(e){return Ln.test(e??"")?"PUT":"PATCH"}function Rt(e){return e.replace(Wn,"\\$&")}function gt(e){let t=Vn.exec(e);return t?t[1]:null}var W,On,Mn,Un,_n,$n,wn,Bn,Fn,Qn,Hn,st,xe,pt,ct,lt,te,Te,Ln,ut,ft,dt,yt,Wn,Vn,h=x(()=>{"use strict";W="[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}",On=new RegExp(W,"i"),Mn=new RegExp("^{?("+W+")}?$","i"),Un=new RegExp("("+W+")\\)$","i"),_n=new RegExp(`{(${W})}`,"g"),$n=new RegExp(`\\/(\\w+)\\((${W})`,"i");wn=/(["'].*?["'])/;Bn=/pagingcookie="()/,Fn=/[<>"']/g;Qn=/[\u007F-\uFFFF]/g;Hn=/"/g;st=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/,xe=/HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/m,pt=/Content-Type: text\/plain/i,ct=/OData-EntityId.+/i,lt=/\w+$/g,te=/\r?\n/,Te=/(\w+)(\([\d\w-]+\))$/,Ln=/EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;ut=/^{let s=e[n];if(s==null)return;s=Gn(s);let p=i+1;r.push(`${n}=@p${p}`),o.push(`@p${p}=${V(s)||s}`)}),{key:`(${r.join(",")})`,queryParams:o}}function ht(e,t){return e.hasOwnProperty(t)||e.hasOwnProperty(t.toLowerCase())}function G(e,t){return e[t]?e[t]:e[t.toLowerCase()]}function Ct(e){return e?Xn(e):{key:"()"}}function At(e="",t=1){e=decodeURIComponent(decodeURIComponent(e));let r=at(e);return{cookie:r?.sanitizedCookie||"",page:r?.page||t,nextPage:r?.page?r.page+1:t+1}}function R(e){return typeof e>"u"||e==null}function O(){return et().randomUUID()}function Kn(){if(typeof GetGlobalContext<"u")return GetGlobalContext();if(typeof Xrm<"u"){if(!R(Xrm.Utility)&&!R(Xrm.Utility.getGlobalContext))return Xrm.Utility.getGlobalContext();if(!R(Xrm.Page)&&!R(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.")}function Et(){let t=Kn().getClientUrl();return t.match(/\/$/)&&(t=t.substring(0,t.length-1)),t}function re(){return!!window.shell}function zn(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&Object.prototype.toString.call(e)!=="[object Date]"}function T(e,t){let r={};for(let o in e)e.hasOwnProperty(o)&&!t?.includes(o)&&(zn(e[o])?r[o]=T(e[o]):Array.isArray(e[o])?r[o]=e[o].slice():r[o]=e[o]);return r}function l(e,t=[]){t.includes("signal")||t.push("signal");let r=T(e,t);return r.signal=e.signal,r}function bt(e,t,r,o){o=o||0;let n=o+r>t.length?t.length%r:r,i;i=new Uint8Array(n);for(let s=0;s{"use strict";tt();h();ve=4194304});function D(e,t,r){throw new Error(r?`${e} requires a ${t} parameter to be of type ${r}.`:`${e} requires a ${t} parameter.`)}var a,f=x(()=>{"use strict";h();a=class e{static handleErrorResponse(t){throw new Error(`Error: ${t.status}: ${t.message}`)}static parameterCheck(t,r,o,n){(typeof t>"u"||t===null||t==="")&&D(r,o,n)}static stringParameterCheck(t,r,o){typeof t!="string"&&D(r,o,"String")}static maxLengthStringParameterCheck(t,r,o,n){if(t&&t.length>n)throw new Error(`${o} has a ${n} character limit.`)}static arrayParameterCheck(t,r,o){t.constructor!==Array&&D(r,o,"Array")}static stringOrArrayParameterCheck(t,r,o){t.constructor!==Array&&typeof t!="string"&&D(r,o,"String or Array")}static numberParameterCheck(t,r,o){if(typeof t!="number"){if(typeof t=="string"&&t&&!isNaN(parseInt(t)))return;D(r,o,"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(t,r){let o=new Error;return Object.keys(t).forEach(n=>{o[n]=t[n]}),r&&Object.keys(r).forEach(n=>{o[n]=r[n]}),o}static boolParameterCheck(t,r,o){typeof t!="boolean"&&D(r,o,"Boolean")}static guidParameterCheck(t,r,o){let n=V(t);return n||D(r,o,"GUID String"),n}static keyParameterCheck(t,r,o){try{e.stringParameterCheck(t,r,o);let n=V(t);if(n)return n;let i=t.split(",");if(i.length)for(let s=0;s{"use strict";ne=class ne{};ne.Prefer=(X=class{static get(t){return`${ne.Prefer.IncludeAnnotations}="${t}"`}},X.ReturnRepresentation="return=representation",X.Annotations=(M=class{},M.AssociatedNavigationProperty="Microsoft.Dynamics.CRM.associatednavigationproperty",M.LookupLogicalName="Microsoft.Dynamics.CRM.lookuplogicalname",M.All="*",M.FormattedValue="OData.Community.Display.V1.FormattedValue",M.FetchXmlPagingCookie="Microsoft.Dynamics.CRM.fetchxmlpagingcookie",M),X.IncludeAnnotations="odata.include-annotations",X);k=ne});function S(e,t){if(typeof t=="string"){let r=yt.exec(t);if(r)return new Date(Date.UTC(+r[1],+r[2]-1,+r[3],+r[4],+r[5],+r[6]))}return t}var Pe=x(()=>{"use strict";h()});function to(e){let t={position:0},r={},o,n,i;do{if(i=t.position,n=ro(e,t),!n)break;o=st.exec(n),o!==null?r[o[1].toLowerCase()]=o[2]:t.position=i}while(n&&o);return r}function ro(e,t){return no(e,t,te)}function no(e,t,r){let o=t.position||0,n=e.slice(o),i=r.exec(n);if(!i)return null;let s=o+i.index;return t.position=s+i[0].length,e.substring(o,s)}function oo(e){let t=xe.exec(e);return{httpStatusString:t[0],httpStatus:parseInt(t[1]),httpStatusMessage:t[2].trim()}}function ao(e){xe.lastIndex=0;let t=lt.exec(e.trim());return t?.length?t[0]:void 0}function io(e,t,r){let o=ao(e);return Se(o)}function so(e,t,r){if(t?.[r]?.valueIfEmpty!==void 0)return t[r].valueIfEmpty;{let o=ct.exec(e);return Z(o?.[0])??void 0}}function po(e,t,r){let{httpStatusString:o,httpStatus:n,httpStatusMessage:i}=oo(e),s=e.substring(e.indexOf("{"),e.lastIndexOf("}")+1);if(!s)return pt.test(e)?io(e,t,r):so(e,t,r);let p=ke(s,t,r);if(n<400)return p;let E=to(e.substring(e.indexOf(o)+o.length+1,e.indexOf("{")));return a.handleHttpError(p,{status:n,statusText:i,statusMessage:i,headers:E})}function De(e,t,r=0){let o=e.substring(0,e.search(te)),n=e.split(o);n.shift(),n.pop();let i=[];for(let s of n){if(s.indexOf("--changesetresponse_")===-1){i.push(po(s,t,r++));continue}s=s.trim();let p=s.substring(s.search(te)+1).trim();i=i.concat(De(p,t,r++))}return i}var Ie=x(()=>{"use strict";f();h();oe()});function Oe(e,t){let r=null;if(e.indexOf("@")!==-1){let o=e.split("@");switch(o[1]){case"odata.context":r="oDataContext";break;case"odata.count":r="oDataCount",t=t!=null?parseInt(t):0;break;case"odata.nextLink":r="oDataNextLink";break;case"odata.deltaLink":r="oDataDeltaLink";break;case k.Prefer.Annotations.FormattedValue:r=o[0]+"_Formatted";break;case k.Prefer.Annotations.AssociatedNavigationProperty:r=o[0]+"_NavigationProperty";break;case k.Prefer.Annotations.LookupLogicalName:r=o[0]+"_LogicalName";break}}return[r,t]}function Me(e,t){if(t){if(t.isRef&&e["@odata.id"]!=null)return ot(e);if(t.toCount)return Oe("@odata.count",e["@odata.count"])[1]||0}for(let o in e){if(e[o]!=null)if(Array.isArray(e[o]))for(var r=0;r-1}function uo(e){return ht(e,"Content-Disposition")}function fo(e){return G(e,"Content-Type")?.startsWith("application/json")==!0}function yo(e,t){let r=De(e,t);return t?.[0].convertedToBatch?r[0]:r}function Ro(e,t,r){return lo(e,t,r[0])}function ke(e,t,r=0){return Me(JSON.parse(e,S),t[r])}function Se(e){let t=Number(e);return isFinite(t)?t:e}function go(e,t){if(t?.[0]?.valueIfEmpty!==void 0)return t[0].valueIfEmpty;let r=G(e,"OData-EntityId");if(r)return Z(r)??void 0;let o=G(e,"Location");if(o){let n={location:o};return e["x-ms-chunk-size"]&&(n.chunkSize=parseInt(e["x-ms-chunk-size"])),e["x-ms-dyn-backgroundoperationid"]&&(n.backgroundOperationId=e["x-ms-dyn-backgroundoperationid"]),n}}function Ue(e,t,r){return e.length?mo(e)?yo(e,r):uo(t)?Ro(e,t,r):fo(t)?ke(e,r):Se(e):go(t,r)}var oe=x(()=>{"use strict";Pt();d();Pe();h();Ie()});function U(e){let t={};if(!e)return t;let r=e.split(`\r +`);for(let o=0,n=r.length;o0&&(t[i.substring(0,s)]=i.substring(s+2))}return t}var _e=x(()=>{"use strict"});var Dt={};Je(Dt,{XhrWrapper:()=>K,executeRequest:()=>ho});function ho(e){return new Promise((t,r)=>{Co(e,t,r)})}function Co(e,t,r){let o=e.data,n=e.headers,i=e.responseParams,s=e.abortSignal;if(s?.aborted){r(a.handleHttpError({name:"AbortError",code:20,message:"The user aborted a request."}));return}let p=new XMLHttpRequest;p.open(e.method,e.uri,e.isAsync||!1);for(let y in n)p.setRequestHeader(y,n[y]);p.onreadystatechange=function(){if(p.readyState===4){if(s&&s.removeEventListener("abort",E),!p||p.status===0)return;if(p.status>=200&&p.status<300||p.status===304){let y=U(p.getAllResponseHeaders()),b={data:Ue(p.responseText,y,i[e.requestId]),headers:y,status:p.status};p=null,t(b)}else{let y,A;try{A=U(p.getAllResponseHeaders());let j=Ue(p.responseText,A,i[e.requestId]);if(Array.isArray(j)){r(j);return}y=j.error}catch{p.response.length>0?y={message:p.response}:y={message:"Unexpected Error"}}let b={status:p.status,statusText:p.statusText,headers:A};p=null,r(a.handleHttpError(y,b))}}},e.timeout&&(p.timeout=e.timeout),p.onerror=function(){let y=U(p.getAllResponseHeaders());r(a.handleHttpError({status:p.status,statusText:p.statusText,message:p.responseText||"Network Error",headers:y})),p=null},p.ontimeout=function(){let y=U(p.getAllResponseHeaders());r(a.handleHttpError({name:"TimeoutError",status:p.status,statusText:p.statusText,message:p.responseText||"Request Timed Out",headers:y})),p=null},p.onabort=function(){if(!p)return;let y=U(p.getAllResponseHeaders());r(a.handleHttpError({status:p.status,statusText:p.statusText,message:"Request aborted",headers:y})),p=null};let E=()=>{if(!p)return;let y=U(p.getAllResponseHeaders());r(a.handleHttpError({name:"AbortError",code:20,status:p.status,statusText:p.statusText,message:"The user aborted a request.",headers:y})),p.abort(),p=null};s&&s.addEventListener("abort",E),o?p.send(o):p.send(),K.afterSendEvent&&K.afterSendEvent()}var K,It=x(()=>{"use strict";f();oe();_e();K=class{}});var Jo={};Je(Jo,{DynamicsWebApi:()=>Ke});d();f();var c="DynamicsWebApi";var g=`${c}.setConfig`,Yn=["dataApi","searchApi","serviceApi"],Jn=(e,t)=>{if(re())return new URL("_api",window.location.origin).toString()+"/";{e||(e=Et());let r="api";return t.path&&(r+=`/${t.path}`),t.version&&(r+=`/v${t.version}`),new URL(r,e).toString()+"/"}},jn=(e,t)=>{t&&(t.escapeSpecialCharacters!=null&&(a.boolParameterCheck(t.escapeSpecialCharacters,g,"config.searchApi.options.escapeSpecialCharacters"),e.escapeSpecialCharacters=t.escapeSpecialCharacters),t.enableResponseCompatibility!=null&&(a.boolParameterCheck(t.enableResponseCompatibility,g,"config.searchApi.options.enableResponseCompatibility"),e.enableSearchApiResponseCompatibility=t.enableResponseCompatibility))},Zn=(e,t,r)=>{let o=e[t],n=r?.[t];n?.version&&(a.stringParameterCheck(n.version,g,`config.${t}.version`),o.version=n.version),n?.path&&(a.stringParameterCheck(n.path,g,`config.${t}.path`),o.path=n.path),t==="searchApi"&&jn(o,n?.options),o.url=Jn(e.serverUrl,o)};function Ne(e,t){t?.serverUrl&&(a.stringParameterCheck(t.serverUrl,g,"config.serverUrl"),e.serverUrl=t.serverUrl),Yn.forEach(r=>{Zn(e,r,t)}),t?.impersonate&&(e.impersonate=a.guidParameterCheck(t.impersonate,g,"config.impersonate")),t?.impersonateAAD&&(e.impersonateAAD=a.guidParameterCheck(t.impersonateAAD,g,"config.impersonateAAD")),t?.onTokenRefresh&&(a.callbackParameterCheck(t.onTokenRefresh,g,"config.onTokenRefresh"),e.onTokenRefresh=t.onTokenRefresh),t?.includeAnnotations&&(a.stringParameterCheck(t.includeAnnotations,g,"config.includeAnnotations"),e.includeAnnotations=t.includeAnnotations),t?.timeout&&(a.numberParameterCheck(t.timeout,g,"config.timeout"),e.timeout=t.timeout),t?.maxPageSize&&(a.numberParameterCheck(t.maxPageSize,g,"config.maxPageSize"),e.maxPageSize=t.maxPageSize),t?.returnRepresentation!=null&&(a.boolParameterCheck(t.returnRepresentation,g,"config.returnRepresentation"),e.returnRepresentation=t.returnRepresentation),t?.useEntityNames!=null&&(a.boolParameterCheck(t.useEntityNames,g,"config.useEntityNames"),e.useEntityNames=t.useEntityNames),t?.headers&&(e.headers=t.headers)}function vt(){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:""},serviceApi:{url:""}}}d();d();var I=null,Nt=e=>{I=e},F=e=>{if(R(I))return null;let t=I[e];if(!t){for(let r in I)if(I[r]===e)return e}return t};async function kt(e){return(It(),je(Dt)).executeRequest(e)}f();f();h();d();var $e=(e,t,r="",o="&")=>{let n=[];if(e){if(e.navigationProperty){if(a.stringParameterCheck(e.navigationProperty,`DynamicsWebApi.${e.functionName}`,"request.navigationProperty"),r+="/"+e.navigationProperty,e.navigationPropertyKey){let i=a.keyParameterCheck(e.navigationPropertyKey,`DynamicsWebApi.${e.functionName}`,"request.navigationPropertyKey");r+="("+i+")"}e.navigationProperty==="Attributes"&&e.metadataAttributeType&&(a.stringParameterCheck(e.metadataAttributeType,`DynamicsWebApi.${e.functionName}`,"request.metadataAttributeType"),r+="/"+e.metadataAttributeType)}if(e.select?.length&&(a.arrayParameterCheck(e.select,`DynamicsWebApi.${e.functionName}`,"request.select"),e.functionName=="retrieve"&&e.select.length==1&&e.select[0].endsWith("/$ref")?r+="/"+e.select[0]:(e.select[0].startsWith("/")&&e.functionName=="retrieve"&&(e.navigationProperty==null?r+=e.select.shift():e.select.shift()),e.select.length&&n.push("$select="+e.select.join(",")))),e.filter){a.stringParameterCheck(e.filter,`DynamicsWebApi.${e.functionName}`,"request.filter");let i=nt(e.filter);n.push("$filter="+encodeURIComponent(i))}if(e.fieldName&&(a.stringParameterCheck(e.fieldName,`DynamicsWebApi.${e.functionName}`,"request.fieldName"),e.property||(e.property=e.fieldName),delete e.fieldName),e.property&&(a.stringParameterCheck(e.property,`DynamicsWebApi.${e.functionName}`,"request.property"),r+="/"+e.property),e.savedQuery&&n.push("savedQuery="+a.guidParameterCheck(e.savedQuery,`DynamicsWebApi.${e.functionName}`,"request.savedQuery")),e.userQuery&&n.push("userQuery="+a.guidParameterCheck(e.userQuery,`DynamicsWebApi.${e.functionName}`,"request.userQuery")),e.apply&&(a.stringParameterCheck(e.apply,`DynamicsWebApi.${e.functionName}`,"request.apply"),n.push("$apply="+e.apply)),e.count&&(a.boolParameterCheck(e.count,`DynamicsWebApi.${e.functionName}`,"request.count"),n.push("$count="+e.count)),e.top&&e.top>0&&(a.numberParameterCheck(e.top,`DynamicsWebApi.${e.functionName}`,"request.top"),n.push("$top="+e.top)),e.orderBy!=null&&e.orderBy.length&&(a.arrayParameterCheck(e.orderBy,`DynamicsWebApi.${e.functionName}`,"request.orderBy"),n.push("$orderby="+e.orderBy.join(","))),e.partitionId&&(a.stringParameterCheck(e.partitionId,`DynamicsWebApi.${e.functionName}`,"request.partitionId"),n.push("partitionid='"+e.partitionId+"'")),e.downloadSize&&(a.stringParameterCheck(e.downloadSize,`DynamicsWebApi.${e.functionName}`,"request.downloadSize"),n.push("size="+e.downloadSize)),e.tag&&(a.stringParameterCheck(e.tag,`DynamicsWebApi.${e.functionName}`,"request.tag"),n.push("tag="+encodeURIComponent(e.tag))),e.queryParams?.length&&(a.arrayParameterCheck(e.queryParams,`DynamicsWebApi.${e.functionName}`,"request.queryParams"),n.push(e.queryParams.join("&"))),e.fileName&&(a.stringParameterCheck(e.fileName,`DynamicsWebApi.${e.functionName}`,"request.fileName"),n.push("x-ms-file-name="+e.fileName)),e.data&&a.parameterCheck(e.data,`DynamicsWebApi.${e.functionName}`,"request.data"),e.isBatch&&a.boolParameterCheck(e.isBatch,`DynamicsWebApi.${e.functionName}`,"request.isBatch"),e.fetchXml&&(a.stringParameterCheck(e.fetchXml,`DynamicsWebApi.${e.functionName}`,"request.fetchXml"),n.push("fetchXml="+encodeURIComponent(e.fetchXml))),R(e.inChangeSet)||a.boolParameterCheck(e.inChangeSet,`DynamicsWebApi.${e.functionName}`,"request.inChangeSet"),e.isBatch&&R(e.inChangeSet)&&(e.inChangeSet=!0),e.timeout&&a.numberParameterCheck(e.timeout,`DynamicsWebApi.${e.functionName}`,"request.timeout"),e.expand?.length)if(a.stringOrArrayParameterCheck(e.expand,`DynamicsWebApi.${e.functionName}`,"request.expand"),typeof e.expand=="string")n.push("$expand="+e.expand);else{let i=[];for(let{property:s,...p}of e.expand){if(!s)continue;let E={functionName:`${e.functionName} $expand`,...p},y=$e(E,t,"",";");y&&(y=`(${y})`),i.push(s+y)}i.length&&n.push("$expand="+i.join(","))}}return n.length?(o==="&"&&(r+="?"),r+n.join(o)):r};f();f();h();var St=(e,t)=>{let r=`DynamicsWebApi.${e.functionName}`,o={respondAsync:e.respondAsync,backgroundOperationCallbackUrl:e.backgroundOperationCallbackUrl??t?.backgroundOperationCallbackUrl,returnRepresentation:e.returnRepresentation??t?.returnRepresentation,includeAnnotations:e.includeAnnotations??t?.includeAnnotations,maxPageSize:e.maxPageSize??t?.maxPageSize,trackChanges:e.trackChanges,continueOnError:e.continueOnError},n=new Set;if(e.prefer?.length){a.stringOrArrayParameterCheck(e.prefer,r,"request.prefer");let i=typeof e.prefer=="string"?e.prefer.split(","):e.prefer;for(let s of i){let p=s.trim();p.includes("respond-async")?o.respondAsync=!0:p.startsWith("odata.callback")?o.backgroundOperationCallbackUrl=gt(p):p==="return=representation"?o.returnRepresentation=!0:p.includes("odata.include-annotations=")?o.includeAnnotations=be(p.replace("odata.include-annotations=","")):p.startsWith("odata.maxpagesize=")?o.maxPageSize=Number(be(p.replace("odata.maxpagesize=","")))||0:p.includes("odata.track-changes")?o.trackChanges=!0:p.includes("odata.continue-on-error")?o.continueOnError=!0:n.add(p)}}for(let i in o){let s=Ao[i];s&&o[i]&&(s.validator?.(o[i],r,`request.${i}`),s.condition(o[i],o)&&n.add(s.formatter(o[i],o)))}return Array.from(n).join(",")},Ao={respondAsync:{validator:a.boolParameterCheck,condition:e=>!!e,formatter:()=>"respond-async"},backgroundOperationCallbackUrl:{validator:a.stringParameterCheck,condition:(e,t)=>e&&t.respondAsync,formatter:e=>`odata.callback;url="${e}"`},returnRepresentation:{validator:a.boolParameterCheck,condition:e=>!!e,formatter:()=>"return=representation"},includeAnnotations:{validator:a.stringParameterCheck,condition:e=>!!e,formatter:e=>`odata.include-annotations="${e}"`},maxPageSize:{validator:(e,t)=>e>0?a.numberParameterCheck(e,t,"request.maxPageSize"):void 0,condition:e=>e>0,formatter:e=>`odata.maxpagesize=${e}`},trackChanges:{validator:a.boolParameterCheck,condition:e=>!!e,formatter:()=>"odata.track-changes"},continueOnError:{validator:a.boolParameterCheck,condition:e=>!!e,formatter:()=>"odata.continue-on-error"}};var Ot=(e,t)=>{let r={...t.headers,...e.userHeaders},o=St(e,t);if(o.length&&(r.Prefer=o),e.collection==="$metadata"&&(r.Accept="application/xml"),e.transferMode&&(r["x-ms-transfer-mode"]=e.transferMode),e.ifmatch!=null&&e.ifnonematch!=null)throw new Error(`DynamicsWebApi.${e.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`);return e.ifmatch&&(a.stringParameterCheck(e.ifmatch,`DynamicsWebApi.${e.functionName}`,"request.ifmatch"),r["If-Match"]=e.ifmatch),e.ifnonematch&&(a.stringParameterCheck(e.ifnonematch,`DynamicsWebApi.${e.functionName}`,"request.ifnonematch"),r["If-None-Match"]=e.ifnonematch),e.impersonate&&(a.stringParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate"),r.MSCRMCallerID=a.guidParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate")),e.impersonateAAD&&(a.stringParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD"),r.CallerObjectId=a.guidParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD")),e.token&&(a.stringParameterCheck(e.token,`DynamicsWebApi.${e.functionName}`,"request.token"),r.Authorization="Bearer "+e.token),e.duplicateDetection&&(a.boolParameterCheck(e.duplicateDetection,`DynamicsWebApi.${e.functionName}`,"request.duplicateDetection"),r["MSCRM.SuppressDuplicateDetection"]="false"),e.bypassCustomPluginExecution&&(a.boolParameterCheck(e.bypassCustomPluginExecution,`DynamicsWebApi.${e.functionName}`,"request.bypassCustomPluginExecution"),r["MSCRM.BypassCustomPluginExecution"]="true"),e.noCache&&(a.boolParameterCheck(e.noCache,`DynamicsWebApi.${e.functionName}`,"request.noCache"),r["Cache-Control"]="no-cache"),e.mergeLabels&&(a.boolParameterCheck(e.mergeLabels,`DynamicsWebApi.${e.functionName}`,"request.mergeLabels"),r["MSCRM.MergeLabels"]="true"),e.contentId&&(a.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")||(r["Content-ID"]=e.contentId)),e.contentRange&&(a.stringParameterCheck(e.contentRange,`DynamicsWebApi.${e.functionName}`,"request.contentRange"),r["Content-Range"]=e.contentRange),e.range&&(a.stringParameterCheck(e.range,`DynamicsWebApi.${e.functionName}`,"request.range"),r.Range=e.range),r};f();var ae=(e,t)=>(e.path="",e.functionName=e.functionName||"",e.url?(a.stringParameterCheck(e.url,`DynamicsWebApi.${e.functionName}`,"request.url"),e.path=e.url.replace(t.dataApi.url,"")):(!e._isUnboundRequest&&!e.contentId&&!e.collection&&a.parameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.contentId&&(a.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")&&(e.path=e.contentId)),e.collection!=null&&(a.stringParameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.path+=e.path?`/${e.collection}`:e.collection,e.key&&(e.key=a.keyParameterCheck(e.key,`DynamicsWebApi.${e.functionName}`,"request.key"),e.path+=`(${e.key})`)),e.addPath&&(e.path&&(e.path+="/"),e.path+=e.addPath),e.path=$e(e,t,e.path)),e.hasOwnProperty("async")&&e.async!=null?a.boolParameterCheck(e.async,`DynamicsWebApi.${e.functionName}`,"request.async"):e.async=!0,e.headers=Ot(e,t),e);h();d();Pe();Ie();oe();_e();var ie=(e,t)=>{if(!e)return null;if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array)return e;let r=i=>{let s=Te.exec(i);if(s&&s.length>2){let p=F(s[1]);if(!R(p))return i.replace(Te,`${p}$2`)}return i},o=(i,s)=>(s.startsWith(t.dataApi.url)||(i.endsWith("@odata.bind")?s.startsWith("/")||(s=`/${s}`):s=`${t.dataApi.url}${ee(s)}`),s),n=JSON.stringify(e,(i,s)=>{if(i==="@odata.id"||i.endsWith("@odata.bind"))typeof s=="string"&&!s.startsWith("$")&&(s=Ee(s),t.useEntityNames&&(s=r(s)),i!=="@odata.id"&&(s=o(i,s)));else if(i.startsWith("oData")||i.endsWith("_Formatted")||i.endsWith("_NavigationProperty")||i.endsWith("_LogicalName"))return;return s});return it(n)};var se=(e={},t)=>(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"]&&t&&(e["Content-Type"]="application/json; charset=utf-8"),e);d();var we=(e,t,r)=>{let o=`dwa_batch_${O()}`,n=[],i=null,s=1e5,p=(y,A)=>{for(let b in y)b==="Authorization"||b==="Content-ID"||A.push(`${b}: ${y[b]}`)};e.forEach(y=>{y.functionName="executeBatch",r?.inChangeSet===!1&&(y.inChangeSet=!1);let A=y.method==="GET"?!1:!!y.inChangeSet;if(!A&&i&&(n.push(`\r --${i}--`),i=null,s=1e5),i||(n.push(`\r --${o}`),A&&(i=`changeset_${O()}`,n.push("Content-Type: multipart/mixed;boundary="+i))),A&&n.push(`\r ---${i}`),n.push("Content-Type: application/http"),n.push("Content-Transfer-Encoding: binary"),A){let x=y.headers.hasOwnProperty("Content-ID")?y.headers["Content-ID"]:++s;n.push(`Content-ID: ${x}`)}y.path?.startsWith("$")?n.push(`\r +--${i}`),n.push("Content-Type: application/http"),n.push("Content-Transfer-Encoding: binary"),A){let b=y.headers.hasOwnProperty("Content-ID")?y.headers["Content-ID"]:++s;n.push(`Content-ID: ${b}`)}y.path?.startsWith("$")?n.push(`\r ${y.method} ${y.path} HTTP/1.1`):n.push(`\r ${y.method} ${t.dataApi.url}${y.path} HTTP/1.1`),y.method==="GET"?n.push("Accept: application/json"):n.push("Content-Type: application/json"),y.headers&&p(y.headers,n),y.data&&n.push(`\r -${ae(y.data,t)}`)}),i&&n.push(`\r +${ie(y.data,t)}`)}),i&&n.push(`\r --${i}--`),n.push(`\r --${o}--\r -`);let E=ie(r?.userHeaders,r?.data);return E["Content-Type"]=`multipart/mixed;boundary=${o}`,{headers:E,body:n.join(`\r -`)}};var Ot=(e,t)=>{z[e]?z[e].push(t):z[e]=[t]},Eo=(e,t)=>{_[e]?_[e].push(t):_[e]=[t]},we=e=>{delete z[e],_.hasOwnProperty(e)&&delete _[e]},Mt=async(e,t)=>{try{let r=await No(e,t);return we(e.requestId),r}catch(r){throw we(e.requestId),r}finally{we(e.requestId)}},_={},z={},xo=["$metadata","EntityDefinitions","RelationshipDefinitions","GlobalOptionSetDefinitions","ManagedPropertyDefinitions","query","suggest","autocomplete"],bo=e=>xo.indexOf(e)>-1,To=async(e,t)=>{if(!R(I))return F(e)||e;let r=oe({method:"GET",collection:"EntityDefinitions",select:["EntitySetName","LogicalName"],noCache:!0,functionName:"retrieveMultiple"},t),o=await Mt(r,t);vt({});for(let n=0;n{if(!e||bo(e)||(e=e.toLowerCase(),!t.useEntityNames))return e;try{return await To(e,t)}catch(r){throw new Error("Unable to fetch Collection Names. Error: "+r.message)}},No=async(e,t)=>{e.headers=e.headers||{},e.responseParameters=e.responseParameters||{},e.requestId=e.requestId||O(),Ot(e.requestId,e.responseParameters);let r=null,o=e.responseParameters?.convertedToBatch;if(e.path==="$batch"&&!o){let s=_[e.requestId];if(!s)throw a.batchIsEmpty();let p=$e(s,t,e);r=p.body,e.headers={...p.headers,...e.headers},delete _[e.requestId]}else r=o?e.data:ae(e.data,t),!o&&e.includeDefaultDataverseHeaders!==!1&&(e.headers=ie(e.headers,e.data));t.impersonate&&!e.headers.MSCRMCallerID&&(e.headers.MSCRMCallerID=t.impersonate),t.impersonateAAD&&!e.headers.CallerObjectId&&(e.headers.CallerObjectId=t.impersonateAAD);let n=null;if(t.onTokenRefresh&&(!e.headers||e.headers&&!e.headers.Authorization)&&(n=await t.onTokenRefresh(),!n))throw new Error("Token is empty. Request is aborted.");n&&(e.headers.Authorization="Bearer "+(n.hasOwnProperty("accessToken")?n.accessToken:n)),te()&&(e.headers.__RequestVerificationToken=await window.shell.getTokenDeferred());let i=e.apiConfig?e.apiConfig.url:t.dataApi.url;return await It({method:e.method,uri:i.toString()+e.path,data:r,proxy:t.proxy,isAsync:e.async,headers:e.headers,requestId:e.requestId,abortSignal:e.signal,responseParams:z,timeout:e.timeout||t.timeout})},Ut=async(e,t)=>{if(e.responseParameters=e.responseParameters||{},e.userHeaders=e.headers,delete e.headers,!e.isBatch){let r=await vo(e.collection,t);if(e.collection=r,oe(e,t),e.responseParameters.convertedToBatch=!1,e.path.length>2e3){let o=$e([e],t);e.headers.Authorization&&(o.headers.Authorization=e.headers.Authorization),e.method="POST",e.path="$batch",e.data=o.body,e.headers={...o.headers,...e.userHeaders},e.responseParameters.convertedToBatch=!0}return Mt(e,t)}oe(e,t),Ot(e.requestId,e.responseParameters),Eo(e.requestId,e)};var _t=e=>F(e);var $,q,w,se=class{constructor(t){B(this,$,Tt());B(this,q,!1);B(this,w,null);this.setConfig=t=>ve(m(this,$),t);this.makeRequest=t=>(t.isBatch=m(this,q),m(this,w)&&(t.requestId=m(this,w)),Ut(t,m(this,$)));ve(m(this,$),t)}get batchRequestId(){return m(this,w)}set batchRequestId(t){L(this,w,t)}get config(){return m(this,$)}get isBatch(){return m(this,q)}set isBatch(t){L(this,q,t)}};$=new WeakMap,q=new WeakMap,w=new WeakMap;u();d();var $t="associate",Y=`${c}.${$t}`,wt=async(e,t)=>{a.parameterCheck(e,Y,"request"),a.parameterCheck(e.relatedKey,Y,"request.relatedKey"),a.stringParameterCheck(e.relationshipName,Y,"request.relationshipName");let r=e.relatedKey,o=e.relatedKey;(!t.isBatch||t.isBatch&&!e.relatedKey.startsWith("$"))&&(a.stringParameterCheck(e.relatedCollection,Y,"request.relatedCollection"),r=a.keyParameterCheck(e.relatedKey,Y,"request.relatedKey"),o=`${e.relatedCollection}(${r})`);let n=l(e,["primaryKey"]);n.method="POST",n.functionName=$t,n.navigationProperty=e.relationshipName+"/$ref",n.key=e.primaryKey,n.data={"@odata.id":o},await t.makeRequest(n)};u();d();var Bt="associateSingleValued",J=`${c}.${Bt}`,Ft=async(e,t)=>{a.parameterCheck(e,J,"request"),a.parameterCheck(e.relatedKey,J,"request.relatedKey"),a.stringParameterCheck(e.navigationProperty,J,"request.navigationProperty");let r=e.relatedKey,o=e.relatedKey;(!t.isBatch||t.isBatch&&!e.relatedKey.startsWith("$"))&&(a.stringParameterCheck(e.relatedCollection,J,"request.relatedCollection"),r=a.keyParameterCheck(e.relatedKey,J,"request.relatedKey"),o=`${e.relatedCollection}(${r})`);let n=l(e,["primaryKey"]);n.method="PUT",n.functionName=Bt,n.navigationProperty+="/$ref",n.key=e.primaryKey,n.data={"@odata.id":o},await t.makeRequest(n)};u();d();var Ht="callAction",qt=`${c}.${Ht}`,Qt=async(e,t)=>{a.parameterCheck(e,qt,"request"),a.stringParameterCheck(e.actionName,qt,"request.actionName");let r=l(e,["action"]);return r.method="POST",r.functionName=Ht,r.addPath=e.actionName,r._isUnboundRequest=!r.collection,r.data=e.action,(await t.makeRequest(r))?.data};u();d();var Wt="callFunction",Lt=`${c}.${Wt}`,Vt=async(e,t)=>{a.parameterCheck(e,Lt,"request");let r=y=>y.name||y.functionName,o=typeof e!="string",n=o?r(e):e,i=o?"request.name":"name",s=o?T(e,["name"]):{functionName:n};a.stringParameterCheck(n,Lt,i);let p=Ct(s.parameters);return s.method="GET",s.addPath=n+p.key,s.queryParams=p.queryParams,s._isUnboundRequest=!s.collection,s.functionName=Wt,(await t.makeRequest(s))?.data};u();d();var Gt="create",Po=`${c}.${Gt}`,v=async(e,t)=>{a.parameterCheck(e,Po,"request");let r;return e.functionName?r=e:(r=l(e),r.functionName=Gt),r.method="POST",(await t.makeRequest(r))?.data};u();d();var Xt="count",Do=`${c}.${Xt}`,Kt=async(e,t)=>{a.parameterCheck(e,Do,"request");let r=l(e);return r.method="GET",r.functionName=Xt,r.filter?.length?r.count=!0:r.navigationProperty="$count",r.responseParameters={toCount:r.count},(await t.makeRequest(r))?.data};u();u();u();d();var Yt="retrieveMultiple",zt=`${c}.${Yt}`,C=async(e,t,r)=>{a.parameterCheck(e,zt,"request");let o;return e.functionName?o=e:(o=l(e),o.functionName=Yt),o.method="GET",r&&(a.stringParameterCheck(r,zt,"nextPageLink"),o.url=r),(await t.makeRequest(o))?.data};var Io="retrieveAll",ko=`${c}.${Io}`,pe=async(e,t,r,o=[])=>{let n=await C(e,t,r);o=o.concat(n.value);let i=n.oDataNextLink;if(i)return pe(e,t,i,o);let s={value:o};return n.oDataDeltaLink&&(s["@odata.deltaLink"]=n.oDataDeltaLink,s.oDataDeltaLink=n.oDataDeltaLink),s},Be=(e,t)=>(a.throwBatchIncompatible(ko,t.isBatch),pe(e,t));var So="countAll",Jt=`${c}.${So}`,jt=async(e,t)=>(a.throwBatchIncompatible(Jt,t.isBatch),a.parameterCheck(e,Jt,"request"),(await pe(e,t)).value.length);u();d();var Zt="disassociate",ce=`${c}.${Zt}`,er=async(e,t)=>{a.parameterCheck(e,ce,"request");let r=l(e);r.method="DELETE",r.functionName=Zt,a.stringParameterCheck(e.relationshipName,ce,"request.relationshipName");let o=a.keyParameterCheck(e.primaryKey,ce,"request.primaryKey"),n=a.keyParameterCheck(e.relatedKey,ce,"request.relatedId");r.key=o,r.navigationProperty=`${e.relationshipName}(${n})/$ref`,await t.makeRequest(r)};u();d();var tr="disassociateSingleValued",Fe=`${c}.${tr}`,rr=async(e,t)=>{a.parameterCheck(e,Fe,"request");let r=l(e);r.method="DELETE",r.functionName=tr,a.stringParameterCheck(e.navigationProperty,Fe,"request.navigationProperty");let o=a.keyParameterCheck(e.primaryKey,Fe,"request.primaryKey");r.navigationProperty+="/$ref",r.key=o,await t.makeRequest(r)};u();d();var nr="retrieve",Oo=`${c}.${nr}`,N=async(e,t)=>{a.parameterCheck(e,Oo,"request");let r;return e.functionName?r=e:(r=l(e),r.functionName=nr),r.method="GET",r.responseParameters={isRef:r.select?.length===1&&r.select[0].endsWith("/$ref")},(await t.makeRequest(r))?.data};u();h();d();var or="fetch",le=`${c}.${or}`,me=async(e,t)=>{a.parameterCheck(e,le,"request");let r=l(e);if(r.method="GET",r.functionName=or,a.stringParameterCheck(r.fetchXml,le,"request.fetchXml"),r.fetchXml&&!ut.test(r.fetchXml)){let n="";ft.test(r.fetchXml)||(r.pageNumber=r.pageNumber||1,a.numberParameterCheck(r.pageNumber,le,"request.pageNumber"),n=`$1 page="${r.pageNumber}"`),r.pagingCookie!=null&&(a.stringParameterCheck(r.pagingCookie,le,"request.pagingCookie"),n+=` paging-cookie="${r.pagingCookie}"`),n&&(r.fetchXml=r.fetchXml.replace(dt,n))}return r.responseParameters={pageNumber:r.pageNumber},(await t.makeRequest(r))?.data};u();var Mo="fetchAll",ar=`${c}.${Mo}`,ir=async(e,t,r=[])=>{let o=await me(e,t);return r=r.concat(o.value),o.PagingInfo?(e.pageNumber=o.PagingInfo.nextPage,e.pagingCookie=o.PagingInfo.cookie,ir(e,t,r)):{value:r}},sr=async(e,t)=>(a.parameterCheck(e,ar,"request"),a.throwBatchIncompatible(ar,t.isBatch),ir(e,t));u();h();d();var pr="update",Uo=`${c}.${pr}`,P=async(e,t)=>{a.parameterCheck(e,Uo,"request");let r;e.functionName?r=e:(r=l(e),r.functionName=pr),r.method??(r.method=mt(r.collection)),r.responseParameters={valueIfEmpty:!0},r.ifmatch??(r.ifmatch="*");let o=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(n){if(o&&n.status===412)return!1;throw n}};u();d();var lr="updateSingleProperty",cr=`${c}.${lr}`,mr=async(e,t)=>{a.parameterCheck(e,cr,"request"),a.parameterCheck(e.fieldValuePair,cr,"request.fieldValuePair");var r=Object.keys(e.fieldValuePair)[0],o=e.fieldValuePair[r];let n=l(e);return n.navigationProperty=r,n.data={value:o},n.functionName=lr,n.method="PUT",delete n.fieldValuePair,(await t.makeRequest(n))?.data};u();d();var ur="upsert",_o=`${c}.${ur}`,fr=async(e,t)=>{a.parameterCheck(e,_o,"request");let r=l(e);r.method="PATCH",r.functionName=ur;let o=r.ifnonematch,n=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(i){if(o&&i.status===412)return null;if(n&&i.status===404)return null;throw i}};u();d();var dr="deleteRecord",$o=`${c}.${dr}`,H=async(e,t)=>{a.parameterCheck(e,$o,"request");let r;e.functionName?r=e:(r=l(e),r.functionName=dr),r.method="DELETE",r.responseParameters={valueIfEmpty:!0};let o=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(n){if(o&&n.status===412)return!1;throw n}};u();d();var Rr="uploadFile",yr=`${c}.${Rr}`,gr=async(e,t,r,o,n=0)=>{if(xt(e,r,o,n),await t.makeRequest(e),n+=o,n<=r.length)return gr(e,t,r,o,n)},hr=async(e,t)=>{a.throwBatchIncompatible(yr,t.isBatch),a.parameterCheck(e,yr,"request");let r=l(e,["data"]);r.method="PATCH",r.functionName=Rr,r.transferMode="chunked";let o=await t.makeRequest(r);return r.url=o?.data.location,delete r.transferMode,delete r.fieldName,delete r.property,delete r.fileName,gr(r,t,e.data,o?.data.chunkSize)};u();d();var Ar="downloadFile",Cr=`${c}.${Ar}`,Er=async(e,t,r=0,o="")=>{e.range="bytes="+r+"-"+(r+Te-1),e.downloadSize="full";let n=await t.makeRequest(e);return e.url=n?.data.location,o+=n?.data.value,r+=Te,r<=n?.data.fileSize?Er(e,t,r,o):{fileName:n?.data.fileName,fileSize:n?.data.fileSize,data:bt(o)}},xr=(e,t)=>{a.throwBatchIncompatible(Cr,t.isBatch),a.parameterCheck(e,Cr,"request");let r=l(e);return r.method="GET",r.functionName=Ar,r.responseParameters={parse:!0},Er(r,t)};d();u();var wo="executeBatch",Bo=`${c}.${wo}`;async function br(e,t){a.throwBatchNotStarted(t.isBatch);let r=e?l(e):{};return r.collection="$batch",r.method="POST",r.functionName=Bo,r.requestId=t.batchRequestId,t.batchRequestId=null,t.isBatch=!1,(await t.makeRequest(r))?.data}function Tr(e){e.isBatch=!0,e.batchRequestId=O()}u();d();var Nr="createEntity",vr=`${c}.${Nr}`,Pr=async(e,t)=>{a.parameterCheck(e,vr,"request"),a.parameterCheck(e.data,vr,"request.data");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Nr,v(r,t)};u();d();var Ir="updateEntity",Dr=`${c}.${Ir}`,kr=async(e,t)=>{a.parameterCheck(e,Dr,"request"),a.parameterCheck(e.data,Dr,"request.data");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Ir,r.key=r.data.MetadataId,r.method="PUT",await P(r,t)};u();d();var Fo="retrieveEntity",Sr=`${c}.${Fo}`,Or=async(e,t)=>{a.parameterCheck(e,Sr,"request"),a.keyParameterCheck(e.key,Sr,"request.key");let r=l(e);return r.collection="EntityDefinitions",r.functionName="retrieveEntity",await N(r,t)};d();var qo="retrieveEntities",Mr=(e,t)=>{let r=t?l(t):{};return r.collection="EntityDefinitions",r.functionName=qo,C(r,e)};d();u();var Ur="createAttribute",qe=`${c}.${Ur}`,_r=(e,t)=>{a.parameterCheck(e,qe,"request"),a.parameterCheck(e.data,qe,"request.data"),a.keyParameterCheck(e.entityKey,qe,"request.entityKey");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Ur,r.navigationProperty="Attributes",r.key=e.entityKey,v(r,t)};d();u();var $r="updateAttribute",ue=`${c}.${$r}`,wr=(e,t)=>{a.parameterCheck(e,ue,"request"),a.parameterCheck(e.data,ue,"request.data"),a.keyParameterCheck(e.entityKey,ue,"request.entityKey"),a.guidParameterCheck(e.data.MetadataId,ue,"request.data.MetadataId");let r=l(e);return r.collection="EntityDefinitions",r.functionName=$r,r.navigationProperty="Attributes",r.navigationPropertyKey=e.data.MetadataId,r.metadataAttributeType=e.castType,r.key=e.entityKey,r.method="PUT",P(r,t)};d();u();var Br="retrieveAttributes",He=`${c}.${Br}`,Fr=(e,t)=>{a.parameterCheck(e,He,"request"),a.keyParameterCheck(e.entityKey,He,"request.entityKey"),e.castType&&a.stringParameterCheck(e.castType,He,"request.castType");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Br,r.navigationProperty="Attributes",r.key=e.entityKey,r.metadataAttributeType=e.castType,C(r,t)};d();u();var qr="retrieveAttributes",fe=`${c}.${qr}`,Hr=(e,t)=>{a.parameterCheck(e,fe,"request"),a.keyParameterCheck(e.entityKey,fe,"request.entityKey"),a.keyParameterCheck(e.attributeKey,fe,"request.attributeKey"),e.castType&&a.stringParameterCheck(e.castType,fe,"request.castType");let r=l(e);return r.collection="EntityDefinitions",r.navigationProperty="Attributes",r.navigationPropertyKey=e.attributeKey,r.metadataAttributeType=e.castType,r.key=e.entityKey,r.functionName=qr,N(r,t)};d();u();var Lr="createRelationship",Qr=`${c}.${Lr}`,Wr=(e,t)=>{a.parameterCheck(e,Qr,"request"),a.parameterCheck(e.data,Qr,"request.data");let r=l(e);return r.collection="RelationshipDefinitions",r.functionName=Lr,v(r,t)};d();u();var Vr="updateRelationship",de=`${c}.${Vr}`;function Gr(e,t){a.parameterCheck(e,de,"request"),a.parameterCheck(e.data,de,"request.data"),a.guidParameterCheck(e.data.MetadataId,de,"request.data.MetadataId"),e.castType&&a.stringParameterCheck(e.castType,de,"request.castType");let r=l(e);return r.collection="RelationshipDefinitions",r.key=e.data.MetadataId,r.navigationProperty=e.castType,r.functionName=Vr,r.method="PUT",P(r,t)}d();u();var Kr="deleteRelationship",Xr=`${c}.${Kr}`;async function zr(e,t){a.parameterCheck(e,Xr,"request"),a.keyParameterCheck(e.key,Xr,"request.key");let r=l(e);return r.collection="RelationshipDefinitions",r.functionName=Kr,H(r,t)}d();u();var Yr="retrieveRelationships",Ho=`DynamicsWebApi.${Yr}`;async function Jr(e,t){let r=e?l(e):{};return r.collection="RelationshipDefinitions",r.functionName=Yr,e&&e.castType&&(a.stringParameterCheck(e.castType,Ho,"request.castType"),r.navigationProperty=e.castType),C(r,t)}d();u();var jr="retrieveRelationship",Qe=`DynamicsWebApi.${jr}`;async function Zr(e,t){a.parameterCheck(e,Qe,"request"),a.keyParameterCheck(e.key,Qe,"request.key"),e.castType&&a.stringParameterCheck(e.castType,Qe,"request.castType");let r=l(e);return r.collection="RelationshipDefinitions",r.navigationProperty=e.castType,r.functionName=jr,N(r,t)}d();u();var tn="createGlobalOptionSet",en=`DynamicsWebApi.${tn}`;async function rn(e,t){a.parameterCheck(e,en,"request"),a.parameterCheck(e.data,en,"request.data");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.functionName=tn,v(r,t)}d();u();var nn="updateGlobalOptionSet",ye=`DynamicsWebApi.${nn}`;async function on(e,t){a.parameterCheck(e,ye,"request"),a.parameterCheck(e.data,ye,"request.data"),a.guidParameterCheck(e.data.MetadataId,ye,"request.data.MetadataId"),e.castType&&a.stringParameterCheck(e.castType,ye,"request.castType");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.key=e.data.MetadataId,r.functionName=nn,r.method="PUT",P(r,t)}d();u();var an="deleteGlobalOptionSet",Qo=`DynamicsWebApi.${an}`;async function sn(e,t){a.parameterCheck(e,Qo,"request");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.functionName=an,H(r,t)}d();u();var cn="retrieveGlobalOptionSet",pn=`DynamicsWebApi.${cn}`;async function ln(e,t){a.parameterCheck(e,pn,"request"),e.castType&&a.stringParameterCheck(e.castType,pn,"request.castType");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.navigationProperty=e.castType,r.functionName=cn,N(r,t)}d();u();var mn="retrieveGlobalOptionSets",Lo=`DynamicsWebApi.${mn}`;async function un(e,t){let r=e?l(e):{};return r.collection="GlobalOptionSetDefinitions",r.functionName=mn,e?.castType&&(a.stringParameterCheck(e.castType,Lo,"request.castType"),r.navigationProperty=e.castType),C(r,t)}d();u();var fn="retrieveCsdlMetadata",Wo=`DynamicsWebApi.${fn}`;async function dn(e,t){let r=e?l(e):{};return r.collection="$metadata",r.functionName=fn,e?.addAnnotations&&(a.boolParameterCheck(e.addAnnotations,Wo,"request.addAnnotations"),r.includeAnnotations="*"),(await t.makeRequest(r))?.data}d();u();h();function Q(e,t,r){if(!e)return e;switch(r?.escapeSpecialCharacters===!0&&(e.search=Rt(e.search)),e.entities?.length&&(e.entities=Vo(e.entities,r?.version)),t){case"query":Go(e,r?.version);break;default:Xo(e,r?.version);break}return e}function Vo(e,t="1.0"){if(!e)return e;if(typeof e=="string"){if(t!=="1.0")return e;try{e=JSON.parse(e)}catch{throw new Error("The 'query.entities' property must be a valid JSON string.")}if(!Array.isArray(e))throw new Error("The 'query.entities' property must be an array of strings or objects.")}let r=i=>typeof i=="string"?i:i.name,o=i=>typeof i=="string"?{name:i}:i,n=e.map(i=>t==="1.0"?r(i):o(i));return t!=="1.0"?JSON.stringify(n):n}function Go(e,t="1.0"){t==="1.0"?(n=>{if(n.count!=null&&(n.returnTotalRecordCount==null&&(n.returnTotalRecordCount=n.count),delete n.count),n.options){if(typeof n.options=="string")try{n.options=JSON.parse(n.options,Ko)}catch{throw new Error("The 'query.options' property must be a valid JSON string.")}n.searchMode||(n.searchMode=n.options.searchMode),n.searchType||(n.searchType=n.options.queryType==="lucene"?"full":n.options.queryType),delete n.options}for(let i of zo)if(n[i]&&typeof n[i]=="string")try{n[i]=JSON.parse(n[i])}catch{throw new Error(`The 'query.${i}' property must be a valid JSON string.`)}})(e):(n=>{n.returnTotalRecordCount!=null&&(n.count==null&&(n.count=n.returnTotalRecordCount),delete n.returnTotalRecordCount),(n.searchMode||n.searchType)&&(typeof n.options!="string"&&(n.options||(n.options={}),n.options.searchMode||(n.options.searchMode=n.searchMode),n.options.queryType||(n.options.queryType=n.searchType==="full"?"lucene":n.searchType)),delete n.searchMode,delete n.searchType),n.orderBy&&typeof n.orderBy!="string"&&(n.orderby=JSON.stringify(n.orderBy),delete n.orderBy),n.facets&&typeof n.facets!="string"&&(n.facets=JSON.stringify(n.facets)),n.options&&typeof n.options!="string"&&(n.options=JSON.stringify(yn(n.options)))})(e)}function Xo(e,t="1.0"){t==="1.0"?(n=>{if(n.fuzzy!=null&&(n.useFuzzy==null&&(n.useFuzzy=n.fuzzy),delete n.fuzzy),delete n.options,n.orderBy&&typeof n.orderBy=="string")try{n.orderBy=JSON.parse(n.orderBy)}catch{throw new Error("The 'query.orderBy' property must be a valid JSON string.")}})(e):(n=>{n.useFuzzy!=null&&(n.fuzzy==null&&(n.fuzzy=n.useFuzzy),delete n.useFuzzy),n.orderBy&&typeof n.orderBy!="string"&&(n.orderby=JSON.stringify(n.orderBy),delete n.orderBy),n.options&&typeof n.options!="string"&&(n.options=JSON.stringify(yn(n.options)))})(e)}function yn(e){let t={};for(let r in e)t[r.toLowerCase()]=e[r];return t}function Ko(e,t){switch(e){case"searchmode":this.searchMode=t;break;case"querytype":this.queryType=t;break;default:return t}}var zo=["orderBy","facets"];function Rn(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S),i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.facets=n.Facets,i.totalrecordcount=n.Count,i.querycontext=n.QueryContext),i},o=()=>{let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Count:e.totalrecordcount,Value:e.value,Facets:e.facets,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():o()}var Le="query",Re=`${c}.${Le}`;async function We(e,t){a.parameterCheck(e,Re,"request");let r=typeof e!="string",o=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};a.parameterCheck(n.query,Re,"request.query"),a.stringParameterCheck(n.query.search,Re,o),a.maxLengthStringParameterCheck(n.query.search,Re,o,100),n.collection="query",n.functionName=Le,n.method="POST",n.data=Q(n.query,Le,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return Rn(i.data,t.config.searchApi)}d();u();function gn(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S);t.enableSearchApiResponseCompatibility&&n.Value?.forEach(s=>{s.document=s.Document,s.text=s.Text});let i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.querycontext=n.QueryContext),i},o=()=>{t.enableSearchApiResponseCompatibility&&e.value?.forEach(i=>{i.Document=i.document,i.Text=i.text});let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Value:e.value,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():o()}var Ve="suggest",ge=`${c}.${Ve}`;async function hn(e,t){a.parameterCheck(e,ge,"request");let r=typeof e!="string",o=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};a.parameterCheck(n.query,ge,"request.query"),a.stringParameterCheck(n.query.search,ge,o),a.maxLengthStringParameterCheck(n.query.search,ge,o,100),n.functionName=n.collection=Ve,n.method="POST",n.data=Q(n.query,Ve,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return gn(i.data,t.config.searchApi)}d();u();function Cn(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S),i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.querycontext=n.QueryContext),i},o=()=>{let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Value:e.value,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():o()}var Ge="autocomplete",he=`${c}.${Ge}`;async function An(e,t){a.parameterCheck(e,he,"request");let r=typeof e!="string",o=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};r&&a.parameterCheck(n.query,he,"request.query"),a.stringParameterCheck(n.query.search,he,o),a.maxLengthStringParameterCheck(n.query.search,he,o,100),n.functionName=n.collection=Ge,n.method="POST",n.data=Q(n.query,Ge,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return Cn(i.data,t.config.searchApi)}u();var xn="getBackgroundOperationStatus",En=`${c}.${xn}`;async function bn(e,t){a.throwBatchIncompatible(En,t.isBatch),a.keyParameterCheck(e,En,"backgroundOperationId");let r={method:"GET",addPath:`backgroundoperation/${e}`,functionName:xn,apiConfig:t.config.serviceApi,includeDefaultDataverseHeaders:!1,headers:{"Content-Type":"application/json"},_isUnboundRequest:!0};return(await t.makeRequest(r))?.data}u();var vn="cancelBackgroundOperation",Tn=`${c}.${vn}`;async function Nn(e,t){a.throwBatchIncompatible(Tn,t.isBatch),a.keyParameterCheck(e,Tn,"backgroundOperationId");let r={method:"DELETE",addPath:`backgroundoperation/${e}`,functionName:vn,apiConfig:t.config.serviceApi,includeDefaultDataverseHeaders:!1,headers:{"Content-Type":"application/json"},_isUnboundRequest:!0};return(await t.makeRequest(r))?.data}var f,Ke=class Ke{constructor(t){B(this,f);this.setConfig=t=>m(this,f).setConfig(t);this.create=async t=>v(t,m(this,f));this.retrieve=async t=>N(t,m(this,f));this.update=async t=>P(t,m(this,f));this.updateSingleProperty=async t=>mr(t,m(this,f));this.deleteRecord=async t=>H(t,m(this,f));this.upsert=async t=>fr(t,m(this,f));this.uploadFile=async t=>hr(t,m(this,f));this.downloadFile=t=>xr(t,m(this,f));this.retrieveMultiple=async(t,r)=>C(t,m(this,f),r);this.retrieveAll=t=>Be(t,m(this,f));this.count=async t=>Kt(t,m(this,f));this.countAll=async t=>jt(t,m(this,f));this.fetch=async t=>me(t,m(this,f));this.fetchAll=async t=>sr(t,m(this,f));this.associate=async t=>wt(t,m(this,f));this.disassociate=async t=>er(t,m(this,f));this.associateSingleValued=async t=>Ft(t,m(this,f));this.disassociateSingleValued=async t=>rr(t,m(this,f));this.callFunction=async t=>Vt(t,m(this,f));this.callAction=async t=>Qt(t,m(this,f));this.createEntity=t=>Pr(t,m(this,f));this.updateEntity=t=>kr(t,m(this,f));this.retrieveEntity=t=>Or(t,m(this,f));this.retrieveEntities=t=>Mr(m(this,f),t);this.createAttribute=t=>_r(t,m(this,f));this.updateAttribute=t=>wr(t,m(this,f));this.retrieveAttributes=t=>Fr(t,m(this,f));this.retrieveAttribute=t=>Hr(t,m(this,f));this.createRelationship=t=>Wr(t,m(this,f));this.updateRelationship=t=>Gr(t,m(this,f));this.deleteRelationship=t=>zr(t,m(this,f));this.retrieveRelationships=t=>Jr(t,m(this,f));this.retrieveRelationship=t=>Zr(t,m(this,f));this.createGlobalOptionSet=t=>rn(t,m(this,f));this.updateGlobalOptionSet=t=>on(t,m(this,f));this.deleteGlobalOptionSet=t=>sn(t,m(this,f));this.retrieveGlobalOptionSet=t=>ln(t,m(this,f));this.retrieveGlobalOptionSets=t=>un(t,m(this,f));this.retrieveCsdlMetadata=async t=>dn(t,m(this,f));this.search=async t=>We(t,m(this,f));this.query=async t=>We(t,m(this,f));this.suggest=async t=>hn(t,m(this,f));this.autocomplete=async t=>An(t,m(this,f));this.getBackgroundOperationStatus=async t=>bn(t,m(this,f));this.cancelBackgroundOperation=async t=>Nn(t,m(this,f));this.startBatch=()=>Tr(m(this,f));this.executeBatch=async t=>br(t,m(this,f));this.initializeInstance=t=>new Ke(t||m(this,f).config);this.Utility={getCollectionName:t=>_t(t)};L(this,f,new se(t))}};f=new WeakMap;var Xe=Ke;return Je(Jo);})(); +`);let E=se(r?.userHeaders,r?.data);return E["Content-Type"]=`multipart/mixed;boundary=${o}`,{headers:E,body:n.join(`\r +`)}};var Mt=(e,t)=>{z[e]?z[e].push(t):z[e]=[t]},Eo=(e,t)=>{_[e]?_[e].push(t):_[e]=[t]},Be=e=>{delete z[e],_.hasOwnProperty(e)&&delete _[e]},Ut=async(e,t)=>{try{let r=await No(e,t);return Be(e.requestId),r}catch(r){throw Be(e.requestId),r}finally{Be(e.requestId)}},_={},z={},bo=["$metadata","EntityDefinitions","RelationshipDefinitions","GlobalOptionSetDefinitions","ManagedPropertyDefinitions","query","suggest","autocomplete"],xo=e=>bo.indexOf(e)>-1,To=async(e,t)=>{if(!R(I))return F(e)||e;let r=ae({method:"GET",collection:"EntityDefinitions",select:["EntitySetName","LogicalName"],noCache:!0,functionName:"retrieveMultiple"},t),o=await Ut(r,t);Nt({});for(let n=0;n{if(!e||xo(e)||(e=e.toLowerCase(),!t.useEntityNames))return e;try{return await To(e,t)}catch(r){throw new Error("Unable to fetch Collection Names. Error: "+r.message)}},No=async(e,t)=>{e.headers=e.headers||{},e.responseParameters=e.responseParameters||{},e.requestId=e.requestId||O(),Mt(e.requestId,e.responseParameters);let r=null,o=e.responseParameters?.convertedToBatch;if(e.path==="$batch"&&!o){let s=_[e.requestId];if(!s)throw a.batchIsEmpty();let p=we(s,t,e);r=p.body,e.headers={...p.headers,...e.headers},delete _[e.requestId]}else r=o?e.data:ie(e.data,t),!o&&e.includeDefaultDataverseHeaders!==!1&&(e.headers=se(e.headers,e.data));t.impersonate&&!e.headers.MSCRMCallerID&&(e.headers.MSCRMCallerID=t.impersonate),t.impersonateAAD&&!e.headers.CallerObjectId&&(e.headers.CallerObjectId=t.impersonateAAD);let n=null;if(t.onTokenRefresh&&(!e.headers||e.headers&&!e.headers.Authorization)&&(n=await t.onTokenRefresh(),!n))throw new Error("Token is empty. Request is aborted.");n&&(e.headers.Authorization="Bearer "+(n.hasOwnProperty("accessToken")?n.accessToken:n)),re()&&(e.headers.__RequestVerificationToken=await window.shell.getTokenDeferred());let i=e.apiConfig?e.apiConfig.url:t.dataApi.url;return await kt({method:e.method,uri:i.toString()+e.path,data:r,proxy:t.proxy,isAsync:e.async,headers:e.headers,requestId:e.requestId,abortSignal:e.signal,responseParams:z,timeout:e.timeout||t.timeout})},_t=async(e,t)=>{if(e.responseParameters=e.responseParameters||{},e.userHeaders=e.headers,delete e.headers,!e.isBatch){let r=await vo(e.collection,t);if(e.collection=r,ae(e,t),e.responseParameters.convertedToBatch=!1,e.path.length>2e3){let o=we([e],t);e.headers.Authorization&&(o.headers.Authorization=e.headers.Authorization),e.method="POST",e.path="$batch",e.data=o.body,e.headers={...o.headers,...e.userHeaders},e.responseParameters.convertedToBatch=!0}return Ut(e,t)}ae(e,t),Mt(e.requestId,e.responseParameters),Eo(e.requestId,e)};var $t=e=>F(e);var $,q,w,pe=class{constructor(t){B(this,$,vt());B(this,q,!1);B(this,w,null);this.setConfig=t=>Ne(m(this,$),t);this.makeRequest=t=>(t.isBatch=m(this,q),m(this,w)&&(t.requestId=m(this,w)),_t(t,m(this,$)));Ne(m(this,$),t)}get batchRequestId(){return m(this,w)}set batchRequestId(t){L(this,w,t)}get config(){return m(this,$)}get isBatch(){return m(this,q)}set isBatch(t){L(this,q,t)}};$=new WeakMap,q=new WeakMap,w=new WeakMap;f();d();var wt="associate",Y=`${c}.${wt}`,Bt=async(e,t)=>{a.parameterCheck(e,Y,"request"),a.parameterCheck(e.relatedKey,Y,"request.relatedKey"),a.stringParameterCheck(e.relationshipName,Y,"request.relationshipName");let r=e.relatedKey,o=e.relatedKey;(!t.isBatch||t.isBatch&&!e.relatedKey.startsWith("$"))&&(a.stringParameterCheck(e.relatedCollection,Y,"request.relatedCollection"),r=a.keyParameterCheck(e.relatedKey,Y,"request.relatedKey"),o=`${t.config.dataApi.url}${e.relatedCollection}(${r})`);let n=l(e,["primaryKey"]);n.method="POST",n.functionName=wt,n.navigationProperty=e.relationshipName+"/$ref",n.key=e.primaryKey,n.data={"@odata.id":o},await t.makeRequest(n)};f();d();var Ft="associateSingleValued",J=`${c}.${Ft}`,qt=async(e,t)=>{a.parameterCheck(e,J,"request"),a.parameterCheck(e.relatedKey,J,"request.relatedKey"),a.stringParameterCheck(e.navigationProperty,J,"request.navigationProperty");let r=e.relatedKey,o=e.relatedKey;(!t.isBatch||t.isBatch&&!e.relatedKey.startsWith("$"))&&(a.stringParameterCheck(e.relatedCollection,J,"request.relatedCollection"),r=a.keyParameterCheck(e.relatedKey,J,"request.relatedKey"),o=`${t.config.dataApi.url}${e.relatedCollection}(${r})`);let n=l(e,["primaryKey"]);n.method="PUT",n.functionName=Ft,n.navigationProperty+="/$ref",n.key=e.primaryKey,n.data={"@odata.id":o},await t.makeRequest(n)};f();d();var Ht="callAction",Qt=`${c}.${Ht}`,Lt=async(e,t)=>{a.parameterCheck(e,Qt,"request"),a.stringParameterCheck(e.actionName,Qt,"request.actionName");let r=l(e,["action"]);return r.method="POST",r.functionName=Ht,r.addPath=e.actionName,r._isUnboundRequest=!r.collection,r.data=e.action,(await t.makeRequest(r))?.data};f();d();var Vt="callFunction",Wt=`${c}.${Vt}`,Gt=async(e,t)=>{a.parameterCheck(e,Wt,"request");let r=y=>y.name||y.functionName,o=typeof e!="string",n=o?r(e):e,i=o?"request.name":"name",s=o?T(e,["name"]):{functionName:n};a.stringParameterCheck(n,Wt,i);let p=Ct(s.parameters);return s.method="GET",s.addPath=n+p.key,s.queryParams=p.queryParams,s._isUnboundRequest=!s.collection,s.functionName=Vt,(await t.makeRequest(s))?.data};f();d();var Xt="create",Po=`${c}.${Xt}`,v=async(e,t)=>{a.parameterCheck(e,Po,"request");let r;return e.functionName?r=e:(r=l(e),r.functionName=Xt),r.method="POST",(await t.makeRequest(r))?.data};f();d();var Kt="count",Do=`${c}.${Kt}`,zt=async(e,t)=>{a.parameterCheck(e,Do,"request");let r=l(e);return r.method="GET",r.functionName=Kt,r.filter?.length?r.count=!0:r.navigationProperty="$count",r.responseParameters={toCount:r.count},(await t.makeRequest(r))?.data};f();f();f();d();var Jt="retrieveMultiple",Yt=`${c}.${Jt}`,C=async(e,t,r)=>{a.parameterCheck(e,Yt,"request");let o;return e.functionName?o=e:(o=l(e),o.functionName=Jt),o.method="GET",r&&(a.stringParameterCheck(r,Yt,"nextPageLink"),o.url=r),(await t.makeRequest(o))?.data};var Io="retrieveAll",ko=`${c}.${Io}`,ce=async(e,t,r,o=[])=>{let n=await C(e,t,r);o=o.concat(n.value);let i=n.oDataNextLink;if(i)return ce(e,t,i,o);let s={value:o};return n.oDataDeltaLink&&(s["@odata.deltaLink"]=n.oDataDeltaLink,s.oDataDeltaLink=n.oDataDeltaLink),s},Fe=(e,t)=>(a.throwBatchIncompatible(ko,t.isBatch),ce(e,t));var So="countAll",jt=`${c}.${So}`,Zt=async(e,t)=>(a.throwBatchIncompatible(jt,t.isBatch),a.parameterCheck(e,jt,"request"),(await ce(e,t)).value.length);f();d();var er="disassociate",le=`${c}.${er}`,tr=async(e,t)=>{a.parameterCheck(e,le,"request");let r=l(e);r.method="DELETE",r.functionName=er,a.stringParameterCheck(e.relationshipName,le,"request.relationshipName");let o=a.keyParameterCheck(e.primaryKey,le,"request.primaryKey"),n=a.keyParameterCheck(e.relatedKey,le,"request.relatedId");r.key=o,r.navigationProperty=`${e.relationshipName}(${n})/$ref`,await t.makeRequest(r)};f();d();var rr="disassociateSingleValued",qe=`${c}.${rr}`,nr=async(e,t)=>{a.parameterCheck(e,qe,"request");let r=l(e);r.method="DELETE",r.functionName=rr,a.stringParameterCheck(e.navigationProperty,qe,"request.navigationProperty");let o=a.keyParameterCheck(e.primaryKey,qe,"request.primaryKey");r.navigationProperty+="/$ref",r.key=o,await t.makeRequest(r)};f();d();var or="retrieve",Oo=`${c}.${or}`,N=async(e,t)=>{a.parameterCheck(e,Oo,"request");let r;return e.functionName?r=e:(r=l(e),r.functionName=or),r.method="GET",r.responseParameters={isRef:r.select?.length===1&&r.select[0].endsWith("/$ref")},(await t.makeRequest(r))?.data};f();h();d();var ar="fetch",me=`${c}.${ar}`,ue=async(e,t)=>{a.parameterCheck(e,me,"request");let r=l(e);if(r.method="GET",r.functionName=ar,a.stringParameterCheck(r.fetchXml,me,"request.fetchXml"),r.fetchXml&&!ut.test(r.fetchXml)){let n="";ft.test(r.fetchXml)||(r.pageNumber=r.pageNumber||1,a.numberParameterCheck(r.pageNumber,me,"request.pageNumber"),n=`$1 page="${r.pageNumber}"`),r.pagingCookie!=null&&(a.stringParameterCheck(r.pagingCookie,me,"request.pagingCookie"),n+=` paging-cookie="${r.pagingCookie}"`),n&&(r.fetchXml=r.fetchXml.replace(dt,n))}return r.responseParameters={pageNumber:r.pageNumber},(await t.makeRequest(r))?.data};f();var Mo="fetchAll",ir=`${c}.${Mo}`,sr=async(e,t,r=[])=>{let o=await ue(e,t);return r=r.concat(o.value),o.PagingInfo?(e.pageNumber=o.PagingInfo.nextPage,e.pagingCookie=o.PagingInfo.cookie,sr(e,t,r)):{value:r}},pr=async(e,t)=>(a.parameterCheck(e,ir,"request"),a.throwBatchIncompatible(ir,t.isBatch),sr(e,t));f();h();d();var cr="update",Uo=`${c}.${cr}`,P=async(e,t)=>{a.parameterCheck(e,Uo,"request");let r;e.functionName?r=e:(r=l(e),r.functionName=cr),r.method??(r.method=mt(r.collection)),r.responseParameters={valueIfEmpty:!0},r.ifmatch??(r.ifmatch="*");let o=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(n){if(o&&n.status===412)return!1;throw n}};f();d();var mr="updateSingleProperty",lr=`${c}.${mr}`,ur=async(e,t)=>{a.parameterCheck(e,lr,"request"),a.parameterCheck(e.fieldValuePair,lr,"request.fieldValuePair");var r=Object.keys(e.fieldValuePair)[0],o=e.fieldValuePair[r];let n=l(e);return n.navigationProperty=r,n.data={value:o},n.functionName=mr,n.method="PUT",delete n.fieldValuePair,(await t.makeRequest(n))?.data};f();d();var fr="upsert",_o=`${c}.${fr}`,dr=async(e,t)=>{a.parameterCheck(e,_o,"request");let r=l(e);r.method="PATCH",r.functionName=fr;let o=r.ifnonematch,n=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(i){if(o&&i.status===412)return null;if(n&&i.status===404)return null;throw i}};f();d();var yr="deleteRecord",$o=`${c}.${yr}`,Q=async(e,t)=>{a.parameterCheck(e,$o,"request");let r;e.functionName?r=e:(r=l(e),r.functionName=yr),r.method="DELETE",r.responseParameters={valueIfEmpty:!0};let o=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(n){if(o&&n.status===412)return!1;throw n}};f();d();var gr="uploadFile",Rr=`${c}.${gr}`,hr=async(e,t,r,o,n=0)=>{if(bt(e,r,o,n),await t.makeRequest(e),n+=o,n<=r.length)return hr(e,t,r,o,n)},Cr=async(e,t)=>{a.throwBatchIncompatible(Rr,t.isBatch),a.parameterCheck(e,Rr,"request");let r=l(e,["data"]);r.method="PATCH",r.functionName=gr,r.transferMode="chunked";let o=await t.makeRequest(r);return r.url=o?.data.location,delete r.transferMode,delete r.fieldName,delete r.property,delete r.fileName,hr(r,t,e.data,o?.data.chunkSize)};f();d();var Er="downloadFile",Ar=`${c}.${Er}`,br=async(e,t,r=0,o="")=>{e.range="bytes="+r+"-"+(r+ve-1),e.downloadSize="full";let n=await t.makeRequest(e);return e.url=n?.data.location,o+=n?.data.value,r+=ve,r<=n?.data.fileSize?br(e,t,r,o):{fileName:n?.data.fileName,fileSize:n?.data.fileSize,data:xt(o)}},xr=(e,t)=>{a.throwBatchIncompatible(Ar,t.isBatch),a.parameterCheck(e,Ar,"request");let r=l(e);return r.method="GET",r.functionName=Er,r.responseParameters={parse:!0},br(r,t)};d();f();var wo="executeBatch",Bo=`${c}.${wo}`;async function Tr(e,t){a.throwBatchNotStarted(t.isBatch);let r=e?l(e):{};return r.collection="$batch",r.method="POST",r.functionName=Bo,r.requestId=t.batchRequestId,t.batchRequestId=null,t.isBatch=!1,(await t.makeRequest(r))?.data}function vr(e){e.isBatch=!0,e.batchRequestId=O()}f();d();var Pr="createEntity",Nr=`${c}.${Pr}`,Dr=async(e,t)=>{a.parameterCheck(e,Nr,"request"),a.parameterCheck(e.data,Nr,"request.data");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Pr,v(r,t)};f();d();var kr="updateEntity",Ir=`${c}.${kr}`,Sr=async(e,t)=>{a.parameterCheck(e,Ir,"request"),a.parameterCheck(e.data,Ir,"request.data");let r=l(e);return r.collection="EntityDefinitions",r.functionName=kr,r.key=r.data.MetadataId,r.method="PUT",await P(r,t)};f();d();var Fo="retrieveEntity",Or=`${c}.${Fo}`,Mr=async(e,t)=>{a.parameterCheck(e,Or,"request"),a.keyParameterCheck(e.key,Or,"request.key");let r=l(e);return r.collection="EntityDefinitions",r.functionName="retrieveEntity",await N(r,t)};d();var qo="retrieveEntities",Ur=(e,t)=>{let r=t?l(t):{};return r.collection="EntityDefinitions",r.functionName=qo,C(r,e)};d();f();var _r="createAttribute",Qe=`${c}.${_r}`,$r=(e,t)=>{a.parameterCheck(e,Qe,"request"),a.parameterCheck(e.data,Qe,"request.data"),a.keyParameterCheck(e.entityKey,Qe,"request.entityKey");let r=l(e);return r.collection="EntityDefinitions",r.functionName=_r,r.navigationProperty="Attributes",r.key=e.entityKey,v(r,t)};d();f();var wr="updateAttribute",fe=`${c}.${wr}`,Br=(e,t)=>{a.parameterCheck(e,fe,"request"),a.parameterCheck(e.data,fe,"request.data"),a.keyParameterCheck(e.entityKey,fe,"request.entityKey"),a.guidParameterCheck(e.data.MetadataId,fe,"request.data.MetadataId");let r=l(e);return r.collection="EntityDefinitions",r.functionName=wr,r.navigationProperty="Attributes",r.navigationPropertyKey=e.data.MetadataId,r.metadataAttributeType=e.castType,r.key=e.entityKey,r.method="PUT",P(r,t)};d();f();var Fr="retrieveAttributes",He=`${c}.${Fr}`,qr=(e,t)=>{a.parameterCheck(e,He,"request"),a.keyParameterCheck(e.entityKey,He,"request.entityKey"),e.castType&&a.stringParameterCheck(e.castType,He,"request.castType");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Fr,r.navigationProperty="Attributes",r.key=e.entityKey,r.metadataAttributeType=e.castType,C(r,t)};d();f();var Qr="retrieveAttributes",de=`${c}.${Qr}`,Hr=(e,t)=>{a.parameterCheck(e,de,"request"),a.keyParameterCheck(e.entityKey,de,"request.entityKey"),a.keyParameterCheck(e.attributeKey,de,"request.attributeKey"),e.castType&&a.stringParameterCheck(e.castType,de,"request.castType");let r=l(e);return r.collection="EntityDefinitions",r.navigationProperty="Attributes",r.navigationPropertyKey=e.attributeKey,r.metadataAttributeType=e.castType,r.key=e.entityKey,r.functionName=Qr,N(r,t)};d();f();var Wr="createRelationship",Lr=`${c}.${Wr}`,Vr=(e,t)=>{a.parameterCheck(e,Lr,"request"),a.parameterCheck(e.data,Lr,"request.data");let r=l(e);return r.collection="RelationshipDefinitions",r.functionName=Wr,v(r,t)};d();f();var Gr="updateRelationship",ye=`${c}.${Gr}`;function Xr(e,t){a.parameterCheck(e,ye,"request"),a.parameterCheck(e.data,ye,"request.data"),a.guidParameterCheck(e.data.MetadataId,ye,"request.data.MetadataId"),e.castType&&a.stringParameterCheck(e.castType,ye,"request.castType");let r=l(e);return r.collection="RelationshipDefinitions",r.key=e.data.MetadataId,r.navigationProperty=e.castType,r.functionName=Gr,r.method="PUT",P(r,t)}d();f();var zr="deleteRelationship",Kr=`${c}.${zr}`;async function Yr(e,t){a.parameterCheck(e,Kr,"request"),a.keyParameterCheck(e.key,Kr,"request.key");let r=l(e);return r.collection="RelationshipDefinitions",r.functionName=zr,Q(r,t)}d();f();var Jr="retrieveRelationships",Qo=`DynamicsWebApi.${Jr}`;async function jr(e,t){let r=e?l(e):{};return r.collection="RelationshipDefinitions",r.functionName=Jr,e&&e.castType&&(a.stringParameterCheck(e.castType,Qo,"request.castType"),r.navigationProperty=e.castType),C(r,t)}d();f();var Zr="retrieveRelationship",Le=`DynamicsWebApi.${Zr}`;async function en(e,t){a.parameterCheck(e,Le,"request"),a.keyParameterCheck(e.key,Le,"request.key"),e.castType&&a.stringParameterCheck(e.castType,Le,"request.castType");let r=l(e);return r.collection="RelationshipDefinitions",r.navigationProperty=e.castType,r.functionName=Zr,N(r,t)}d();f();var rn="createGlobalOptionSet",tn=`DynamicsWebApi.${rn}`;async function nn(e,t){a.parameterCheck(e,tn,"request"),a.parameterCheck(e.data,tn,"request.data");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.functionName=rn,v(r,t)}d();f();var on="updateGlobalOptionSet",Re=`DynamicsWebApi.${on}`;async function an(e,t){a.parameterCheck(e,Re,"request"),a.parameterCheck(e.data,Re,"request.data"),a.guidParameterCheck(e.data.MetadataId,Re,"request.data.MetadataId"),e.castType&&a.stringParameterCheck(e.castType,Re,"request.castType");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.key=e.data.MetadataId,r.functionName=on,r.method="PUT",P(r,t)}d();f();var sn="deleteGlobalOptionSet",Ho=`DynamicsWebApi.${sn}`;async function pn(e,t){a.parameterCheck(e,Ho,"request");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.functionName=sn,Q(r,t)}d();f();var ln="retrieveGlobalOptionSet",cn=`DynamicsWebApi.${ln}`;async function mn(e,t){a.parameterCheck(e,cn,"request"),e.castType&&a.stringParameterCheck(e.castType,cn,"request.castType");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.navigationProperty=e.castType,r.functionName=ln,N(r,t)}d();f();var un="retrieveGlobalOptionSets",Lo=`DynamicsWebApi.${un}`;async function fn(e,t){let r=e?l(e):{};return r.collection="GlobalOptionSetDefinitions",r.functionName=un,e?.castType&&(a.stringParameterCheck(e.castType,Lo,"request.castType"),r.navigationProperty=e.castType),C(r,t)}d();f();var dn="retrieveCsdlMetadata",Wo=`DynamicsWebApi.${dn}`;async function yn(e,t){let r=e?l(e):{};return r.collection="$metadata",r.functionName=dn,e?.addAnnotations&&(a.boolParameterCheck(e.addAnnotations,Wo,"request.addAnnotations"),r.includeAnnotations="*"),(await t.makeRequest(r))?.data}d();f();h();function H(e,t,r){if(!e)return e;switch(r?.escapeSpecialCharacters===!0&&(e.search=Rt(e.search)),e.entities?.length&&(e.entities=Vo(e.entities,r?.version)),t){case"query":Go(e,r?.version);break;default:Xo(e,r?.version);break}return e}function Vo(e,t="1.0"){if(!e)return e;if(typeof e=="string"){if(t!=="1.0")return e;try{e=JSON.parse(e)}catch{throw new Error("The 'query.entities' property must be a valid JSON string.")}if(!Array.isArray(e))throw new Error("The 'query.entities' property must be an array of strings or objects.")}let r=i=>typeof i=="string"?i:i.name,o=i=>typeof i=="string"?{name:i}:i,n=e.map(i=>t==="1.0"?r(i):o(i));return t!=="1.0"?JSON.stringify(n):n}function Go(e,t="1.0"){t==="1.0"?(n=>{if(n.count!=null&&(n.returnTotalRecordCount==null&&(n.returnTotalRecordCount=n.count),delete n.count),n.options){if(typeof n.options=="string")try{n.options=JSON.parse(n.options,Ko)}catch{throw new Error("The 'query.options' property must be a valid JSON string.")}n.searchMode||(n.searchMode=n.options.searchMode),n.searchType||(n.searchType=n.options.queryType==="lucene"?"full":n.options.queryType),delete n.options}for(let i of zo)if(n[i]&&typeof n[i]=="string")try{n[i]=JSON.parse(n[i])}catch{throw new Error(`The 'query.${i}' property must be a valid JSON string.`)}})(e):(n=>{n.returnTotalRecordCount!=null&&(n.count==null&&(n.count=n.returnTotalRecordCount),delete n.returnTotalRecordCount),(n.searchMode||n.searchType)&&(typeof n.options!="string"&&(n.options||(n.options={}),n.options.searchMode||(n.options.searchMode=n.searchMode),n.options.queryType||(n.options.queryType=n.searchType==="full"?"lucene":n.searchType)),delete n.searchMode,delete n.searchType),n.orderBy&&typeof n.orderBy!="string"&&(n.orderby=JSON.stringify(n.orderBy),delete n.orderBy),n.facets&&typeof n.facets!="string"&&(n.facets=JSON.stringify(n.facets)),n.options&&typeof n.options!="string"&&(n.options=JSON.stringify(Rn(n.options)))})(e)}function Xo(e,t="1.0"){t==="1.0"?(n=>{if(n.fuzzy!=null&&(n.useFuzzy==null&&(n.useFuzzy=n.fuzzy),delete n.fuzzy),delete n.options,n.orderBy&&typeof n.orderBy=="string")try{n.orderBy=JSON.parse(n.orderBy)}catch{throw new Error("The 'query.orderBy' property must be a valid JSON string.")}})(e):(n=>{n.useFuzzy!=null&&(n.fuzzy==null&&(n.fuzzy=n.useFuzzy),delete n.useFuzzy),n.orderBy&&typeof n.orderBy!="string"&&(n.orderby=JSON.stringify(n.orderBy),delete n.orderBy),n.options&&typeof n.options!="string"&&(n.options=JSON.stringify(Rn(n.options)))})(e)}function Rn(e){let t={};for(let r in e)t[r.toLowerCase()]=e[r];return t}function Ko(e,t){switch(e){case"searchmode":this.searchMode=t;break;case"querytype":this.queryType=t;break;default:return t}}var zo=["orderBy","facets"];function gn(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S),i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.facets=n.Facets,i.totalrecordcount=n.Count,i.querycontext=n.QueryContext),i},o=()=>{let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Count:e.totalrecordcount,Value:e.value,Facets:e.facets,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():o()}var We="query",ge=`${c}.${We}`;async function Ve(e,t){a.parameterCheck(e,ge,"request");let r=typeof e!="string",o=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};a.parameterCheck(n.query,ge,"request.query"),a.stringParameterCheck(n.query.search,ge,o),a.maxLengthStringParameterCheck(n.query.search,ge,o,100),n.collection="query",n.functionName=We,n.method="POST",n.data=H(n.query,We,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return gn(i.data,t.config.searchApi)}d();f();function hn(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S);t.enableSearchApiResponseCompatibility&&n.Value?.forEach(s=>{s.document=s.Document,s.text=s.Text});let i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.querycontext=n.QueryContext),i},o=()=>{t.enableSearchApiResponseCompatibility&&e.value?.forEach(i=>{i.Document=i.document,i.Text=i.text});let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Value:e.value,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():o()}var Ge="suggest",he=`${c}.${Ge}`;async function Cn(e,t){a.parameterCheck(e,he,"request");let r=typeof e!="string",o=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};a.parameterCheck(n.query,he,"request.query"),a.stringParameterCheck(n.query.search,he,o),a.maxLengthStringParameterCheck(n.query.search,he,o,100),n.functionName=n.collection=Ge,n.method="POST",n.data=H(n.query,Ge,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return hn(i.data,t.config.searchApi)}d();f();function An(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S),i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.querycontext=n.QueryContext),i},o=()=>{let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Value:e.value,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():o()}var Xe="autocomplete",Ce=`${c}.${Xe}`;async function En(e,t){a.parameterCheck(e,Ce,"request");let r=typeof e!="string",o=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};r&&a.parameterCheck(n.query,Ce,"request.query"),a.stringParameterCheck(n.query.search,Ce,o),a.maxLengthStringParameterCheck(n.query.search,Ce,o,100),n.functionName=n.collection=Xe,n.method="POST",n.data=H(n.query,Xe,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return An(i.data,t.config.searchApi)}f();var xn="getBackgroundOperationStatus",bn=`${c}.${xn}`;async function Tn(e,t){a.throwBatchIncompatible(bn,t.isBatch),a.keyParameterCheck(e,bn,"backgroundOperationId");let r={method:"GET",addPath:`backgroundoperation/${e}`,functionName:xn,apiConfig:t.config.serviceApi,includeDefaultDataverseHeaders:!1,headers:{"Content-Type":"application/json"},_isUnboundRequest:!0};return(await t.makeRequest(r))?.data}f();var Nn="cancelBackgroundOperation",vn=`${c}.${Nn}`;async function Pn(e,t){a.throwBatchIncompatible(vn,t.isBatch),a.keyParameterCheck(e,vn,"backgroundOperationId");let r={method:"DELETE",addPath:`backgroundoperation/${e}`,functionName:Nn,apiConfig:t.config.serviceApi,includeDefaultDataverseHeaders:!1,headers:{"Content-Type":"application/json"},_isUnboundRequest:!0};return(await t.makeRequest(r))?.data}d();var u,ze=class ze{constructor(t){B(this,u);this.setConfig=t=>m(this,u).setConfig(t);this.create=async t=>v(t,m(this,u));this.retrieve=async t=>N(t,m(this,u));this.update=async t=>P(t,m(this,u));this.updateSingleProperty=async t=>ur(t,m(this,u));this.deleteRecord=async t=>Q(t,m(this,u));this.upsert=async t=>dr(t,m(this,u));this.uploadFile=async t=>Cr(t,m(this,u));this.downloadFile=t=>xr(t,m(this,u));this.retrieveMultiple=async(t,r)=>C(t,m(this,u),r);this.retrieveAll=t=>Fe(t,m(this,u));this.count=async t=>zt(t,m(this,u));this.countAll=async t=>Zt(t,m(this,u));this.fetch=async t=>ue(t,m(this,u));this.fetchAll=async t=>pr(t,m(this,u));this.associate=async t=>Bt(t,m(this,u));this.disassociate=async t=>tr(t,m(this,u));this.associateSingleValued=async t=>qt(t,m(this,u));this.disassociateSingleValued=async t=>nr(t,m(this,u));this.callFunction=async t=>Gt(t,m(this,u));this.callAction=async t=>Lt(t,m(this,u));this.createEntity=t=>Dr(t,m(this,u));this.updateEntity=t=>Sr(t,m(this,u));this.retrieveEntity=t=>Mr(t,m(this,u));this.retrieveEntities=t=>Ur(m(this,u),t);this.createAttribute=t=>$r(t,m(this,u));this.updateAttribute=t=>Br(t,m(this,u));this.retrieveAttributes=t=>qr(t,m(this,u));this.retrieveAttribute=t=>Hr(t,m(this,u));this.createRelationship=t=>Vr(t,m(this,u));this.updateRelationship=t=>Xr(t,m(this,u));this.deleteRelationship=t=>Yr(t,m(this,u));this.retrieveRelationships=t=>jr(t,m(this,u));this.retrieveRelationship=t=>en(t,m(this,u));this.createGlobalOptionSet=t=>nn(t,m(this,u));this.updateGlobalOptionSet=t=>an(t,m(this,u));this.deleteGlobalOptionSet=t=>pn(t,m(this,u));this.retrieveGlobalOptionSet=t=>mn(t,m(this,u));this.retrieveGlobalOptionSets=t=>fn(t,m(this,u));this.retrieveCsdlMetadata=async t=>yn(t,m(this,u));this.search=async t=>Ve(t,m(this,u));this.query=async t=>Ve(t,m(this,u));this.suggest=async t=>Cn(t,m(this,u));this.autocomplete=async t=>En(t,m(this,u));this.getBackgroundOperationStatus=async t=>Tn(t,m(this,u));this.cancelBackgroundOperation=async t=>Pn(t,m(this,u));this.startBatch=()=>vr(m(this,u));this.executeBatch=async t=>Tr(t,m(this,u));this.initializeInstance=t=>new ze(t||m(this,u).config);this.Utility={getCollectionName:t=>$t(t),toAbsoluteUrl:t=>Tt(m(this,u),t)};L(this,u,new pe(t))}};u=new WeakMap;var Ke=ze;return je(Jo);})(); 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 3435cf3..b353158 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/parseBatchResponse.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/requests/constants.ts", "../src/client/RequestClient.ts", "../src/client/helpers/entityNameMapper.ts", "../src/client/helpers/executeRequest.ts", "../src/client/request/composers/url.ts", "../src/client/request/composers/headers.ts", "../src/client/request/composers/preferHeader.ts", "../src/client/request/composers/request.ts", "../src/client/request/processData.ts", "../src/client/helpers/index.ts", "../src/client/request/setStandardHeaders.ts", "../src/client/request/convertToBatch.ts", "../src/client/dataverse.ts", "../src/requests/associate.ts", "../src/requests/associateSingleValued.ts", "../src/requests/callAction.ts", "../src/requests/callFunction.ts", "../src/requests/create.ts", "../src/requests/count.ts", "../src/requests/countAll.ts", "../src/requests/retrieveAll.ts", "../src/requests/retrieveMultiple.ts", "../src/requests/disassociate.ts", "../src/requests/disassociateSingleValued.ts", "../src/requests/retrieve.ts", "../src/requests/fetchXml.ts", "../src/requests/fetchXmlAll.ts", "../src/requests/update.ts", "../src/requests/updateSingleProperty.ts", "../src/requests/upsert.ts", "../src/requests/delete.ts", "../src/requests/uploadFile.ts", "../src/requests/downloadFile.ts", "../src/requests/executeBatch.ts", "../src/requests/metadata/createEntity.ts", "../src/requests/metadata/updateEntity.ts", "../src/requests/metadata/retrieveEntity.ts", "../src/requests/metadata/retrieveEntities.ts", "../src/requests/metadata/createAttribute.ts", "../src/requests/metadata/updateAttribute.ts", "../src/requests/metadata/retrieveAttributes.ts", "../src/requests/metadata/retrieveAttribute.ts", "../src/requests/metadata/createRelationship.ts", "../src/requests/metadata/updateRelationship.ts", "../src/requests/metadata/deleteRelationship.ts", "../src/requests/metadata/retrieveRelationships.ts", "../src/requests/metadata/retrieveRelationship.ts", "../src/requests/metadata/createGlobalOptionSet.ts", "../src/requests/metadata/updateGlobalOptionSet.ts", "../src/requests/metadata/deleteGlobalOptionSet.ts", "../src/requests/metadata/retrieveGlobalOptionSet.ts", "../src/requests/metadata/retrieveGlobalOptionSets.ts", "../src/requests/metadata/retrieveCsdlMetadata.ts", "../src/requests/search/query.ts", "../src/requests/search/convertSearchQuery.ts", "../src/requests/search/responseParsers/parseQueryResponse.ts", "../src/requests/search/suggest.ts", "../src/requests/search/responseParsers/parseSuggestResponse.ts", "../src/requests/search/autocomplete.ts", "../src/requests/search/responseParsers/parseAutocompleteResponse.ts", "../src/requests/backgroundOperation/getStatus.ts", "../src/requests/backgroundOperation/cancel.ts"], - "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? (global.window.crypto as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nconst LEADING_SLASH_REGEX = /^\\//;\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.replace(LEADING_SLASH_REGEX, \"\");\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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", "\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): Record {\r\n\tconst headers: Record = {};\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 type * as 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 headers = options.headers;\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 headers) {\r\n request.setRequestHeader(key, headers[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 if (!request || request.status === 0) return; // response was handled elsewhere or will be handled by onerror\r\n\r\n if ((request.status >= 200 && request.status < 300) || request.status === 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 } else {\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 return;\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 }\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 { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\r\n};\r\n", "import { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const 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 value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n"], - "mappings": ";40BAAO,SAASA,IAAwB,CACpC,OAA6B,OAAc,MAC/C,CAFA,IAAAC,GAAAC,EAAA,oBCWO,SAASC,GAAOC,EAAwB,CAE3C,MAAO,CAAC,CADMC,GAAW,KAAKD,CAAK,CAEvC,CAEO,SAASE,EAAYF,EAA8B,CACtD,IAAMG,EAAQC,GAAmB,KAAKJ,CAAK,EAC3C,OAAOG,EAAQA,EAAM,CAAC,EAAI,IAC9B,CAEO,SAASE,EAAmBC,EAA6B,CAC5D,GAAI,CAACA,EAAK,OAAO,KACjB,IAAMH,EAAQI,GAA4B,KAAKD,CAAG,EAClD,OAAOH,EAAQA,EAAM,CAAC,EAAI,IAC9B,CAEO,SAASK,GAA4BR,EAAuB,CAC/D,OAAOA,EAAM,QAAQS,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AASD,EAAA,KAAKJ,EAAO,EAS3D,8BAA0CK,GAC5BuC,GAAyBvC,EAASD,EAAA,KAAKJ,EAAO,EAO5D,0BAAuB,MAAOK,GAA6DwC,GAAqBxC,EAASD,EAAA,KAAKJ,EAAO,EAQrI,YAAyB,MAAqBK,GAEhCyC,GAAMzC,EAASD,EAAA,KAAKJ,EAAO,EAOzC,WAAuB,MAAOK,GAAqEyC,GAAMzC,EAASD,EAAA,KAAKJ,EAAO,EAO9H,aAA2B,MAA6BK,GAC1C0C,GAAQ1C,EAASD,EAAA,KAAKJ,EAAO,EAO3C,kBAAqC,MAAOK,GAC9B2C,GAAa3C,EAASD,EAAA,KAAKJ,EAAO,EAOhD,kCAA+B,MAAOiD,GACxBC,GAA6BD,EAAuB7C,EAAA,KAAKJ,EAAO,EAO9E,+BAA4B,MAAOiD,GACrBE,GAA0BF,EAAuB7C,EAAA,KAAKJ,EAAO,EAK3E,gBAAa,IAAsBoD,GAAWhD,EAAA,KAAKJ,EAAO,EAO1D,kBAAe,MAAOK,GAAqDgD,GAAahD,EAASD,EAAA,KAAKJ,EAAO,EAQ7G,wBAAsBE,GAAoC,IAAID,GAAeC,GAAUE,EAAA,KAAKJ,GAAQ,MAAM,EAE1G,aAAU,CAQN,kBAAoBsD,GAAsCC,GAAkBD,CAAU,CAC1F,EAldIE,EAAA,KAAKxD,EAAU,IAAIyD,GAAgBvD,CAAM,EAC7C,CAkdJ,EA1dIF,EAAA,YADG,IAAM0D,GAANzD", - "names": ["getCrypto", "init_Crypto", "__esmMin", "isUuid", "value", "UUID_REGEX", "extractUuid", "match", "EXTRACT_UUID_REGEX", "extractUuidFromUrl", "url", "EXTRACT_UUID_FROM_URL_REGEX", "removeCurlyBracketsFromUuid", "REMOVE_BRACKETS_FROM_UUID_REGEX", "_match", "p1", "safelyRemoveCurlyBracketsFromUrl", "QUOTATION_MARK_REGEX", "part", "index", "convertToReferenceObject", "responseData", "result", "ENTITY_UUID_REGEX", "parsePagingCookie", "pagingCookie", "info", "PAGING_COOKIE_REGEX", "page", "sanitizedCookie", "sanitizeCookie", "cookie", "characterMap", "SPECIAL_CHARACTER_REGEX", "char", "removeLeadingSlash", "LEADING_SLASH_REGEX", "escapeUnicodeSymbols", "UNICODE_SYMBOLS_REGEX", "chr", "removeDoubleQuotes", "DOUBLE_QUOTE_REGEX", "getUpdateMethod", "collection", "SPECIAL_COLLECTION_FOR_UPDATE_REGEX", "escapeSearchSpecialCharacters", "SEARCH_SPECIAL_CHARACTERS_REGEX", "extractPreferCallbackUrl", "PREFER_CALLBACK_URL_REGEX", "UUID", "BATCH_RESPONSE_HEADERS_REGEX", "HTTP_STATUS_REGEX", "CONTENT_TYPE_PLAIN_REGEX", "ODATA_ENTITYID_REGEX", "TEXT_REGEX", "LINE_ENDING_REGEX", "SEARCH_FOR_ENTITY_NAME_REGEX", "FETCH_XML_TOP_REGEX", "FETCH_XML_PAGE_REGEX", "FETCH_XML_REPLACE_REGEX", "DATE_FORMAT_REGEX", "init_Regex", "__esmMin", "formatParameterValue", "value", "isUuid", "processParameters", "parameters", "parameterNames", "functionParams", "urlQuery", "parameterName", "index", "paramIndex", "extractUuid", "hasHeader", "headers", "name", "getHeader", "buildFunctionParameters", "getFetchXmlPagingCookie", "pageCookies", "currentPageNumber", "result", "parsePagingCookie", "isNull", "generateUUID", "getCrypto", "getXrmContext", "getClientUrl", "clientUrl", "isRunningWithinPortals", "isObject", "obj", "copyObject", "src", "excludeProps", "target", "prop", "copyRequest", "setFileChunk", "request", "fileBuffer", "chunkSize", "offset", "count", "content", "i", "convertToFileBuffer", "binaryString", "bytes", "downloadChunkSize", "init_Utility", "__esmMin", "init_Crypto", "init_Regex", "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", "DATE_FORMAT_REGEX", "init_dateReviver", "__esmMin", "init_Regex", "parseBatchHeaders", "text", "ctx", "headers", "parts", "line", "pos", "readLine", "BATCH_RESPONSE_HEADERS_REGEX", "readTo", "LINE_ENDING_REGEX", "searchRegTerm", "start", "slicedText", "match", "end", "getHttpStatus", "response", "HTTP_STATUS_REGEX", "getPlainContent", "textReg", "TEXT_REGEX", "handlePlainContent", "batchResponse", "parseParams", "requestNumber", "plainContent", "handlePlainResponse", "handleEmptyContent", "entityUrl", "ODATA_ENTITYID_REGEX", "extractUuidFromUrl", "processBatchPart", "httpStatusString", "httpStatus", "httpStatusMessage", "responseData", "CONTENT_TYPE_PLAIN_REGEX", "parsedResponse", "handleJsonResponse", "responseHeaders", "ErrorHelper", "parseBatchResponse", "delimiter", "batchResponseParts", "result", "part", "batchToProcess", "init_parseBatchResponse", "__esmMin", "init_ErrorHelper", "init_Regex", "init_parseResponse", "getFormattedKeyValue", "keyName", "value", "newKey", "format", "DWA", "parseData", "object", "parseParams", "convertToReferenceObject", "currentKey", "j", "formattedKeyValue", "aliasKeys", "getFetchXmlPagingCookie", "base64ToString", "base64", "parseFileResponse", "response", "responseHeaders", "data", "parseResult", "location", "getHeader", "isBatchResponse", "isFileResponse", "hasHeader", "isJsonResponse", "handleBatchResponse", "batch", "parseBatchResponse", "handleFileResponse", "handleJsonResponse", "requestNumber", "dateReviver", "handlePlainResponse", "numberResponse", "handleEmptyResponse", "entityUrl", "extractUuidFromUrl", "result", "parseResponse", "init_parseResponse", "__esmMin", "init_dwa", "init_Utility", "init_dateReviver", "init_Regex", "init_parseBatchResponse", "parseResponseHeaders", "headerStr", "headers", "headerPairs", "i", "ilen", "headerPair", "index", "init_parseResponseHeaders", "__esmMin", "xhr_exports", "__export", "XhrWrapper", "executeRequest", "options", "resolve", "reject", "_executeRequest", "successCallback", "errorCallback", "data", "headers", "responseParams", "signal", "ErrorHelper", "request", "key", "abort", "responseHeaders", "parseResponseHeaders", "response", "parseResponse", "error", "errorParsed", "errorParameters", "init_xhr", "__esmMin", "init_ErrorHelper", "init_parseResponse", "init_parseResponseHeaders", "dynamics_web_api_exports", "__export", "DynamicsWebApi", "init_Utility", "init_ErrorHelper", "LIBRARY_NAME", "FUNCTION_NAME", "LIBRARY_NAME", "apiConfigs", "getApiUrl", "serverUrl", "apiConfig", "isRunningWithinPortals", "getClientUrl", "url", "mergeSearchApiOptions", "internalApiConfig", "options", "ErrorHelper", "mergeApiConfig", "internalConfig", "apiType", "config", "mergeConfig", "defaultConfig", "init_Utility", "init_Utility", "entityNames", "setEntityNames", "newEntityNames", "findCollectionName", "entityName", "isNull", "collectionName", "key", "executeRequest", "options", "init_ErrorHelper", "init_ErrorHelper", "init_Regex", "init_Utility", "composeUrl", "request", "config", "url", "joinSymbol", "queryArray", "ErrorHelper", "navigationKey", "filterResult", "safelyRemoveCurlyBracketsFromUrl", "isNull", "expandQueryArray", "property", "expand", "expandRequest", "expandConverted", "init_ErrorHelper", "init_ErrorHelper", "init_Regex", "composePreferHeader", "request", "config", "functionName", "options", "prefer", "ErrorHelper", "preferArray", "item", "trimmedItem", "extractPreferCallbackUrl", "removeDoubleQuotes", "key", "optionFactory", "preferOptionsFactory", "value", "url", "annotations", "size", "composeHeaders", "request", "config", "headers", "prefer", "composePreferHeader", "ErrorHelper", "init_ErrorHelper", "composeRequest", "request", "config", "ErrorHelper", "composeUrl", "composeHeaders", "init_Regex", "init_Utility", "init_dateReviver", "init_parseBatchResponse", "init_parseResponse", "init_parseResponseHeaders", "processData", "data", "config", "replaceEntityNameWithCollectionName", "value", "valueParts", "SEARCH_FOR_ENTITY_NAME_REGEX", "collectionName", "findCollectionName", "isNull", "addFullWebApiUrl", "key", "removeLeadingSlash", "stringifiedData", "removeCurlyBracketsFromUuid", "escapeUnicodeSymbols", "setStandardHeaders", "headers", "data", "init_Utility", "convertToBatch", "requests", "config", "batchRequest", "batchBoundary", "generateUUID", "batchBody", "currentChangeSet", "contentId", "addHeaders", "headers", "key", "internalRequest", "inChangeSet", "contentIdValue", "processData", "setStandardHeaders", "_addResponseParams", "requestId", "responseParams", "_responseParseParams", "_addRequestToBatchCollection", "request", "_batchRequestCollection", "_clearRequestData", "_runRequest", "config", "result", "sendRequest", "error", "_nameExceptions", "_isEntityNameException", "entityName", "_getCollectionNames", "isNull", "entityNames", "findCollectionName", "composeRequest", "setEntityNames", "i", "_checkCollectionName", "generateUUID", "processedData", "isBatchConverted", "batchRequest", "ErrorHelper", "batchResult", "convertToBatch", "processData", "setStandardHeaders", "token", "isRunningWithinPortals", "url", "executeRequest", "makeRequest", "collectionName", "getCollectionName", "entityName", "findCollectionName", "_config", "_isBatch", "_batchRequestId", "DataverseClient", "config", "__privateAdd", "defaultConfig", "mergeConfig", "__privateGet", "request", "makeRequest", "value", "__privateSet", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "associate", "request", "client", "ErrorHelper", "relatedKey", "odataId", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "associateSingleValued", "request", "client", "ErrorHelper", "relatedKey", "odataId", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "callAction", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "callFunction", "request", "client", "ErrorHelper", "getFunctionName", "isObject", "functionName", "parameterName", "internalRequest", "copyObject", "functionParameters", "buildFunctionParameters", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "create", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "count", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "init_ErrorHelper", "init_ErrorHelper", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveMultiple", "request", "client", "nextPageLink", "ErrorHelper", "internalRequest", "copyRequest", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveAllRequest", "request", "client", "nextPageLink", "records", "response", "retrieveMultiple", "pageLink", "result", "retrieveAll", "ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "countAll", "request", "client", "ErrorHelper", "retrieveAllRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "disassociate", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "primaryKey", "relatedKey", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "disassociateSingleValued", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "primaryKey", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieve", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Regex", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "fetchXml", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "FETCH_XML_TOP_REGEX", "replacementString", "FETCH_XML_PAGE_REGEX", "FETCH_XML_REPLACE_REGEX", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "executeFetchXmlAll", "request", "client", "records", "response", "fetchXml", "fetchXmlAll", "ErrorHelper", "init_ErrorHelper", "init_Regex", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "update", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "getUpdateMethod", "ifmatch", "error", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "updateSingleProperty", "request", "client", "ErrorHelper", "field", "fieldValue", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "upsert", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "ifnonematch", "ifmatch", "error", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "deleteRecord", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "ifmatch", "error", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "_uploadFileChunk", "request", "client", "fileBytes", "chunkSize", "offset", "setFileChunk", "uploadFile", "ErrorHelper", "internalRequest", "copyRequest", "response", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "downloadFileChunk", "request", "client", "bytesDownloaded", "data", "downloadChunkSize", "response", "convertToFileBuffer", "downloadFile", "ErrorHelper", "internalRequest", "copyRequest", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "executeBatch", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "startBatch", "generateUUID", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "createEntity", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "create", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "updateEntity", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "update", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveEntity", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieve", "init_Utility", "FUNCTION_NAME", "retrieveEntities", "client", "request", "internalRequest", "copyRequest", "retrieveMultiple", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "createAttribute", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "create", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "updateAttribute", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "update", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveAttributes", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieveMultiple", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveAttribute", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieve", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "createRelationship", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "create", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "updateRelationship", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "update", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "deleteRelationship", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "deleteRecord", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveRelationships", "request", "client", "internalRequest", "copyRequest", "ErrorHelper", "retrieveMultiple", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveRelationship", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieve", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "createGlobalOptionSet", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "create", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "updateGlobalOptionSet", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "update", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "deleteGlobalOptionSet", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "deleteRecord", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveGlobalOptionSet", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieve", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveGlobalOptionSets", "request", "client", "internalRequest", "copyRequest", "ErrorHelper", "retrieveMultiple", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveCsdlMetadata", "request", "client", "internalRequest", "copyRequest", "ErrorHelper", "init_Utility", "init_ErrorHelper", "init_Regex", "convertSearchQuery", "query", "functionName", "config", "escapeSearchSpecialCharacters", "convertEntitiesProperty", "convertQuery", "convertSuggestOrAutocompleteQuery", "entities", "version", "toStringArray", "entity", "toSearchEntity", "toReturn", "searchOptionsReviver", "prop", "specialProperties", "convertOptionKeysToLowerCase", "options", "newOptions", "key", "value", "parseQueryResponse", "queryResponse", "config", "toV1", "responseValue", "dateReviver", "toReturn", "toV2", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "query", "request", "client", "ErrorHelper", "_isObject", "parameterName", "internalRequest", "copyObject", "convertSearchQuery", "response", "parseQueryResponse", "init_Utility", "init_ErrorHelper", "parseSuggestResponse", "queryResponse", "config", "toV1", "responseValue", "dateReviver", "item", "toReturn", "toV2", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "suggest", "request", "client", "ErrorHelper", "_isObject", "parameterName", "internalRequest", "copyObject", "convertSearchQuery", "response", "parseSuggestResponse", "init_Utility", "init_ErrorHelper", "parseAutocompleteResponse", "queryResponse", "config", "toV1", "responseValue", "dateReviver", "toReturn", "toV2", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "autocomplete", "request", "client", "ErrorHelper", "_isObject", "parameterName", "internalRequest", "copyObject", "convertSearchQuery", "response", "parseAutocompleteResponse", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "getBackgroundOperationStatus", "backgroundOperationId", "client", "ErrorHelper", "internalRequest", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "cancelBackgroundOperation", "backgroundOperationId", "client", "ErrorHelper", "internalRequest", "_client", "_DynamicsWebApi", "config", "__privateAdd", "__privateGet", "request", "create", "retrieve", "update", "updateSingleProperty", "deleteRecord", "upsert", "uploadFile", "downloadFile", "nextPageLink", "retrieveMultiple", "retrieveAll", "count", "countAll", "fetchXml", "fetchXmlAll", "associate", "disassociate", "associateSingleValued", "disassociateSingleValued", "callFunction", "callAction", "createEntity", "updateEntity", "retrieveEntity", "retrieveEntities", "createAttribute", "updateAttribute", "retrieveAttributes", "retrieveAttribute", "createRelationship", "updateRelationship", "deleteRelationship", "retrieveRelationships", "retrieveRelationship", "createGlobalOptionSet", "updateGlobalOptionSet", "deleteGlobalOptionSet", "retrieveGlobalOptionSet", "retrieveGlobalOptionSets", "retrieveCsdlMetadata", "query", "suggest", "autocomplete", "backgroundOperationId", "getBackgroundOperationStatus", "cancelBackgroundOperation", "startBatch", "executeBatch", "entityName", "getCollectionName", "__privateSet", "DataverseClient", "DynamicsWebApi"] + "sourcesContent": ["export function getCrypto(): T {\r\n return global.DWA_BROWSER ? (global.window.crypto as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.startsWith(\"/\") ? value.slice(1) : value;\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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\nexport function toAbsoluteUrl(client: IDataverseClient, value: string): string {\r\n return `${client.config.dataApi.url}${removeLeadingSlash(value)}`;\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\r\n}\r\n", "\uFEFFexport function parseResponseHeaders(headerStr: string): Record {\r\n\tconst headers: Record = {};\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 type * as 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 headers = options.headers;\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 headers) {\r\n request.setRequestHeader(key, headers[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 if (!request || request.status === 0) return; // response was handled elsewhere or will be handled by onerror\r\n\r\n if ((request.status >= 200 && request.status < 300) || request.status === 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 } else {\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 return;\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 }\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 { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\nimport { toAbsoluteUrl } from \"./utils/Utility\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n\r\n /**\r\n * Adds an absolute Web API URL to the beginning of a provided value.\r\n * @param value The value to modify.\r\n * @returns The absolute URL.\r\n */\r\n toAbsoluteUrl: (value: string): string => toAbsoluteUrl(this.#client,value),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Disables enforcement of absolute URLs for @odata.id properties in the request body.\r\n * In some cases, @odata.id has an alternate key format that does not use absolute URLs, for example:\r\n * In an UpsertMultiple action body.\r\n */\r\n disableODataIdAbsoluteUrl?: boolean;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\r\n};\r\n", "import { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key === \"@odata.id\" || key.endsWith(\"@odata.bind\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n\r\n // the full Web API URL is only added in requests to /$ref\r\n // the value itself is set directly in the requests that require it\r\n if (key !== \"@odata.id\") {\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n"], + "mappings": ";40BAAO,SAASA,IAAwB,CACpC,OAA6B,OAAc,MAC/C,CAFA,IAAAC,GAAAC,EAAA,oBCWO,SAASC,GAAOC,EAAwB,CAE3C,MAAO,CAAC,CADMC,GAAW,KAAKD,CAAK,CAEvC,CAEO,SAASE,EAAYF,EAA8B,CACtD,IAAMG,EAAQC,GAAmB,KAAKJ,CAAK,EAC3C,OAAOG,EAAQA,EAAM,CAAC,EAAI,IAC9B,CAEO,SAASE,EAAmBC,EAA6B,CAC5D,GAAI,CAACA,EAAK,OAAO,KACjB,IAAMH,EAAQI,GAA4B,KAAKD,CAAG,EAClD,OAAOH,EAAQA,EAAM,CAAC,EAAI,IAC9B,CAEO,SAASK,GAA4BR,EAAuB,CAC/D,OAAOA,EAAM,QAAQS,GAAiC,CAACC,EAAQC,IAAOA,CAAE,CAC5E,CASO,SAASC,GAAiCN,EAAqB,CAKlE,OADcA,EAAI,MAAMO,EAAoB,EAEvC,IAAI,CAACC,EAAMC,IAEJA,EAAQ,IAAM,EACPP,GAA4BM,CAAI,EAE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BsC,GAAwBtC,EAASD,EAAA,KAAKJ,EAAO,EAS3D,8BAA0CK,GAC5BuC,GAAyBvC,EAASD,EAAA,KAAKJ,EAAO,EAO5D,0BAAuB,MAAOK,GAA6DwC,GAAqBxC,EAASD,EAAA,KAAKJ,EAAO,EAQrI,YAAyB,MAAqBK,GAEhCyC,GAAMzC,EAASD,EAAA,KAAKJ,EAAO,EAOzC,WAAuB,MAAOK,GAAqEyC,GAAMzC,EAASD,EAAA,KAAKJ,EAAO,EAO9H,aAA2B,MAA6BK,GAC1C0C,GAAQ1C,EAASD,EAAA,KAAKJ,EAAO,EAO3C,kBAAqC,MAAOK,GAC9B2C,GAAa3C,EAASD,EAAA,KAAKJ,EAAO,EAOhD,kCAA+B,MAAOiD,GACxBC,GAA6BD,EAAuB7C,EAAA,KAAKJ,EAAO,EAO9E,+BAA4B,MAAOiD,GACrBE,GAA0BF,EAAuB7C,EAAA,KAAKJ,EAAO,EAK3E,gBAAa,IAAsBoD,GAAWhD,EAAA,KAAKJ,EAAO,EAO1D,kBAAe,MAAOK,GAAqDgD,GAAahD,EAASD,EAAA,KAAKJ,EAAO,EAQ7G,wBAAsBE,GAAoC,IAAID,GAAeC,GAAUE,EAAA,KAAKJ,GAAQ,MAAM,EAE1G,aAAU,CAQN,kBAAoBsD,GAAsCC,GAAkBD,CAAU,EAOtF,cAAgBE,GAA0BC,GAAcrD,EAAA,KAAKJ,GAAQwD,CAAK,CAC9E,EAzdIE,EAAA,KAAK1D,EAAU,IAAI2D,GAAgBzD,CAAM,EAC7C,CAydJ,EAjeIF,EAAA,YADG,IAAM4D,GAAN3D", + "names": ["getCrypto", "init_Crypto", "__esmMin", "isUuid", "value", "UUID_REGEX", "extractUuid", "match", "EXTRACT_UUID_REGEX", "extractUuidFromUrl", "url", "EXTRACT_UUID_FROM_URL_REGEX", "removeCurlyBracketsFromUuid", "REMOVE_BRACKETS_FROM_UUID_REGEX", "_match", "p1", "safelyRemoveCurlyBracketsFromUrl", "QUOTATION_MARK_REGEX", "part", "index", "convertToReferenceObject", "responseData", "result", "ENTITY_UUID_REGEX", "parsePagingCookie", "pagingCookie", "info", "PAGING_COOKIE_REGEX", "page", "sanitizedCookie", "sanitizeCookie", "cookie", "characterMap", "SPECIAL_CHARACTER_REGEX", "char", "removeLeadingSlash", "escapeUnicodeSymbols", "UNICODE_SYMBOLS_REGEX", "chr", "removeDoubleQuotes", "DOUBLE_QUOTE_REGEX", "getUpdateMethod", "collection", "SPECIAL_COLLECTION_FOR_UPDATE_REGEX", "escapeSearchSpecialCharacters", "SEARCH_SPECIAL_CHARACTERS_REGEX", "extractPreferCallbackUrl", "PREFER_CALLBACK_URL_REGEX", "UUID", "BATCH_RESPONSE_HEADERS_REGEX", "HTTP_STATUS_REGEX", "CONTENT_TYPE_PLAIN_REGEX", "ODATA_ENTITYID_REGEX", "TEXT_REGEX", "LINE_ENDING_REGEX", "SEARCH_FOR_ENTITY_NAME_REGEX", "FETCH_XML_TOP_REGEX", "FETCH_XML_PAGE_REGEX", "FETCH_XML_REPLACE_REGEX", "DATE_FORMAT_REGEX", "init_Regex", "__esmMin", "formatParameterValue", "value", "isUuid", "processParameters", "parameters", "parameterNames", "functionParams", "urlQuery", "parameterName", "index", "paramIndex", "extractUuid", "hasHeader", "headers", "name", "getHeader", "buildFunctionParameters", "getFetchXmlPagingCookie", "pageCookies", "currentPageNumber", "result", "parsePagingCookie", "isNull", "generateUUID", "getCrypto", "getXrmContext", "getClientUrl", "clientUrl", "isRunningWithinPortals", "isObject", "obj", "copyObject", "src", "excludeProps", "target", "prop", "copyRequest", "setFileChunk", "request", "fileBuffer", "chunkSize", "offset", "count", "content", "i", "convertToFileBuffer", "binaryString", "bytes", "toAbsoluteUrl", "client", "removeLeadingSlash", "downloadChunkSize", "init_Utility", "__esmMin", "init_Crypto", "init_Regex", "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", "DATE_FORMAT_REGEX", "init_dateReviver", "__esmMin", "init_Regex", "parseBatchHeaders", "text", "ctx", "headers", "parts", "line", "pos", "readLine", "BATCH_RESPONSE_HEADERS_REGEX", "readTo", "LINE_ENDING_REGEX", "searchRegTerm", "start", "slicedText", "match", "end", "getHttpStatus", "response", "HTTP_STATUS_REGEX", "getPlainContent", "textReg", "TEXT_REGEX", "handlePlainContent", "batchResponse", "parseParams", "requestNumber", "plainContent", "handlePlainResponse", "handleEmptyContent", "entityUrl", "ODATA_ENTITYID_REGEX", "extractUuidFromUrl", "processBatchPart", "httpStatusString", "httpStatus", "httpStatusMessage", "responseData", "CONTENT_TYPE_PLAIN_REGEX", "parsedResponse", "handleJsonResponse", "responseHeaders", "ErrorHelper", "parseBatchResponse", "delimiter", "batchResponseParts", "result", "part", "batchToProcess", "init_parseBatchResponse", "__esmMin", "init_ErrorHelper", "init_Regex", "init_parseResponse", "getFormattedKeyValue", "keyName", "value", "newKey", "format", "DWA", "parseData", "object", "parseParams", "convertToReferenceObject", "currentKey", "j", "formattedKeyValue", "aliasKeys", "getFetchXmlPagingCookie", "base64ToString", "base64", "parseFileResponse", "response", "responseHeaders", "data", "parseResult", "location", "getHeader", "isBatchResponse", "isFileResponse", "hasHeader", "isJsonResponse", "handleBatchResponse", "batch", "parseBatchResponse", "handleFileResponse", "handleJsonResponse", "requestNumber", "dateReviver", "handlePlainResponse", "numberResponse", "handleEmptyResponse", "entityUrl", "extractUuidFromUrl", "result", "parseResponse", "init_parseResponse", "__esmMin", "init_dwa", "init_Utility", "init_dateReviver", "init_Regex", "init_parseBatchResponse", "parseResponseHeaders", "headerStr", "headers", "headerPairs", "i", "ilen", "headerPair", "index", "init_parseResponseHeaders", "__esmMin", "xhr_exports", "__export", "XhrWrapper", "executeRequest", "options", "resolve", "reject", "_executeRequest", "successCallback", "errorCallback", "data", "headers", "responseParams", "signal", "ErrorHelper", "request", "key", "abort", "responseHeaders", "parseResponseHeaders", "response", "parseResponse", "error", "errorParsed", "errorParameters", "init_xhr", "__esmMin", "init_ErrorHelper", "init_parseResponse", "init_parseResponseHeaders", "dynamics_web_api_exports", "__export", "DynamicsWebApi", "init_Utility", "init_ErrorHelper", "LIBRARY_NAME", "FUNCTION_NAME", "LIBRARY_NAME", "apiConfigs", "getApiUrl", "serverUrl", "apiConfig", "isRunningWithinPortals", "getClientUrl", "url", "mergeSearchApiOptions", "internalApiConfig", "options", "ErrorHelper", "mergeApiConfig", "internalConfig", "apiType", "config", "mergeConfig", "defaultConfig", "init_Utility", "init_Utility", "entityNames", "setEntityNames", "newEntityNames", "findCollectionName", "entityName", "isNull", "collectionName", "key", "executeRequest", "options", "init_ErrorHelper", "init_ErrorHelper", "init_Regex", "init_Utility", "composeUrl", "request", "config", "url", "joinSymbol", "queryArray", "ErrorHelper", "navigationKey", "filterResult", "safelyRemoveCurlyBracketsFromUrl", "isNull", "expandQueryArray", "property", "expand", "expandRequest", "expandConverted", "init_ErrorHelper", "init_ErrorHelper", "init_Regex", "composePreferHeader", "request", "config", "functionName", "options", "prefer", "ErrorHelper", "preferArray", "item", "trimmedItem", "extractPreferCallbackUrl", "removeDoubleQuotes", "key", "optionFactory", "preferOptionsFactory", "value", "url", "annotations", "size", "composeHeaders", "request", "config", "headers", "prefer", "composePreferHeader", "ErrorHelper", "init_ErrorHelper", "composeRequest", "request", "config", "ErrorHelper", "composeUrl", "composeHeaders", "init_Regex", "init_Utility", "init_dateReviver", "init_parseBatchResponse", "init_parseResponse", "init_parseResponseHeaders", "processData", "data", "config", "replaceEntityNameWithCollectionName", "value", "valueParts", "SEARCH_FOR_ENTITY_NAME_REGEX", "collectionName", "findCollectionName", "isNull", "addFullWebApiUrl", "key", "removeLeadingSlash", "stringifiedData", "removeCurlyBracketsFromUuid", "escapeUnicodeSymbols", "setStandardHeaders", "headers", "data", "init_Utility", "convertToBatch", "requests", "config", "batchRequest", "batchBoundary", "generateUUID", "batchBody", "currentChangeSet", "contentId", "addHeaders", "headers", "key", "internalRequest", "inChangeSet", "contentIdValue", "processData", "setStandardHeaders", "_addResponseParams", "requestId", "responseParams", "_responseParseParams", "_addRequestToBatchCollection", "request", "_batchRequestCollection", "_clearRequestData", "_runRequest", "config", "result", "sendRequest", "error", "_nameExceptions", "_isEntityNameException", "entityName", "_getCollectionNames", "isNull", "entityNames", "findCollectionName", "composeRequest", "setEntityNames", "i", "_checkCollectionName", "generateUUID", "processedData", "isBatchConverted", "batchRequest", "ErrorHelper", "batchResult", "convertToBatch", "processData", "setStandardHeaders", "token", "isRunningWithinPortals", "url", "executeRequest", "makeRequest", "collectionName", "getCollectionName", "entityName", "findCollectionName", "_config", "_isBatch", "_batchRequestId", "DataverseClient", "config", "__privateAdd", "defaultConfig", "mergeConfig", "__privateGet", "request", "makeRequest", "value", "__privateSet", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "associate", "request", "client", "ErrorHelper", "relatedKey", "odataId", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "associateSingleValued", "request", "client", "ErrorHelper", "relatedKey", "odataId", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "callAction", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "callFunction", "request", "client", "ErrorHelper", "getFunctionName", "isObject", "functionName", "parameterName", "internalRequest", "copyObject", "functionParameters", "buildFunctionParameters", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "create", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "count", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "init_ErrorHelper", "init_ErrorHelper", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveMultiple", "request", "client", "nextPageLink", "ErrorHelper", "internalRequest", "copyRequest", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveAllRequest", "request", "client", "nextPageLink", "records", "response", "retrieveMultiple", "pageLink", "result", "retrieveAll", "ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "countAll", "request", "client", "ErrorHelper", "retrieveAllRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "disassociate", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "primaryKey", "relatedKey", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "disassociateSingleValued", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "primaryKey", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieve", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Regex", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "fetchXml", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "FETCH_XML_TOP_REGEX", "replacementString", "FETCH_XML_PAGE_REGEX", "FETCH_XML_REPLACE_REGEX", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "executeFetchXmlAll", "request", "client", "records", "response", "fetchXml", "fetchXmlAll", "ErrorHelper", "init_ErrorHelper", "init_Regex", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "update", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "getUpdateMethod", "ifmatch", "error", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "updateSingleProperty", "request", "client", "ErrorHelper", "field", "fieldValue", "internalRequest", "copyRequest", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "upsert", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "ifnonematch", "ifmatch", "error", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "deleteRecord", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "ifmatch", "error", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "_uploadFileChunk", "request", "client", "fileBytes", "chunkSize", "offset", "setFileChunk", "uploadFile", "ErrorHelper", "internalRequest", "copyRequest", "response", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "downloadFileChunk", "request", "client", "bytesDownloaded", "data", "downloadChunkSize", "response", "convertToFileBuffer", "downloadFile", "ErrorHelper", "internalRequest", "copyRequest", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "executeBatch", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "startBatch", "generateUUID", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "createEntity", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "create", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "updateEntity", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "update", "init_ErrorHelper", "init_Utility", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveEntity", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieve", "init_Utility", "FUNCTION_NAME", "retrieveEntities", "client", "request", "internalRequest", "copyRequest", "retrieveMultiple", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "createAttribute", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "create", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "updateAttribute", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "update", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveAttributes", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieveMultiple", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "retrieveAttribute", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieve", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "createRelationship", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "create", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "updateRelationship", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "update", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "deleteRelationship", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "deleteRecord", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveRelationships", "request", "client", "internalRequest", "copyRequest", "ErrorHelper", "retrieveMultiple", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveRelationship", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieve", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "createGlobalOptionSet", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "create", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "updateGlobalOptionSet", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "update", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "deleteGlobalOptionSet", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "deleteRecord", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveGlobalOptionSet", "request", "client", "ErrorHelper", "internalRequest", "copyRequest", "retrieve", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveGlobalOptionSets", "request", "client", "internalRequest", "copyRequest", "ErrorHelper", "retrieveMultiple", "init_Utility", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "retrieveCsdlMetadata", "request", "client", "internalRequest", "copyRequest", "ErrorHelper", "init_Utility", "init_ErrorHelper", "init_Regex", "convertSearchQuery", "query", "functionName", "config", "escapeSearchSpecialCharacters", "convertEntitiesProperty", "convertQuery", "convertSuggestOrAutocompleteQuery", "entities", "version", "toStringArray", "entity", "toSearchEntity", "toReturn", "searchOptionsReviver", "prop", "specialProperties", "convertOptionKeysToLowerCase", "options", "newOptions", "key", "value", "parseQueryResponse", "queryResponse", "config", "toV1", "responseValue", "dateReviver", "toReturn", "toV2", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "query", "request", "client", "ErrorHelper", "_isObject", "parameterName", "internalRequest", "copyObject", "convertSearchQuery", "response", "parseQueryResponse", "init_Utility", "init_ErrorHelper", "parseSuggestResponse", "queryResponse", "config", "toV1", "responseValue", "dateReviver", "item", "toReturn", "toV2", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "suggest", "request", "client", "ErrorHelper", "_isObject", "parameterName", "internalRequest", "copyObject", "convertSearchQuery", "response", "parseSuggestResponse", "init_Utility", "init_ErrorHelper", "parseAutocompleteResponse", "queryResponse", "config", "toV1", "responseValue", "dateReviver", "toReturn", "toV2", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "autocomplete", "request", "client", "ErrorHelper", "_isObject", "parameterName", "internalRequest", "copyObject", "convertSearchQuery", "response", "parseAutocompleteResponse", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "getBackgroundOperationStatus", "backgroundOperationId", "client", "ErrorHelper", "internalRequest", "init_ErrorHelper", "FUNCTION_NAME", "REQUEST_NAME", "LIBRARY_NAME", "cancelBackgroundOperation", "backgroundOperationId", "client", "ErrorHelper", "internalRequest", "init_Utility", "_client", "_DynamicsWebApi", "config", "__privateAdd", "__privateGet", "request", "create", "retrieve", "update", "updateSingleProperty", "deleteRecord", "upsert", "uploadFile", "downloadFile", "nextPageLink", "retrieveMultiple", "retrieveAll", "count", "countAll", "fetchXml", "fetchXmlAll", "associate", "disassociate", "associateSingleValued", "disassociateSingleValued", "callFunction", "callAction", "createEntity", "updateEntity", "retrieveEntity", "retrieveEntities", "createAttribute", "updateAttribute", "retrieveAttributes", "retrieveAttribute", "createRelationship", "updateRelationship", "deleteRelationship", "retrieveRelationships", "retrieveRelationship", "createGlobalOptionSet", "updateGlobalOptionSet", "deleteGlobalOptionSet", "retrieveGlobalOptionSet", "retrieveGlobalOptionSets", "retrieveCsdlMetadata", "query", "suggest", "autocomplete", "backgroundOperationId", "getBackgroundOperationStatus", "cancelBackgroundOperation", "startBatch", "executeBatch", "entityName", "getCollectionName", "value", "toAbsoluteUrl", "__privateSet", "DataverseClient", "DynamicsWebApi"] } diff --git a/dist/esm/dynamics-web-api.mjs b/dist/esm/dynamics-web-api.mjs index 00b6445..8f6e123 100644 --- a/dist/esm/dynamics-web-api.mjs +++ b/dist/esm/dynamics-web-api.mjs @@ -1,4 +1,4 @@ -/*! dynamics-web-api v2.3.2 (c) 2025 Aleksandr Rogov. License: MIT */ +/*! dynamics-web-api v2.4.0 (c) 2025 Aleksandr Rogov. License: MIT */ var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; @@ -100,7 +100,7 @@ function sanitizeCookie(cookie) { return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]); } function removeLeadingSlash(value) { - return value.replace(LEADING_SLASH_REGEX, ""); + return value.startsWith("/") ? value.slice(1) : value; } function escapeUnicodeSymbols(value) { return value.replace(UNICODE_SYMBOLS_REGEX, (chr) => `\\u${("0000" + chr.charCodeAt(0).toString(16)).slice(-4)}`); @@ -118,7 +118,7 @@ function extractPreferCallbackUrl(value) { const match = PREFER_CALLBACK_URL_REGEX.exec(value); return match ? match[1] : null; } -var UUID, UUID_REGEX, EXTRACT_UUID_REGEX, EXTRACT_UUID_FROM_URL_REGEX, REMOVE_BRACKETS_FROM_UUID_REGEX, ENTITY_UUID_REGEX, QUOTATION_MARK_REGEX, PAGING_COOKIE_REGEX, SPECIAL_CHARACTER_REGEX, LEADING_SLASH_REGEX, UNICODE_SYMBOLS_REGEX, DOUBLE_QUOTE_REGEX, BATCH_RESPONSE_HEADERS_REGEX, HTTP_STATUS_REGEX, CONTENT_TYPE_PLAIN_REGEX, ODATA_ENTITYID_REGEX, TEXT_REGEX, LINE_ENDING_REGEX, SEARCH_FOR_ENTITY_NAME_REGEX, SPECIAL_COLLECTION_FOR_UPDATE_REGEX, FETCH_XML_TOP_REGEX, FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, DATE_FORMAT_REGEX, SEARCH_SPECIAL_CHARACTERS_REGEX, PREFER_CALLBACK_URL_REGEX; +var UUID, UUID_REGEX, EXTRACT_UUID_REGEX, EXTRACT_UUID_FROM_URL_REGEX, REMOVE_BRACKETS_FROM_UUID_REGEX, ENTITY_UUID_REGEX, QUOTATION_MARK_REGEX, PAGING_COOKIE_REGEX, SPECIAL_CHARACTER_REGEX, UNICODE_SYMBOLS_REGEX, DOUBLE_QUOTE_REGEX, BATCH_RESPONSE_HEADERS_REGEX, HTTP_STATUS_REGEX, CONTENT_TYPE_PLAIN_REGEX, ODATA_ENTITYID_REGEX, TEXT_REGEX, LINE_ENDING_REGEX, SEARCH_FOR_ENTITY_NAME_REGEX, SPECIAL_COLLECTION_FOR_UPDATE_REGEX, FETCH_XML_TOP_REGEX, FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, DATE_FORMAT_REGEX, SEARCH_SPECIAL_CHARACTERS_REGEX, PREFER_CALLBACK_URL_REGEX; var init_Regex = __esm({ "src/helpers/Regex.ts"() { "use strict"; @@ -131,7 +131,6 @@ var init_Regex = __esm({ QUOTATION_MARK_REGEX = /(["'].*?["'])/; PAGING_COOKIE_REGEX = /pagingcookie="()/; SPECIAL_CHARACTER_REGEX = /[<>"']/g; - LEADING_SLASH_REGEX = /^\//; UNICODE_SYMBOLS_REGEX = /[\u007F-\uFFFF]/g; DOUBLE_QUOTE_REGEX = /"/g; BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/; @@ -277,6 +276,9 @@ function convertToFileBuffer(binaryString) { } return bytes; } +function toAbsoluteUrl(client, value) { + return `${client.config.dataApi.url}${removeLeadingSlash(value)}`; +} var downloadChunkSize; var init_Utility = __esm({ "src/utils/Utility.ts"() { @@ -1412,13 +1414,15 @@ var processData = (data, config) => { return value; }; const stringifiedData = JSON.stringify(data, (key, value) => { - if (key.endsWith("@odata.bind") || key.endsWith("@odata.id")) { + if (key === "@odata.id" || key.endsWith("@odata.bind")) { if (typeof value === "string" && !value.startsWith("$")) { value = removeCurlyBracketsFromUuid(value); if (config.useEntityNames) { value = replaceEntityNameWithCollectionName(value); } - value = addFullWebApiUrl(key, value); + if (key !== "@odata.id") { + value = addFullWebApiUrl(key, value); + } } } else if (key.startsWith("oData") || key.endsWith("_Formatted") || key.endsWith("_NavigationProperty") || key.endsWith("_LogicalName")) { return void 0; @@ -1718,7 +1722,7 @@ var associate = async (request, client) => { if (!client.isBatch || client.isBatch && !request.relatedKey.startsWith("$")) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); internalRequest.method = "POST"; @@ -1743,7 +1747,7 @@ var associateSingleValued = async (request, client) => { if (!client.isBatch || client.isBatch && !request.relatedKey.startsWith("$")) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME2, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME2, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); internalRequest.method = "PUT"; @@ -2893,6 +2897,7 @@ async function cancelBackgroundOperation(backgroundOperationId, client) { } // src/dynamics-web-api.ts +init_Utility(); var _client; var _DynamicsWebApi = class _DynamicsWebApi { /** @@ -3301,7 +3306,13 @@ var _DynamicsWebApi = class _DynamicsWebApi { * @param {string} entityName entity name * @returns {string | null} collection name */ - getCollectionName: (entityName) => getCollectionName(entityName) + getCollectionName: (entityName) => getCollectionName(entityName), + /** + * Adds an absolute Web API URL to the beginning of a provided value. + * @param value The value to modify. + * @returns The absolute URL. + */ + toAbsoluteUrl: (value) => toAbsoluteUrl(__privateGet(this, _client), value) }; __privateSet(this, _client, new DataverseClient(config)); } diff --git a/dist/esm/dynamics-web-api.mjs.map b/dist/esm/dynamics-web-api.mjs.map index eb15f59..13400b8 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/parseBatchResponse.ts", "../../src/client/helpers/parseResponse.ts", "../../src/client/http.ts", "../../src/utils/Config.ts", "../../src/requests/constants.ts", "../../src/client/RequestClient.ts", "../../src/client/helpers/entityNameMapper.ts", "../../src/client/helpers/executeRequest.ts", "../../src/client/request/composers/url.ts", "../../src/client/request/composers/headers.ts", "../../src/client/request/composers/preferHeader.ts", "../../src/client/request/composers/request.ts", "../../src/client/request/processData.ts", "../../src/client/helpers/index.ts", "../../src/client/request/setStandardHeaders.ts", "../../src/client/request/convertToBatch.ts", "../../src/client/dataverse.ts", "../../src/requests/associate.ts", "../../src/requests/associateSingleValued.ts", "../../src/requests/callAction.ts", "../../src/requests/callFunction.ts", "../../src/requests/create.ts", "../../src/requests/count.ts", "../../src/requests/countAll.ts", "../../src/requests/retrieveAll.ts", "../../src/requests/retrieveMultiple.ts", "../../src/requests/disassociate.ts", "../../src/requests/disassociateSingleValued.ts", "../../src/requests/retrieve.ts", "../../src/requests/fetchXml.ts", "../../src/requests/fetchXmlAll.ts", "../../src/requests/update.ts", "../../src/requests/updateSingleProperty.ts", "../../src/requests/upsert.ts", "../../src/requests/delete.ts", "../../src/requests/uploadFile.ts", "../../src/requests/downloadFile.ts", "../../src/requests/executeBatch.ts", "../../src/requests/metadata/createEntity.ts", "../../src/requests/metadata/updateEntity.ts", "../../src/requests/metadata/retrieveEntity.ts", "../../src/requests/metadata/retrieveEntities.ts", "../../src/requests/metadata/createAttribute.ts", "../../src/requests/metadata/updateAttribute.ts", "../../src/requests/metadata/retrieveAttributes.ts", "../../src/requests/metadata/retrieveAttribute.ts", "../../src/requests/metadata/createRelationship.ts", "../../src/requests/metadata/updateRelationship.ts", "../../src/requests/metadata/deleteRelationship.ts", "../../src/requests/metadata/retrieveRelationships.ts", "../../src/requests/metadata/retrieveRelationship.ts", "../../src/requests/metadata/createGlobalOptionSet.ts", "../../src/requests/metadata/updateGlobalOptionSet.ts", "../../src/requests/metadata/deleteGlobalOptionSet.ts", "../../src/requests/metadata/retrieveGlobalOptionSet.ts", "../../src/requests/metadata/retrieveGlobalOptionSets.ts", "../../src/requests/metadata/retrieveCsdlMetadata.ts", "../../src/requests/search/query.ts", "../../src/requests/search/convertSearchQuery.ts", "../../src/requests/search/responseParsers/parseQueryResponse.ts", "../../src/requests/search/suggest.ts", "../../src/requests/search/responseParsers/parseSuggestResponse.ts", "../../src/requests/search/autocomplete.ts", "../../src/requests/search/responseParsers/parseAutocompleteResponse.ts", "../../src/requests/backgroundOperation/getStatus.ts", "../../src/requests/backgroundOperation/cancel.ts", "../../src/dynamics-web-api.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 as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nconst LEADING_SLASH_REGEX = /^\\//;\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.replace(LEADING_SLASH_REGEX, \"\");\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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", "\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\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 type * as 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 headers = options.headers;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n const httpHeaders: http.OutgoingHttpHeaders = {};\r\n\r\n if (data) {\r\n httpHeaders[\"Content-Type\"] = headers[\"Content-Type\"];\r\n httpHeaders[\"Content-Length\"] = data.length;\r\n\r\n delete headers[\"Content-Type\"];\r\n }\r\n\r\n //set additional headers\r\n for (let key in headers) {\r\n httpHeaders[key] = headers[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: httpHeaders,\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) httpHeaders.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 if (res.statusCode && ((res.statusCode >= 200 && res.statusCode < 300) || res.statusCode === 304)) {\r\n // Success with Not Modified\r\n let responseData = parseResponse(rawData, res.headers as Record, 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 } else {\r\n // All other statuses are error cases.\r\n let crmError;\r\n try {\r\n var errorParsed = parseResponse(rawData, res.headers as Record, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n return;\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 }\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 { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const 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 value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "\uFEFFimport { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\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,QAAsB,OAAO,OAAO,SAAe,0CAAyB,UAAU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AOzC;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAuB,OAAO,YAAqE,MAAM,SAAS,mBAAK,QAAO;AAO9H;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B,OAA6B,YAC1C,QAAQ,SAAS,mBAAK,QAAO;AAO3C;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqC,OAAO,YAC9B,aAAa,SAAS,mBAAK,QAAO;AAOhD;AAAA;AAAA;AAAA;AAAA;AAAA,wCAA+B,OAAO,0BACxB,6BAA6B,uBAAuB,mBAAK,QAAO;AAO9E;AAAA;AAAA;AAAA;AAAA;AAAA,qCAA4B,OAAO,0BACrB,0BAA0B,uBAAuB,mBAAK,QAAO;AAK3E;AAAA;AAAA;AAAA,sBAAa,MAAsB,WAAW,mBAAK,QAAO;AAO1D;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe,OAAO,YAAqD,aAAa,SAAS,mBAAK,QAAO;AAQ7G;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,mBAAK,SAAQ,MAAM;AAE1G,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,kBAAkB,UAAU;AAAA,IAC1F;AAldI,uBAAK,SAAU,IAAI,gBAAgB,MAAM;AAAA,EAC7C;AAkdJ;AA1dI;AADG,IAAM,iBAAN;", + "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 as T) : require(\"./crypto/node\").getCrypto();\r\n}\r\n", "import type { ReferenceObject } from \"../types\";\r\n\r\nconst UUID = \"[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\";\r\n\r\nexport const UUID_REGEX = new RegExp(UUID, \"i\");\r\nexport const EXTRACT_UUID_REGEX = new RegExp(\"^{?(\" + UUID + \")}?$\", \"i\");\r\nexport const EXTRACT_UUID_FROM_URL_REGEX = new RegExp(\"(\" + UUID + \")\\\\)$\", \"i\");\r\n//global here is fine because the state is reset inside string.replace function\r\nexport const REMOVE_BRACKETS_FROM_UUID_REGEX = new RegExp(`{(${UUID})}`, \"g\");\r\nexport const ENTITY_UUID_REGEX = new RegExp(`\\\\/(\\\\w+)\\\\((${UUID})`, \"i\");\r\n\r\nexport function isUuid(value: string): boolean {\r\n const match = UUID_REGEX.exec(value);\r\n return !!match;\r\n}\r\n\r\nexport function extractUuid(value: string): string | null {\r\n const match = EXTRACT_UUID_REGEX.exec(value);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function extractUuidFromUrl(url?: string): string | null {\r\n if (!url) return null;\r\n const match = EXTRACT_UUID_FROM_URL_REGEX.exec(url);\r\n return match ? match[1] : null;\r\n}\r\n\r\nexport function removeCurlyBracketsFromUuid(value: string): string {\r\n return value.replace(REMOVE_BRACKETS_FROM_UUID_REGEX, (_match, p1) => p1);\r\n}\r\n\r\nconst QUOTATION_MARK_REGEX = /([\"'].*?[\"'])/;\r\n\r\n/**\r\n * Safely removes curly brackets from guids in a URL\r\n * @param url URL to remove curly brackets from\r\n * @returns URL with guid without curly brackets\r\n */\r\nexport function safelyRemoveCurlyBracketsFromUrl(url: string): string {\r\n //todo: in future I will need to replace this with a negative lookbehind and lookahead\r\n\r\n // Split the filter string by quotation marks\r\n const parts = url.split(QUOTATION_MARK_REGEX);\r\n return parts\r\n .map((part, index) => {\r\n // Only process parts that are not within quotes\r\n if (index % 2 === 0) {\r\n return removeCurlyBracketsFromUuid(part);\r\n }\r\n return part;\r\n })\r\n .join(\"\");\r\n}\r\n\r\n/**\r\n * Converts a response to a reference object\r\n * @param {Object} responseData - Response object\r\n * @returns {ReferenceObject}\r\n */\r\nexport function convertToReferenceObject(responseData: Record): ReferenceObject {\r\n const result = ENTITY_UUID_REGEX.exec(responseData[\"@odata.id\"]);\r\n return { id: result![2], collection: result![1], oDataContext: responseData[\"@odata.context\"] };\r\n}\r\n\r\nexport const PAGING_COOKIE_REGEX = /pagingcookie=\"()/;\r\nexport const SPECIAL_CHARACTER_REGEX = /[<>\"']/g;\r\n\r\n/**\r\n * Parses a paging cookie\r\n * @param pagingCookie Paging cookie to parse\r\n * @returns\r\n */\r\nexport function parsePagingCookie(pagingCookie: string) {\r\n const info = PAGING_COOKIE_REGEX.exec(pagingCookie);\r\n\r\n if (!info) return null;\r\n\r\n const page = parseInt(info[2], 10);\r\n const sanitizedCookie = sanitizeCookie(info[1]);\r\n\r\n return { page, sanitizedCookie };\r\n}\r\n\r\n/**\r\n * Sanitizes a cookie\r\n * @param cookie Cookie to sanitize\r\n * @returns\r\n */\r\nfunction sanitizeCookie(cookie: string): string {\r\n const characterMap: { [key: string]: string } = {\r\n \"<\": \"<\",\r\n \">\": \">\",\r\n '\"': \""\",\r\n \"'\": \"'\", // Use numeric reference for single quote to avoid confusion\r\n };\r\n\r\n return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]);\r\n}\r\n\r\nexport function removeLeadingSlash(value: string): string {\r\n return value.startsWith(\"/\") ? value.slice(1) : value;\r\n}\r\n\r\nconst UNICODE_SYMBOLS_REGEX = /[\\u007F-\\uFFFF]/g;\r\nexport function escapeUnicodeSymbols(value: string): string {\r\n return value.replace(UNICODE_SYMBOLS_REGEX, (chr: string) => `\\\\u${(\"0000\" + chr.charCodeAt(0).toString(16)).slice(-4)}`);\r\n}\r\n\r\nconst DOUBLE_QUOTE_REGEX = /\"/g;\r\nexport function removeDoubleQuotes(value: string): string {\r\n return value.replace(DOUBLE_QUOTE_REGEX, \"\");\r\n}\r\n\r\nexport const BATCH_RESPONSE_HEADERS_REGEX = /^([^()<>@,;:\\\\\"\\/[\\]?={} \\t]+)\\s?:\\s?(.*)/;\r\nexport const HTTP_STATUS_REGEX = /HTTP\\/?\\s*[\\d.]*\\s+(\\d{3})\\s+([\\w\\s]*)$/m;\r\nexport const CONTENT_TYPE_PLAIN_REGEX = /Content-Type: text\\/plain/i;\r\nexport const ODATA_ENTITYID_REGEX = /OData-EntityId.+/i;\r\nexport const TEXT_REGEX = /\\w+$/g;\r\nexport const LINE_ENDING_REGEX = /\\r?\\n/;\r\nexport const SEARCH_FOR_ENTITY_NAME_REGEX = /(\\w+)(\\([\\d\\w-]+\\))$/;\r\nexport const SPECIAL_COLLECTION_FOR_UPDATE_REGEX = /EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;\r\n\r\n/**Metadata definitions cannot be updated using \"PATCH\" method */\r\nexport function getUpdateMethod(collection: string | undefined | null){\r\n return SPECIAL_COLLECTION_FOR_UPDATE_REGEX.test(collection ?? \"\") ? \"PUT\" : \"PATCH\";\r\n}\r\n\r\nexport const FETCH_XML_TOP_REGEX = /^ {\r\n let value = parameters[parameterName];\r\n if (value == null) return;\r\n\r\n value = formatParameterValue(value);\r\n\r\n const paramIndex = index + 1;\r\n functionParams.push(`${parameterName}=@p${paramIndex}`);\r\n urlQuery.push(`@p${paramIndex}=${extractUuid(value) || value}`);\r\n });\r\n\r\n return {\r\n key: `(${functionParams.join(\",\")})`,\r\n queryParams: urlQuery,\r\n };\r\n}\r\n\r\nexport function hasHeader(headers: Record, name: string): boolean {\r\n return headers.hasOwnProperty(name) || headers.hasOwnProperty(name.toLowerCase());\r\n}\r\n\r\nexport function getHeader(headers: Record, name: string): string | undefined {\r\n if (headers[name]) return headers[name];\r\n\r\n return headers[name.toLowerCase()];\r\n}\r\n\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\nexport function buildFunctionParameters(parameters?: any): Core.FunctionParameters {\r\n return parameters ? processParameters(parameters) : { key: \"()\" };\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\nexport function 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 result = parsePagingCookie(pageCookies);\r\n\r\n // http://stackoverflow.com/questions/41262772/execution-of-fetch-xml-using-web-api-dynamics-365 workaround\r\n return {\r\n cookie: result?.sanitizedCookie || \"\",\r\n page: result?.page || currentPageNumber,\r\n nextPage: result?.page ? result.page + 1 : currentPageNumber + 1,\r\n };\r\n}\r\n\r\n// static isNodeEnv = isNodeEnv;\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\nexport function isNull(value: any): value is undefined | null {\r\n return typeof value === \"undefined\" || value == null;\r\n}\r\n\r\n/** Generates UUID */\r\nexport function generateUUID() {\r\n return getCrypto().randomUUID();\r\n}\r\n\r\nexport function 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 (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {\r\n return Xrm.Utility.getGlobalContext();\r\n } else if (!isNull(Xrm.Page) && !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\nexport function getClientUrl(): string {\r\n const context = 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\nexport function isRunningWithinPortals(): boolean {\r\n return global.DWA_BROWSER ? !!global.window.shell : false;\r\n}\r\n\r\nexport function 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\nexport function 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 (isObject(src[prop])) {\r\n target[prop] = 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\nexport function 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 = copyObject(src, excludeProps);\r\n result.signal = src.signal;\r\n\r\n return result;\r\n}\r\n\r\nexport function 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\nexport function 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\nexport function toAbsoluteUrl(client: IDataverseClient, value: string): string {\r\n return `${client.config.dataApi.url}${removeLeadingSlash(value)}`;\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 statusText: string;\r\n statusMessage: string;\r\n headers: Record;\r\n stack?: string;\r\n}\r\n\r\nfunction throwParameterError(functionName: string, parameterName: string, type: string | null | undefined): never {\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 {\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", "\uFEFFimport { DATE_FORMAT_REGEX } from \"../../helpers/Regex\";\r\n\r\nexport function dateReviver(key: string, value: any): Date {\r\n if (typeof value === \"string\") {\r\n const a = DATE_FORMAT_REGEX.exec(value);\r\n if (a) {\r\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));\r\n }\r\n }\r\n return value;\r\n}\r\n", "import { DynamicsWebApiError, ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport {\r\n BATCH_RESPONSE_HEADERS_REGEX,\r\n LINE_ENDING_REGEX,\r\n HTTP_STATUS_REGEX,\r\n TEXT_REGEX,\r\n CONTENT_TYPE_PLAIN_REGEX,\r\n ODATA_ENTITYID_REGEX,\r\n extractUuidFromUrl,\r\n} from \"../../helpers/Regex\";\r\nimport { handleJsonResponse, handlePlainResponse } from \"./parseResponse\";\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: Record = {};\r\n let parts: RegExpExecArray | null;\r\n let line: string | null;\r\n let pos: number;\r\n\r\n do {\r\n pos = ctx.position;\r\n line = readLine(text, ctx);\r\n if (!line) break; //if the line is empty, then it is the end of the headers\r\n parts = BATCH_RESPONSE_HEADERS_REGEX.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, LINE_ENDING_REGEX);\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 }, searchRegTerm: RegExp): string | null {\r\n const start = ctx.position || 0;\r\n const slicedText = text.slice(start);\r\n const match = searchRegTerm.exec(slicedText);\r\n if (!match) {\r\n return null;\r\n }\r\n const end = start + match.index;\r\n ctx.position = end + match[0].length;\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\nfunction getHttpStatus(response: string) {\r\n const parts = HTTP_STATUS_REGEX.exec(response);\r\n //todo: add error handler for httpStatus and httpStatusMessage; remove \"!\" operator\r\n return { httpStatusString: parts![0], httpStatus: parseInt(parts![1]), httpStatusMessage: parts![2].trim() };\r\n}\r\n\r\nfunction getPlainContent(response: string) {\r\n // Reset the lastIndex property to ensure correct matching\r\n HTTP_STATUS_REGEX.lastIndex = 0;\r\n\r\n const textReg = TEXT_REGEX.exec(response.trim());\r\n return textReg?.length ? textReg[0] : undefined;\r\n}\r\n\r\nfunction handlePlainContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const plainContent = getPlainContent(batchResponse);\r\n return handlePlainResponse(plainContent);\r\n}\r\n\r\nfunction handleEmptyContent(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n if (parseParams?.[requestNumber]?.valueIfEmpty !== undefined) {\r\n return parseParams[requestNumber].valueIfEmpty;\r\n } else {\r\n const entityUrl = ODATA_ENTITYID_REGEX.exec(batchResponse);\r\n return extractUuidFromUrl(entityUrl?.[0]) ?? undefined;\r\n }\r\n}\r\n\r\nfunction processBatchPart(batchResponse: string, parseParams: any, requestNumber: number): any {\r\n const { httpStatusString, httpStatus, httpStatusMessage } = getHttpStatus(batchResponse);\r\n const responseData = batchResponse.substring(batchResponse.indexOf(\"{\"), batchResponse.lastIndexOf(\"}\") + 1);\r\n\r\n //if the batch part does not contain a json response, parse it as plain or empty content\r\n if (!responseData) {\r\n if (CONTENT_TYPE_PLAIN_REGEX.test(batchResponse)) {\r\n return handlePlainContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n return handleEmptyContent(batchResponse, parseParams, requestNumber);\r\n }\r\n\r\n //parse json data\r\n const parsedResponse = handleJsonResponse(responseData, parseParams, requestNumber);\r\n\r\n if (httpStatus < 400) {\r\n return parsedResponse;\r\n }\r\n\r\n //handle error\r\n const responseHeaders = parseBatchHeaders(\r\n batchResponse.substring(batchResponse.indexOf(httpStatusString) + httpStatusString.length + 1, batchResponse.indexOf(\"{\"))\r\n );\r\n\r\n return 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\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\nexport function 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.substring(0, response.search(LINE_ENDING_REGEX));\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 part of batchResponseParts) {\r\n if (part.indexOf(\"--changesetresponse_\") === -1) {\r\n result.push(processBatchPart(part, parseParams, requestNumber++));\r\n continue;\r\n }\r\n\r\n part = part.trim();\r\n const batchToProcess = part.substring(part.search(LINE_ENDING_REGEX) + 1).trim();\r\n result = result.concat(parseBatchResponse(batchToProcess, parseParams, requestNumber++));\r\n }\r\n\r\n return result;\r\n}\r\n", "\uFEFFimport { DWA } from \"../../dwa\";\r\nimport { getHeader, hasHeader, getFetchXmlPagingCookie } from \"../../utils/Utility\";\r\nimport { dateReviver } from \"./dateReviver\";\r\nimport type * as Core from \"../../types\";\r\nimport { convertToReferenceObject, extractUuidFromUrl } from \"../../helpers/Regex\";\r\nimport { parseBatchResponse } from \"./parseBatchResponse\";\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 object - parsed JSON object\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed batch response\r\n */\r\nexport function parseData(object: Record, parseParams?: any): any {\r\n if (parseParams) {\r\n if (parseParams.isRef && object[\"@odata.id\"] != null) {\r\n return 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 for (const currentKey in object) {\r\n if (object[currentKey] != null) {\r\n if (Array.isArray(object[currentKey])) {\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 = getFetchXmlPagingCookie(object[\"@\" + DWA.Prefer.Annotations.FetchXmlPagingCookie], parseParams.pageNumber);\r\n }\r\n }\r\n\r\n return object;\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: string, 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 const 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 if (responseHeaders[\"x-ms-file-size\"]) parseResult.fileSize = parseInt(responseHeaders[\"x-ms-file-size\"]);\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) parseResult.location = location;\r\n\r\n return parseResult;\r\n}\r\n\r\nfunction isBatchResponse(response: string): boolean {\r\n return response.indexOf(\"--batchresponse_\") > -1;\r\n}\r\n\r\nfunction isFileResponse(responseHeaders: Record): boolean {\r\n return hasHeader(responseHeaders, \"Content-Disposition\");\r\n}\r\nfunction isJsonResponse(responseHeaders: Record): boolean {\r\n const contentType = getHeader(responseHeaders, \"Content-Type\");\r\n return contentType?.startsWith(\"application/json\") == true;\r\n}\r\n\r\nfunction handleBatchResponse(response: string, parseParams: any) {\r\n const batch = parseBatchResponse(response, parseParams);\r\n return parseParams?.[0].convertedToBatch ? batch[0] : batch;\r\n}\r\n\r\nfunction handleFileResponse(response: string, responseHeaders: any, parseParams: any): any {\r\n return parseFileResponse(response, responseHeaders, parseParams[0]);\r\n}\r\n\r\nexport function handleJsonResponse(response: string, parseParams: any, requestNumber: number = 0): any {\r\n return parseData(JSON.parse(response, dateReviver), parseParams[requestNumber]);\r\n}\r\n\r\nexport function handlePlainResponse(response?: string): number | string | undefined {\r\n const numberResponse = Number(response);\r\n return isFinite(numberResponse) ? numberResponse : response;\r\n}\r\n\r\nfunction handleEmptyResponse(responseHeaders: Record, parseParams: any): any {\r\n //checking if there is a valueIfEmpty parameter and return it if it is set\r\n if (parseParams?.[0]?.valueIfEmpty !== undefined) {\r\n return parseParams[0].valueIfEmpty;\r\n }\r\n //checking if the response contains an entity id, if it does - return it\r\n const entityUrl = getHeader(responseHeaders, \"OData-EntityId\");\r\n if (entityUrl) {\r\n return extractUuidFromUrl(entityUrl) ?? undefined;\r\n }\r\n //checking if the response has a location header\r\n const location = getHeader(responseHeaders, \"Location\");\r\n if (location) {\r\n const result: { location: string; chunkSize?: number; backgroundOperationId?: string } = { location: location };\r\n if (responseHeaders[\"x-ms-chunk-size\"]) {\r\n result.chunkSize = parseInt(responseHeaders[\"x-ms-chunk-size\"]);\r\n }\r\n if (responseHeaders[\"x-ms-dyn-backgroundoperationid\"]) {\r\n result.backgroundOperationId = responseHeaders[\"x-ms-dyn-backgroundoperationid\"];\r\n }\r\n return result;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param response - response that needs to be parsed\r\n * @param responseHeaders - response headers\r\n * @param parseParams - parameters for parsing the response\r\n * @returns parsed response\r\n */\r\nexport function parseResponse(response: string, responseHeaders: Record, parseParams: any[]): any {\r\n if (!response.length) {\r\n return handleEmptyResponse(responseHeaders, parseParams);\r\n }\r\n if (isBatchResponse(response)) {\r\n return handleBatchResponse(response, parseParams);\r\n }\r\n if (isFileResponse(responseHeaders)) {\r\n return handleFileResponse(response, responseHeaders, parseParams);\r\n }\r\n if (isJsonResponse(responseHeaders)) {\r\n return handleJsonResponse(response, parseParams);\r\n }\r\n return handlePlainResponse(response);\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 type * as 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 headers = options.headers;\r\n const responseParams = options.responseParams;\r\n const signal = options.abortSignal;\r\n\r\n const httpHeaders: http.OutgoingHttpHeaders = {};\r\n\r\n if (data) {\r\n httpHeaders[\"Content-Type\"] = headers[\"Content-Type\"];\r\n httpHeaders[\"Content-Length\"] = data.length;\r\n\r\n delete headers[\"Content-Type\"];\r\n }\r\n\r\n //set additional headers\r\n for (let key in headers) {\r\n httpHeaders[key] = headers[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: httpHeaders,\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) httpHeaders.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 if (res.statusCode && ((res.statusCode >= 200 && res.statusCode < 300) || res.statusCode === 304)) {\r\n // Success with Not Modified\r\n let responseData = parseResponse(rawData, res.headers as Record, 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 } else {\r\n // All other statuses are error cases.\r\n let crmError;\r\n try {\r\n var errorParsed = parseResponse(rawData, res.headers as Record, responseParams[options.requestId]);\r\n\r\n if (Array.isArray(errorParsed)) {\r\n errorCallback(errorParsed);\r\n return;\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 }\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 { isRunningWithinPortals, getClientUrl } from \"./Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { ApiConfig, Config, SearchApiOptions } from \"../dynamics-web-api\";\r\nimport { LIBRARY_NAME } from \"../requests/constants\";\r\n\r\ntype ApiType = \"dataApi\" | \"searchApi\" | \"serviceApi\";\r\n\r\nconst FUNCTION_NAME = `${LIBRARY_NAME}.setConfig`;\r\n\r\nconst apiConfigs: ApiType[] = [\"dataApi\", \"searchApi\", \"serviceApi\"];\r\n\r\nexport interface InternalApiConfig extends ApiConfig {\r\n url: string;\r\n escapeSpecialCharacters?: boolean;\r\n enableSearchApiResponseCompatibility?: boolean;\r\n}\r\n\r\nexport interface InternalConfig extends Config {\r\n dataApi: InternalApiConfig;\r\n searchApi: InternalApiConfig;\r\n serviceApi: InternalApiConfig;\r\n}\r\n\r\nexport const getApiUrl = (serverUrl: string | undefined | null, apiConfig: ApiConfig): string => {\r\n if (isRunningWithinPortals()) {\r\n return new URL(\"_api\", global.window.location.origin).toString() + \"/\";\r\n } else {\r\n if (!serverUrl) serverUrl = getClientUrl();\r\n\r\n let url = \"api\";\r\n if (apiConfig.path) {\r\n url += `/${apiConfig.path}`;\r\n }\r\n if (apiConfig.version) {\r\n url += `/v${apiConfig.version}`;\r\n }\r\n\r\n return new URL(url, serverUrl).toString() + \"/\";\r\n }\r\n};\r\n\r\nconst mergeSearchApiOptions = (internalApiConfig: InternalApiConfig, options: SearchApiOptions | undefined): void => {\r\n if (!options) return;\r\n\r\n if (options.escapeSpecialCharacters != null) {\r\n ErrorHelper.boolParameterCheck(options.escapeSpecialCharacters, FUNCTION_NAME, `config.searchApi.options.escapeSpecialCharacters`);\r\n internalApiConfig.escapeSpecialCharacters = options.escapeSpecialCharacters;\r\n }\r\n\r\n if (options.enableResponseCompatibility != null) {\r\n ErrorHelper.boolParameterCheck(options.enableResponseCompatibility, FUNCTION_NAME, `config.searchApi.options.enableResponseCompatibility`);\r\n internalApiConfig.enableSearchApiResponseCompatibility = options.enableResponseCompatibility;\r\n }\r\n};\r\n\r\nexport const mergeApiConfig = (internalConfig: InternalConfig, apiType: ApiType, config: Config | undefined): void => {\r\n const internalApiConfig = internalConfig[apiType] as InternalApiConfig;\r\n const apiConfig = config?.[apiType] as ApiConfig | undefined;\r\n\r\n if (apiConfig?.version) {\r\n ErrorHelper.stringParameterCheck(apiConfig.version, FUNCTION_NAME, `config.${apiType}.version`);\r\n internalApiConfig.version = apiConfig.version;\r\n }\r\n\r\n if (apiConfig?.path) {\r\n ErrorHelper.stringParameterCheck(apiConfig.path, FUNCTION_NAME, `config.${apiType}.path`);\r\n internalApiConfig.path = apiConfig.path;\r\n }\r\n\r\n if (apiType === \"searchApi\") {\r\n mergeSearchApiOptions(internalApiConfig, apiConfig?.options);\r\n }\r\n\r\n internalApiConfig.url = getApiUrl(internalConfig.serverUrl, internalApiConfig);\r\n};\r\n\r\nexport function mergeConfig(internalConfig: InternalConfig, config?: Config): void {\r\n if (config?.serverUrl) {\r\n ErrorHelper.stringParameterCheck(config.serverUrl, FUNCTION_NAME, \"config.serverUrl\");\r\n internalConfig.serverUrl = config.serverUrl;\r\n }\r\n\r\n apiConfigs.forEach((apiType) => {\r\n mergeApiConfig(internalConfig, apiType, config);\r\n });\r\n\r\n if (config?.impersonate) {\r\n internalConfig.impersonate = ErrorHelper.guidParameterCheck(config.impersonate, FUNCTION_NAME, \"config.impersonate\");\r\n }\r\n\r\n if (config?.impersonateAAD) {\r\n internalConfig.impersonateAAD = ErrorHelper.guidParameterCheck(config.impersonateAAD, FUNCTION_NAME, \"config.impersonateAAD\");\r\n }\r\n\r\n if (config?.onTokenRefresh) {\r\n ErrorHelper.callbackParameterCheck(config.onTokenRefresh, FUNCTION_NAME, \"config.onTokenRefresh\");\r\n internalConfig.onTokenRefresh = config.onTokenRefresh;\r\n }\r\n\r\n if (config?.includeAnnotations) {\r\n ErrorHelper.stringParameterCheck(config.includeAnnotations, FUNCTION_NAME, \"config.includeAnnotations\");\r\n internalConfig.includeAnnotations = config.includeAnnotations;\r\n }\r\n\r\n if (config?.timeout) {\r\n ErrorHelper.numberParameterCheck(config.timeout, FUNCTION_NAME, \"config.timeout\");\r\n internalConfig.timeout = config.timeout;\r\n }\r\n\r\n if (config?.maxPageSize) {\r\n ErrorHelper.numberParameterCheck(config.maxPageSize, FUNCTION_NAME, \"config.maxPageSize\");\r\n internalConfig.maxPageSize = config.maxPageSize;\r\n }\r\n\r\n if (config?.returnRepresentation != null) {\r\n ErrorHelper.boolParameterCheck(config.returnRepresentation, FUNCTION_NAME, \"config.returnRepresentation\");\r\n internalConfig.returnRepresentation = config.returnRepresentation;\r\n }\r\n\r\n if (config?.useEntityNames != null) {\r\n ErrorHelper.boolParameterCheck(config.useEntityNames, FUNCTION_NAME, \"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, FUNCTION_NAME, \"config.proxy\");\r\n\r\n if (config.proxy.url) {\r\n ErrorHelper.stringParameterCheck(config.proxy.url, FUNCTION_NAME, \"config.proxy.url\");\r\n\r\n if (config.proxy.auth) {\r\n ErrorHelper.parameterCheck(config.proxy.auth, FUNCTION_NAME, \"config.proxy.auth\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.username, FUNCTION_NAME, \"config.proxy.auth.username\");\r\n ErrorHelper.stringParameterCheck(config.proxy.auth.password, FUNCTION_NAME, \"config.proxy.auth.password\");\r\n }\r\n }\r\n\r\n internalConfig.proxy = config.proxy;\r\n }\r\n}\r\n\r\nexport function defaultConfig(): 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 serviceApi: {\r\n url: \"\",\r\n },\r\n };\r\n}\r\n", "export const LIBRARY_NAME = \"DynamicsWebApi\";", "import type * as Core from \"../types\";\r\nimport type { AccessToken } from \"../dynamics-web-api\";\r\nimport type { InternalConfig } from \"../utils/Config\";\r\nimport { generateUUID, isRunningWithinPortals, isNull } from \"../utils/Utility\";\r\nimport * as EntityMapper from \"./helpers/entityNameMapper\";\r\nimport { executeRequest } from \"./helpers/executeRequest\";\r\nimport { DynamicsWebApiError, ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { composeRequest, convertToBatch, processData, setStandardHeaders } from \"./request\";\r\n\r\nconst _addResponseParams = (requestId: string, responseParams: Record) => {\r\n if (_responseParseParams[requestId]) _responseParseParams[requestId].push(responseParams);\r\n else _responseParseParams[requestId] = [responseParams];\r\n};\r\n\r\nconst _addRequestToBatchCollection = (requestId: string, request: Core.InternalRequest) => {\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 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\nconst _nameExceptions = [\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\nconst _isEntityNameException = (entityName: string): boolean => {\r\n return _nameExceptions.indexOf(entityName) > -1;\r\n};\r\n\r\nconst _getCollectionNames = async (entityName: string, config: InternalConfig): Promise => {\r\n if (!isNull(EntityMapper.entityNames)) {\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n }\r\n\r\n const request = composeRequest(\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 EntityMapper.setEntityNames({});\r\n for (let i = 0; i < result.data.value.length; i++) {\r\n EntityMapper.entityNames![result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;\r\n }\r\n\r\n return EntityMapper.findCollectionName(entityName) || entityName;\r\n};\r\n\r\nconst _checkCollectionName = async (entityName: string | null | undefined, config: InternalConfig): Promise => {\r\n if (!entityName || _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 _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/**\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\nexport const sendRequest = async (request: Core.InternalRequest, config: InternalConfig): Promise => {\r\n request.headers = request.headers || {};\r\n request.responseParameters = request.responseParameters || {};\r\n request.requestId = request.requestId || 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 = 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 ? processData(request.data, config) : request.data;\r\n\r\n // don't set headers if the request is a part of batch request\r\n // or if it is set to not include default dataverse headers\r\n // todo: use the latter option in batch requests as well\r\n if (!isBatchConverted && request.includeDefaultDataverseHeaders !== false) {\r\n request.headers = setStandardHeaders(request.headers, request.data);\r\n }\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 (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 proxy: config.proxy,\r\n isAsync: request.async,\r\n headers: request.headers!,\r\n requestId: request.requestId!,\r\n abortSignal: request.signal,\r\n responseParams: _responseParseParams,\r\n timeout: request.timeout || config.timeout,\r\n });\r\n};\r\n\r\nexport const makeRequest = async (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 _checkCollectionName(request.collection, config);\r\n\r\n request.collection = collectionName;\r\n composeRequest(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 = convertToBatch([request], config);\r\n\r\n //#175 authorization header must be copied as well.\r\n //todo: is it the only one that needs to be copied?\r\n if (request.headers![\"Authorization\"]) {\r\n batchRequest.headers[\"Authorization\"] = request.headers![\"Authorization\"];\r\n }\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 composeRequest(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\nexport const _clearTestData = (): void => {\r\n EntityMapper.setEntityNames(null);\r\n _responseParseParams = {};\r\n _batchRequestCollection = {};\r\n};\r\n\r\nexport const getCollectionName = (entityName: string): string | null => {\r\n return EntityMapper.findCollectionName(entityName);\r\n};\r\n", "import { isNull } from \"../../utils/Utility\";\r\n\r\nexport let entityNames: Record | null = null;\r\n\r\nexport const setEntityNames = (newEntityNames: Record | null) => {\r\n entityNames = newEntityNames;\r\n};\r\n\r\nexport const findCollectionName = (entityName: string): string | null => {\r\n if (isNull(entityNames)) return null;\r\n\r\n const collectionName = entityNames[entityName];\r\n if (!collectionName) {\r\n for (const key in entityNames) {\r\n if (entityNames[key] === entityName) {\r\n return entityName;\r\n }\r\n }\r\n }\r\n\r\n return collectionName;\r\n};", "import type { RequestOptions, WebApiResponse } from \"../../types\";\r\n\r\nexport async function executeRequest(options: RequestOptions): Promise {\r\n return global.DWA_BROWSER ? require(\"../xhr\").executeRequest(options) : require(\"../http\").executeRequest(options);\r\n}\r\n", "import { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../../types\";\r\nimport { safelyRemoveCurlyBracketsFromUrl } from \"../../../helpers/Regex\";\r\nimport { Config } from \"../../../dynamics-web-api\";\r\nimport { isNull } from \"../../../utils/Utility\";\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 * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @param url Starting url\r\n * @param joinSymbol Join symbol. \"&\" by default and \";\" inside an expand query parameter\r\n * @returns Request URL\r\n */\r\nexport const composeUrl = (request: InternalRequest | null, config: Config | null, url: string = \"\", joinSymbol: \"&\" | \";\" = \"&\"): 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(request.metadataAttributeType, `DynamicsWebApi.${request.functionName}`, \"request.metadataAttributeType\");\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 filterResult = safelyRemoveCurlyBracketsFromUrl(request.filter);\r\n queryArray.push(\"$filter=\" + encodeURIComponent(filterResult));\r\n }\r\n\r\n //todo: delete in v2.5\r\n if (request.fieldName) {\r\n ErrorHelper.stringParameterCheck(request.fieldName, `DynamicsWebApi.${request.functionName}`, \"request.fieldName\");\r\n if (!request.property) request.property = request.fieldName;\r\n delete request.fieldName;\r\n }\r\n\r\n if (request.property) {\r\n ErrorHelper.stringParameterCheck(request.property, `DynamicsWebApi.${request.functionName}`, \"request.property\");\r\n url += \"/\" + request.property;\r\n }\r\n\r\n if (request.savedQuery) {\r\n queryArray.push(\"savedQuery=\" + ErrorHelper.guidParameterCheck(request.savedQuery, `DynamicsWebApi.${request.functionName}`, \"request.savedQuery\"));\r\n }\r\n\r\n if (request.userQuery) {\r\n queryArray.push(\"userQuery=\" + ErrorHelper.guidParameterCheck(request.userQuery, `DynamicsWebApi.${request.functionName}`, \"request.userQuery\"));\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.tag) {\r\n ErrorHelper.stringParameterCheck(request.tag, `DynamicsWebApi.${request.functionName}`, \"request.tag\");\r\n queryArray.push(\"tag=\" + encodeURIComponent(request.tag));\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 (request.fetchXml) {\r\n ErrorHelper.stringParameterCheck(request.fetchXml, `DynamicsWebApi.${request.functionName}`, \"request.fetchXml\");\r\n queryArray.push(\"fetchXml=\" + encodeURIComponent(request.fetchXml));\r\n }\r\n\r\n if (!isNull(request.inChangeSet)) {\r\n ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, \"request.inChangeSet\");\r\n }\r\n\r\n if (request.isBatch && 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 (const { property, ...expand } of request.expand) {\r\n if (!property) continue;\r\n\r\n const expandRequest: InternalRequest = {\r\n functionName: `${request.functionName} $expand`,\r\n ...expand,\r\n };\r\n let expandConverted = composeUrl(expandRequest, config, \"\", \";\");\r\n if (expandConverted) {\r\n expandConverted = `(${expandConverted})`;\r\n }\r\n expandQueryArray.push(property + expandConverted);\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 // nothing to add to the URL\r\n if (!queryArray.length) {\r\n return url;\r\n }\r\n\r\n // in any other cases the joinSymbol is \";\" (during expand process)\r\n if (joinSymbol === \"&\") {\r\n url += \"?\";\r\n }\r\n\r\n return url + queryArray.join(joinSymbol);\r\n\r\n // return !queryArray.length ? url : url + \"?\" + queryArray.join(joinSymbol);\r\n};\r\n", "import type { Config, HeaderCollection } from \"../../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { composePreferHeader } from \"./preferHeader\";\r\n\r\nexport const composeHeaders = (request: InternalRequest, config: Config): HeaderCollection => {\r\n const headers: HeaderCollection = { ...config.headers, ...request.userHeaders };\r\n\r\n const prefer = 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(request.impersonateAAD, `DynamicsWebApi.${request.functionName}`, \"request.impersonateAAD\");\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(request.bypassCustomPluginExecution, `DynamicsWebApi.${request.functionName}`, \"request.bypassCustomPluginExecution\");\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};", "import type { Config } from \"../../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport { extractPreferCallbackUrl, removeDoubleQuotes } from \"../../../helpers/Regex\";\r\n\r\ntype PreferOptions = {\r\n returnRepresentation?: boolean | null;\r\n includeAnnotations?: string | null;\r\n maxPageSize?: number | null;\r\n trackChanges?: boolean;\r\n continueOnError?: boolean;\r\n backgroundOperationCallbackUrl?: string | null;\r\n respondAsync?: boolean;\r\n};\r\n\r\nexport const composePreferHeader = (request: InternalRequest, config: Config): string => {\r\n const functionName = `DynamicsWebApi.${request.functionName}`;\r\n\r\n // Extract request options with defaults from config\r\n const options: PreferOptions = {\r\n respondAsync: request.respondAsync,\r\n backgroundOperationCallbackUrl: request.backgroundOperationCallbackUrl ?? config?.backgroundOperationCallbackUrl,\r\n returnRepresentation: request.returnRepresentation ?? config?.returnRepresentation,\r\n includeAnnotations: request.includeAnnotations ?? config?.includeAnnotations,\r\n maxPageSize: request.maxPageSize ?? config?.maxPageSize,\r\n trackChanges: request.trackChanges,\r\n continueOnError: request.continueOnError,\r\n };\r\n\r\n const prefer: Set = new Set();\r\n\r\n // Process prefer header from request. Request items have a higher priority than config\r\n if (request.prefer?.length) {\r\n ErrorHelper.stringOrArrayParameterCheck(request.prefer, functionName, \"request.prefer\");\r\n const preferArray = typeof request.prefer === \"string\" ? request.prefer.split(\",\") : request.prefer;\r\n\r\n for (const item of preferArray) {\r\n const trimmedItem = item.trim();\r\n\r\n if (trimmedItem.includes(\"respond-async\")) {\r\n options.respondAsync = true;\r\n } else if (trimmedItem.startsWith(\"odata.callback\")) {\r\n options.backgroundOperationCallbackUrl = extractPreferCallbackUrl(trimmedItem);\r\n } else if (trimmedItem === \"return=representation\") {\r\n options.returnRepresentation = true;\r\n } else if (trimmedItem.includes(\"odata.include-annotations=\")) {\r\n options.includeAnnotations = removeDoubleQuotes(trimmedItem.replace(\"odata.include-annotations=\", \"\"));\r\n } else if (trimmedItem.startsWith(\"odata.maxpagesize=\")) {\r\n options.maxPageSize = Number(removeDoubleQuotes(trimmedItem.replace(\"odata.maxpagesize=\", \"\"))) || 0;\r\n } else if (trimmedItem.includes(\"odata.track-changes\")) {\r\n options.trackChanges = true;\r\n } else if (trimmedItem.includes(\"odata.continue-on-error\")) {\r\n options.continueOnError = true;\r\n } else {\r\n prefer.add(trimmedItem);\r\n }\r\n }\r\n }\r\n\r\n // Process prefer options\r\n for (const key in options) {\r\n const optionFactory = preferOptionsFactory[key];\r\n if (optionFactory && options[key]) {\r\n optionFactory.validator?.(options[key], functionName, `request.${key}`);\r\n if (optionFactory.condition(options[key], options)) {\r\n prefer.add(optionFactory.formatter(options[key], options));\r\n }\r\n }\r\n }\r\n\r\n return Array.from(prefer).join(\",\");\r\n};\r\n\r\ntype PreferValidationHandler = (value: any, functionName: string, paramName: string) => void;\r\ninterface PreferFactoryOption {\r\n validator?: PreferValidationHandler;\r\n condition: (value: any, options: Record) => boolean;\r\n formatter: (value: any, options: Record) => string;\r\n}\r\n\r\nconst preferOptionsFactory: Record = {\r\n respondAsync: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"respond-async\",\r\n },\r\n backgroundOperationCallbackUrl: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value, options) => value && options.respondAsync,\r\n formatter: (url) => `odata.callback;url=\"${url}\"`,\r\n },\r\n returnRepresentation: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"return=representation\",\r\n },\r\n includeAnnotations: {\r\n validator: ErrorHelper.stringParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: (annotations) => `odata.include-annotations=\"${annotations}\"`,\r\n },\r\n maxPageSize: {\r\n validator: (value, functionName) => (value > 0 ? ErrorHelper.numberParameterCheck(value, functionName, \"request.maxPageSize\") : undefined),\r\n condition: (value) => value > 0,\r\n formatter: (size) => `odata.maxpagesize=${size}`,\r\n },\r\n trackChanges: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.track-changes\",\r\n },\r\n continueOnError: {\r\n validator: ErrorHelper.boolParameterCheck,\r\n condition: (value) => !!value,\r\n formatter: () => \"odata.continue-on-error\",\r\n },\r\n};\r\n", "import { composeHeaders, composeUrl } from \".\";\r\nimport { ErrorHelper } from \"../../../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../../../types\";\r\nimport type { InternalConfig } from \"../../../utils/Config\";\r\n\r\n/**\r\n * Converts a request object to URL link\r\n * @param request Internal request object\r\n * @param config Internal configuration object\r\n * @returns Modified internal request object\r\n */\r\nexport const composeRequest = (request: InternalRequest, config: Partial): InternalRequest => {\r\n request.path = \"\"; //path must always be reset\r\n request.functionName = request.functionName || \"\";\r\n if (!request.url) {\r\n if (!request._isUnboundRequest && !request.contentId && !request.collection) {\r\n ErrorHelper.parameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\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 request.path = request.contentId;\r\n }\r\n }\r\n\r\n if (request.collection != null) {\r\n ErrorHelper.stringParameterCheck(request.collection, `DynamicsWebApi.${request.functionName}`, \"request.collection\");\r\n request.path += request.path ? `/${request.collection}` : request.collection;\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.addPath) {\r\n if (request.path) {\r\n request.path += \"/\";\r\n }\r\n request.path += request.addPath;\r\n }\r\n\r\n request.path = composeUrl(request, config, request.path);\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 = composeHeaders(request, config);\r\n\r\n return request;\r\n};", "import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from \"../../helpers/Regex\";\r\nimport type { InternalConfig } from \"../../utils/Config\";\r\nimport { isNull } from \"../../utils/Utility\";\r\nimport { findCollectionName } from \"../helpers\";\r\n\r\nexport const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {\r\n if (!data) return null;\r\n\r\n if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;\r\n\r\n const replaceEntityNameWithCollectionName = (value: string): string => {\r\n const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);\r\n if (valueParts && valueParts.length > 2) {\r\n const collectionName = findCollectionName(valueParts[1]);\r\n if (!isNull(collectionName)) {\r\n return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const addFullWebApiUrl = (key: string, value: string): string => {\r\n if (!value.startsWith(config.dataApi.url)) {\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}${removeLeadingSlash(value)}`;\r\n }\r\n }\r\n return value;\r\n };\r\n\r\n const stringifiedData = JSON.stringify(data, (key, value) => {\r\n if (key === \"@odata.id\" || key.endsWith(\"@odata.bind\")) {\r\n if (typeof value === \"string\" && !value.startsWith(\"$\")) {\r\n value = removeCurlyBracketsFromUuid(value);\r\n if (config.useEntityNames) {\r\n value = replaceEntityNameWithCollectionName(value);\r\n }\r\n\r\n // the full Web API URL is only added in requests to /$ref\r\n // the value itself is set directly in the requests that require it\r\n if (key !== \"@odata.id\") {\r\n value = addFullWebApiUrl(key, value);\r\n }\r\n }\r\n } else if (key.startsWith(\"oData\") || key.endsWith(\"_Formatted\") || key.endsWith(\"_NavigationProperty\") || key.endsWith(\"_LogicalName\")) {\r\n return undefined;\r\n }\r\n return value;\r\n });\r\n\r\n return escapeUnicodeSymbols(stringifiedData);\r\n};\r\n", "export * from \"./entityNameMapper\";\r\nexport * from \"./dateReviver\";\r\nexport * from \"./executeRequest\";\r\nexport * from \"./parseBatchResponse\";\r\nexport * from \"./parseResponse\";\r\nexport * from \"./parseResponseHeaders\";", "import type { HeaderCollection } from \"../../dynamics-web-api\";\r\n\r\nexport const setStandardHeaders = (headers: HeaderCollection = {}, data?: any): HeaderCollection => {\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\"] && data) headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\r\n\r\n return headers;\r\n};", "import { processData, setStandardHeaders } from \".\";\r\nimport { InternalConfig } from \"../../utils/Config\";\r\nimport { generateUUID } from \"../../utils/Utility\";\r\nimport type { InternalBatchRequest, InternalRequest } from \"../../types\";\r\n\r\nexport const convertToBatch = (requests: InternalRequest[], config: InternalConfig, batchRequest?: InternalRequest): InternalBatchRequest => {\r\n const batchBoundary = `dwa_batch_${generateUUID()}`;\r\n\r\n const batchBody: string[] = [];\r\n let currentChangeSet: string | null = null;\r\n let contentId = 100000;\r\n\r\n const addHeaders = (headers: Record, batchBody: string[]) => {\r\n for (const key in headers) {\r\n if (key === \"Authorization\" || key === \"Content-ID\") continue;\r\n batchBody.push(`${key}: ${headers[key]}`);\r\n }\r\n };\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(`\\r\\n--${currentChangeSet}--`);\r\n\r\n currentChangeSet = null;\r\n contentId = 100000;\r\n }\r\n\r\n if (!currentChangeSet) {\r\n batchBody.push(`\\r\\n--${batchBoundary}`);\r\n\r\n if (inChangeSet) {\r\n currentChangeSet = `changeset_${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(`\\r\\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(`\\r\\n${internalRequest.method} ${config.dataApi.url}${internalRequest.path} HTTP/1.1`);\r\n } else {\r\n batchBody.push(`\\r\\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 if (internalRequest.headers) {\r\n addHeaders(internalRequest.headers, batchBody);\r\n }\r\n\r\n if (internalRequest.data) {\r\n batchBody.push(`\\r\\n${processData(internalRequest.data, config)}`);\r\n }\r\n });\r\n\r\n if (currentChangeSet) {\r\n batchBody.push(`\\r\\n--${currentChangeSet}--`);\r\n }\r\n\r\n batchBody.push(`\\r\\n--${batchBoundary}--\\r\\n`);\r\n\r\n const headers = setStandardHeaders(batchRequest?.userHeaders, batchRequest?.data);\r\n headers[\"Content-Type\"] = `multipart/mixed;boundary=${batchBoundary}`;\r\n\r\n return { headers: headers, body: batchBody.join(\"\\r\\n\") };\r\n};\r\n", "import { Config } from \"../dynamics-web-api\";\r\nimport type { InternalRequest, WebApiResponse } from \"../types\";\r\nimport { defaultConfig, mergeConfig, type InternalConfig } from \"../utils/Config\";\r\nimport { makeRequest } from \"./RequestClient\";\r\n\r\n// module is in development; multiple changes might be made here\r\n\r\nexport interface IDataverseClient {\r\n get config(): InternalConfig;\r\n get isBatch(): boolean;\r\n set isBatch(value: boolean);\r\n get batchRequestId(): string | null;\r\n set batchRequestId(value: string | null);\r\n\r\n setConfig(config: Config): void;\r\n makeRequest(request: InternalRequest): Promise;\r\n}\r\n\r\nexport class DataverseClient implements IDataverseClient {\r\n #config = defaultConfig();\r\n #isBatch = false;\r\n #batchRequestId: string | null = null;\r\n\r\n constructor(config?: Config) {\r\n mergeConfig(this.#config, config);\r\n }\r\n get batchRequestId(): string | null {\r\n return this.#batchRequestId;\r\n }\r\n set batchRequestId(value: string | null) {\r\n this.#batchRequestId = value;\r\n }\r\n\r\n get config(): InternalConfig {\r\n return this.#config;\r\n }\r\n\r\n get isBatch(): boolean {\r\n return this.#isBatch;\r\n }\r\n\r\n set isBatch(value: boolean) {\r\n this.#isBatch = value;\r\n }\r\n\r\n setConfig = (config: Config) => mergeConfig(this.#config, config);\r\n\r\n makeRequest = (request: InternalRequest): Promise => {\r\n request.isBatch = this.#isBatch;\r\n if (this.#batchRequestId) request.requestId = this.#batchRequestId;\r\n return makeRequest(request, this.#config);\r\n };\r\n}\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associate = async (request: AssociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = request.relationshipName + \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AssociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"associateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const associateSingleValued = async (request: AssociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n\r\n let relatedKey = request.relatedKey;\r\n let odataId = request.relatedKey;\r\n\r\n // relatedKey can be a contentId that starts with \"$\" during batch requests.\r\n // In this case, we do not need to check it as a key parameter.\r\n if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith(\"$\"))) {\r\n ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, \"request.relatedCollection\");\r\n relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedKey\");\r\n odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`;\r\n }\r\n\r\n let internalRequest = copyRequest(request, [\"primaryKey\"]);\r\n internalRequest.method = \"PUT\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = request.primaryKey;\r\n internalRequest.data = { \"@odata.id\": odataId };\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundActionRequest, UnboundActionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callAction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callAction = async (\r\n request: BoundActionRequest | UnboundActionRequest,\r\n client: IDataverseClient,\r\n): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.stringParameterCheck(request.actionName, REQUEST_NAME, \"request.actionName\");\r\n\r\n const internalRequest = copyRequest(request, [\"action\"]);\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n internalRequest.addPath = request.actionName;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.data = request.action;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BoundFunctionRequest, UnboundFunctionRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { buildFunctionParameters, copyObject } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"callFunction\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const callFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const getFunctionName = (request: BoundFunctionRequest | UnboundFunctionRequest) => request.name || request.functionName;\r\n\r\n const isObject = typeof request !== \"string\";\r\n const functionName = isObject ? getFunctionName(request) : request;\r\n const parameterName = isObject ? \"request.name\" : \"name\";\r\n const internalRequest: InternalRequest = isObject ? copyObject(request, [\"name\"]) : { functionName: functionName };\r\n\r\n ErrorHelper.stringParameterCheck(functionName, REQUEST_NAME, parameterName);\r\n\r\n const functionParameters = buildFunctionParameters(internalRequest.parameters);\r\n\r\n internalRequest.method = \"GET\";\r\n internalRequest.addPath = functionName + functionParameters.key;\r\n internalRequest.queryParams = functionParameters.queryParams;\r\n internalRequest._isUnboundRequest = !internalRequest.collection;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CreateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"create\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const create = async (request: CreateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"POST\";\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"count\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const count = async (request: CountRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { CountAllRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveAllRequest } from \"./retrieveAll\";\r\n\r\nconst FUNCTION_NAME = \"countAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const countAll = async (request: CountAllRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const response = await retrieveAllRequest(request, client);\r\n\r\n return response.value.length;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { AllResponse, RetrieveMultipleRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { retrieveMultiple } from \"./retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAllRequest = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n records: any[] = [],\r\n): Promise> => {\r\n const response = await retrieveMultiple(request, client, 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 retrieveAllRequest(request, client, 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\nexport const retrieveAll = (request: RetrieveMultipleRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n return retrieveAllRequest(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieveMultiple\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveMultiple = async (\r\n request: RetrieveMultipleRequest,\r\n client: IDataverseClient,\r\n nextPageLink?: string,\r\n): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method = \"GET\";\r\n\r\n if (nextPageLink) {\r\n ErrorHelper.stringParameterCheck(nextPageLink, REQUEST_NAME, \"nextPageLink\");\r\n internalRequest.url = nextPageLink;\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociate\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociate = async (request: DisassociateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.relationshipName, REQUEST_NAME, \"request.relationshipName\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n const relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, \"request.relatedId\");\r\n\r\n internalRequest.key = primaryKey;\r\n internalRequest.navigationProperty = `${request.relationshipName}(${relatedKey})/$ref`;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DisassociateSingleValuedRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"disassociateSingleValued\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const disassociateSingleValued = async (request: DisassociateSingleValuedRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest = copyRequest(request);\r\n internalRequest.method = \"DELETE\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(request.navigationProperty, REQUEST_NAME, \"request.navigationProperty\");\r\n const primaryKey = ErrorHelper.keyParameterCheck(request.primaryKey, REQUEST_NAME, \"request.primaryKey\");\r\n\r\n internalRequest.navigationProperty += \"/$ref\";\r\n internalRequest.key = primaryKey;\r\n\r\n await client.makeRequest(internalRequest);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { RetrieveRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"retrieve\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieve = async (request: RetrieveRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.makeRequest(internalRequest);\r\n return response?.data;\r\n};", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { FETCH_XML_PAGE_REGEX, FETCH_XML_REPLACE_REGEX, FETCH_XML_TOP_REGEX } from \"../helpers/Regex\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"fetch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const fetchXml = async (request: FetchXmlRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n ErrorHelper.stringParameterCheck(internalRequest.fetchXml, REQUEST_NAME, \"request.fetchXml\");\r\n\r\n //only add paging if there is no top\r\n if (internalRequest.fetchXml && !FETCH_XML_TOP_REGEX.test(internalRequest.fetchXml)) {\r\n let replacementString: string = \"\";\r\n\r\n if (!FETCH_XML_PAGE_REGEX.test(internalRequest.fetchXml)) {\r\n internalRequest.pageNumber = internalRequest.pageNumber || 1;\r\n\r\n ErrorHelper.numberParameterCheck(internalRequest.pageNumber, REQUEST_NAME, \"request.pageNumber\");\r\n replacementString = `$1 page=\"${internalRequest.pageNumber}\"`;\r\n }\r\n\r\n if (internalRequest.pagingCookie != null) {\r\n ErrorHelper.stringParameterCheck(internalRequest.pagingCookie, REQUEST_NAME, \"request.pagingCookie\");\r\n replacementString += ` paging-cookie=\"${internalRequest.pagingCookie}\"`;\r\n }\r\n\r\n //add page number and paging cookie to fetch xml\r\n if (replacementString) internalRequest.fetchXml = internalRequest.fetchXml.replace(FETCH_XML_REPLACE_REGEX, replacementString);\r\n }\r\n\r\n internalRequest.responseParameters = { pageNumber: internalRequest.pageNumber };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { FetchAllRequest, FetchXmlRequest, FetchXmlResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\nimport { fetchXml } from \"./fetchXml\";\r\n\r\nconst FUNCTION_NAME = \"fetchAll\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst executeFetchXmlAll = async (request: FetchXmlRequest, client: IDataverseClient, records: any[] = []): Promise> => {\r\n const response = await fetchXml(request, client);\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, client, records);\r\n }\r\n\r\n return { value: records };\r\n};\r\n\r\nexport const fetchXmlAll = async (request: FetchAllRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n\r\n return executeFetchXmlAll(request, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { getUpdateMethod } from \"../helpers/Regex\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"update\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const update = async (request: UpdateRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\r\n } else internalRequest = request;\r\n\r\n internalRequest.method ??= getUpdateMethod(internalRequest.collection);\r\n internalRequest.responseParameters = { valueIfEmpty: true };\r\n internalRequest.ifmatch ??= \"*\"; //to prevent upsert\r\n\r\n //copy locally\r\n const ifmatch = internalRequest.ifmatch;\r\n\r\n try {\r\n const response = await client.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 as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpdateSinglePropertyRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"updateSingleProperty\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateSingleProperty = async (request: UpdateSinglePropertyRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.fieldValuePair, REQUEST_NAME, \"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 = copyRequest(request);\r\n internalRequest.navigationProperty = field;\r\n internalRequest.data = { value: fieldValue };\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n delete internalRequest[\"fieldValuePair\"];\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UpsertRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"upsert\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const upsert = async (request: UpsertRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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 as any; //todo: check this\r\n } else if (ifmatch && error.status === 404) {\r\n //if prevent create\r\n return null as any; //todo: check this\r\n }\r\n //rethrow error otherwise\r\n throw error;\r\n }\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DeleteRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"deleteRecord\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const deleteRecord = async (request: DeleteRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n let internalRequest: InternalRequest;\r\n\r\n if (!(request).functionName) {\r\n internalRequest = copyRequest(request);\r\n internalRequest.functionName = FUNCTION_NAME;\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 client.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", "import { LIBRARY_NAME } from \"./constants\";\r\nimport type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { UploadRequest } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { copyRequest, setFileChunk } from \"../utils/Utility\";\r\n\r\nconst FUNCTION_NAME = \"uploadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst _uploadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n fileBytes: Uint8Array | Buffer,\r\n chunkSize: number,\r\n offset: number = 0,\r\n): Promise => {\r\n // offset = offset || 0;\r\n setFileChunk(request, fileBytes, chunkSize, offset);\r\n\r\n await client.makeRequest(request);\r\n\r\n offset += chunkSize;\r\n if (offset <= fileBytes.length) {\r\n return _uploadFileChunk(request, client, fileBytes, chunkSize, offset);\r\n }\r\n};\r\n\r\nexport const uploadFile = async (request: UploadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request, [\"data\"]);\r\n internalRequest.method = \"PATCH\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.transferMode = \"chunked\";\r\n\r\n const response = await client.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.property;\r\n delete internalRequest.fileName;\r\n return _uploadFileChunk(internalRequest, client, request.data, response?.data.chunkSize);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { DownloadRequest, DownloadResponse } from \"../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport type { InternalRequest } from \"../types\";\r\nimport { convertToFileBuffer, copyRequest, downloadChunkSize } from \"../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"downloadFile\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nconst downloadFileChunk = async (\r\n request: InternalRequest,\r\n client: IDataverseClient,\r\n bytesDownloaded: number = 0,\r\n data: string = \"\",\r\n): Promise => {\r\n request.range = \"bytes=\" + bytesDownloaded + \"-\" + (bytesDownloaded + downloadChunkSize - 1);\r\n request.downloadSize = \"full\";\r\n\r\n const response = await client.makeRequest(request);\r\n\r\n request.url = response?.data.location;\r\n data += response?.data.value;\r\n\r\n bytesDownloaded += downloadChunkSize;\r\n\r\n if (bytesDownloaded <= response?.data.fileSize) {\r\n return downloadFileChunk(request, client, bytesDownloaded, data);\r\n }\r\n\r\n return {\r\n fileName: response?.data.fileName,\r\n fileSize: response?.data.fileSize,\r\n data: 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\nexport const downloadFile = (request: DownloadRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.method = \"GET\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.responseParameters = { parse: true };\r\n\r\n return downloadFileChunk(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../client/dataverse\";\r\nimport type { BatchRequest } from \"../dynamics-web-api\";\r\nimport { copyRequest, generateUUID } from \"../utils/Utility\";\r\nimport { ErrorHelper } from \"../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../types\";\r\nimport { LIBRARY_NAME } from \"./constants\";\r\n\r\nconst FUNCTION_NAME = \"executeBatch\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function executeBatch(request: BatchRequest | undefined, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchNotStarted(client.isBatch);\r\n\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$batch\";\r\n internalRequest.method = \"POST\";\r\n internalRequest.functionName = REQUEST_NAME;\r\n internalRequest.requestId = client.batchRequestId;\r\n\r\n client.batchRequestId = null;\r\n client.isBatch = false;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n\r\nexport function startBatch(client: IDataverseClient): void {\r\n client.isBatch = true;\r\n client.batchRequestId = generateUUID();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateEntityRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createEntity = async (request: CreateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateEntityRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateEntity = async (request: UpdateEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.key = internalRequest.data.MetadataId;\r\n internalRequest.method = \"PUT\";\r\n\r\n return await update(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntityRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntity\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveEntity = async (request: RetrieveEntityRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = \"retrieveEntity\";\r\n\r\n return await retrieve(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveEntitiesRequest, RetrieveMultipleResponse, RetrieveMultipleRequest } from \"../../dynamics-web-api\";\r\nimport type { InternalRequest } from \"../../types\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\n\r\nconst FUNCTION_NAME = \"retrieveEntities\";\r\n\r\nexport const retrieveEntities = (client: IDataverseClient, request?: RetrieveEntitiesRequest): Promise> => {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateAttributeRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createAttribute = (request: CreateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateAttributeRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateAttribute\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const updateAttribute = (request: UpdateAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\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.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n};\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveMultipleRequest, RetrieveAttributesRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttributes = (request: RetrieveAttributesRequest, client: IDataverseClient): Promise> => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"EntityDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.navigationProperty = \"Attributes\";\r\n internalRequest.key = request.entityKey;\r\n internalRequest.metadataAttributeType = request.castType;\r\n\r\n return retrieveMultiple(internalRequest as RetrieveMultipleRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRequest, RetrieveAttributeRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { retrieve } from \"../retrieve\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"retrieveAttributes\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const retrieveAttribute = (request: RetrieveAttributeRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.entityKey, REQUEST_NAME, \"request.entityKey\");\r\n ErrorHelper.keyParameterCheck(request.attributeKey, REQUEST_NAME, \"request.attributeKey\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = 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 = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest as RetrieveRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateRequest, CreateRelationshipRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { create } from \"../create\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"createRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport const createRelationship = (request: CreateRelationshipRequest, client: IDataverseClient): Promise => {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest as CreateRequest, client);\r\n};", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateRelationshipRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { update } from \"../update\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\n\r\nconst FUNCTION_NAME = \"updateRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\n\r\nexport function updateRelationship(request: UpdateRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest as UpdateRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteRelationshipRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteRelationship\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteRelationship(request: DeleteRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest as DeleteRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationships\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationships(request: RetrieveRelationshipsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request) {\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveRelationshipRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveRelationship\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveRelationship(request: RetrieveRelationshipRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.keyParameterCheck(request.key, REQUEST_NAME, \"request.key\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"RelationshipDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CreateGlobalOptionSetRequest, CreateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { create } from \"../create\";\r\n\r\nconst FUNCTION_NAME = \"createGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function createGlobalOptionSet(request: CreateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return create(internalRequest, client);\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { UpdateGlobalOptionSetRequest, UpdateRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { update } from \"../update\";\r\n\r\nconst FUNCTION_NAME = \"updateGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function updateGlobalOptionSet(request: UpdateGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n ErrorHelper.parameterCheck(request.data, REQUEST_NAME, \"request.data\");\r\n ErrorHelper.guidParameterCheck(request.data.MetadataId, REQUEST_NAME, \"request.data.MetadataId\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.key = request.data.MetadataId;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"PUT\";\r\n\r\n return update(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { DeleteGlobalOptionSetRequest, DeleteRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { deleteRecord } from \"../delete\";\r\n\r\nconst FUNCTION_NAME = \"deleteGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function deleteGlobalOptionSet(request: DeleteGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return deleteRecord(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetRequest, RetrieveRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieve } from \"../retrieve\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSet\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSet(request: RetrieveGlobalOptionSetRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n if (request.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n }\r\n\r\n const internalRequest = copyRequest(request);\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.navigationProperty = request.castType;\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n return retrieve(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { RetrieveGlobalOptionSetsRequest, RetrieveMultipleRequest, RetrieveMultipleResponse } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { retrieveMultiple } from \"../retrieveMultiple\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveGlobalOptionSets\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveGlobalOptionSets(request: RetrieveGlobalOptionSetsRequest | undefined, client: IDataverseClient): Promise> {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"GlobalOptionSetDefinitions\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.castType) {\r\n ErrorHelper.stringParameterCheck(request.castType, REQUEST_NAME, \"request.castType\");\r\n internalRequest.navigationProperty = request.castType;\r\n }\r\n\r\n return retrieveMultiple(internalRequest, client);\r\n}", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { CsdlMetadataRequest } from \"../../dynamics-web-api\";\r\nimport { copyRequest } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\n\r\nconst FUNCTION_NAME = \"retrieveCsdlMetadata\";\r\nconst REQUEST_NAME = `DynamicsWebApi.${FUNCTION_NAME}`;\r\n\r\nexport async function retrieveCsdlMetadata(request: CsdlMetadataRequest | undefined, client: IDataverseClient): Promise {\r\n const internalRequest: InternalRequest = !request ? {} : copyRequest(request);\r\n\r\n internalRequest.collection = \"$metadata\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n\r\n if (request?.addAnnotations) {\r\n ErrorHelper.boolParameterCheck(request.addAnnotations, REQUEST_NAME, \"request.addAnnotations\");\r\n internalRequest.includeAnnotations = \"*\";\r\n }\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { QueryRequest, QueryResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseQueryResponse } from \"./responseParsers/parseQueryResponse\";\r\n\r\nconst FUNCTION_NAME = \"query\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function query(request: string | QueryRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.collection = \"query\";\r\n internalRequest.functionName = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseQueryResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { escapeSearchSpecialCharacters } from \"../../helpers/Regex\";\r\nimport type { Autocomplete, Suggest, Query, SearchEntity, SearchOptions, SuggestOptions } from \"../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../utils/Config\";\r\nimport type { SearchApiFunction } from \"./search.types\";\r\n\r\nexport function convertSearchQuery(\r\n query: Query | Suggest | Autocomplete,\r\n functionName: SearchApiFunction,\r\n config: InternalApiConfig,\r\n): Query | Suggest | Autocomplete {\r\n if (!query) return query;\r\n\r\n //escape special characters in a search query only if the option is set to true\r\n if (config?.escapeSpecialCharacters === true) {\r\n query.search = escapeSearchSpecialCharacters(query.search);\r\n }\r\n\r\n if (query.entities?.length) {\r\n query.entities = convertEntitiesProperty(query.entities, config?.version);\r\n }\r\n\r\n switch (functionName) {\r\n case \"query\":\r\n convertQuery(query as Query, config?.version);\r\n break;\r\n default:\r\n convertSuggestOrAutocompleteQuery(query as Suggest | Autocomplete, config?.version);\r\n break;\r\n }\r\n\r\n return query;\r\n}\r\n\r\nexport function convertEntitiesProperty(entities?: string | string[] | SearchEntity[], version: string = \"1.0\"): string | string[] | undefined {\r\n if (!entities) return entities;\r\n if (typeof entities === \"string\") {\r\n if (version !== \"1.0\") return entities;\r\n try {\r\n entities = JSON.parse(entities) as SearchEntity[];\r\n } catch {\r\n throw new Error(\"The 'query.entities' property must be a valid JSON string.\");\r\n }\r\n\r\n if (!Array.isArray(entities)) {\r\n throw new Error(\"The 'query.entities' property must be an array of strings or objects.\");\r\n }\r\n }\r\n\r\n const toStringArray = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return entity;\r\n return entity.name;\r\n };\r\n\r\n const toSearchEntity = (entity: string | SearchEntity) => {\r\n if (typeof entity === \"string\") return { name: entity };\r\n return entity;\r\n };\r\n\r\n const toReturn = entities.map((entity: string | SearchEntity) => (version === \"1.0\" ? toStringArray(entity) : toSearchEntity(entity)));\r\n\r\n if (version !== \"1.0\") return JSON.stringify(toReturn);\r\n return toReturn as string[];\r\n}\r\n\r\nexport function convertQuery(query: Query, version: string = \"1.0\"): void {\r\n const toV1 = (query: Query) => {\r\n if (query.count != null) {\r\n if (query.returnTotalRecordCount == null) {\r\n query.returnTotalRecordCount = query.count;\r\n }\r\n delete query.count;\r\n }\r\n\r\n if (query.options) {\r\n if (typeof query.options === \"string\") {\r\n try {\r\n query.options = JSON.parse(query.options, searchOptionsReviver) as SearchOptions;\r\n } catch {\r\n throw new Error(\"The 'query.options' property must be a valid JSON string.\");\r\n }\r\n }\r\n\r\n if (!query.searchMode) {\r\n query.searchMode = query.options.searchMode;\r\n }\r\n\r\n if (!query.searchType) {\r\n query.searchType = query.options.queryType === \"lucene\" ? \"full\" : query.options.queryType;\r\n }\r\n\r\n delete query.options;\r\n }\r\n\r\n // in v1.0, orderBy and facets are arrays of strings\r\n for (const prop of specialProperties) {\r\n if (query[prop] && typeof query[prop] === \"string\") {\r\n try {\r\n query[prop] = JSON.parse(query[prop]);\r\n } catch {\r\n throw new Error(`The 'query.${prop}' property must be a valid JSON string.`);\r\n }\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Query) => {\r\n if (query.returnTotalRecordCount != null) {\r\n if (query.count == null) {\r\n query.count = query.returnTotalRecordCount;\r\n }\r\n delete query.returnTotalRecordCount;\r\n }\r\n\r\n if (query.searchMode || query.searchType) {\r\n //only set the options property if it's not a string\r\n if (typeof query.options !== \"string\") {\r\n if (!query.options) query.options = {};\r\n\r\n if (!query.options.searchMode) {\r\n query.options.searchMode = query.searchMode;\r\n }\r\n\r\n if (!query.options.queryType) {\r\n query.options.queryType = query.searchType === \"full\" ? \"lucene\" : query.searchType;\r\n }\r\n }\r\n\r\n delete query.searchMode;\r\n delete query.searchType;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n if (query.facets && typeof query.facets !== \"string\") {\r\n query.facets = JSON.stringify(query.facets);\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nexport function convertSuggestOrAutocompleteQuery(query: Suggest | Autocomplete, version: string = \"1.0\"): void {\r\n const toV1 = (query: Suggest) => {\r\n if (query.fuzzy != null) {\r\n if (query.useFuzzy == null) {\r\n query.useFuzzy = query.fuzzy;\r\n }\r\n delete query.fuzzy;\r\n }\r\n\r\n delete query.options;\r\n\r\n if (query.orderBy && typeof query.orderBy === \"string\") {\r\n try {\r\n query.orderBy = JSON.parse(query.orderBy);\r\n } catch {\r\n throw new Error(`The 'query.orderBy' property must be a valid JSON string.`);\r\n }\r\n }\r\n };\r\n\r\n const toV2 = (query: Suggest) => {\r\n if (query.useFuzzy != null) {\r\n if (query.fuzzy == null) {\r\n query.fuzzy = query.useFuzzy;\r\n }\r\n delete query.useFuzzy;\r\n }\r\n\r\n if (query.orderBy && typeof query.orderBy !== \"string\") {\r\n //@ts-ignore - orderby for some reason must be lowercase in v2.\r\n query.orderby = JSON.stringify(query.orderBy);\r\n delete query.orderBy;\r\n }\r\n\r\n //convert options to string if it's an object\r\n if (query.options && typeof query.options !== \"string\") {\r\n query.options = JSON.stringify(convertOptionKeysToLowerCase(query.options));\r\n }\r\n };\r\n\r\n version === \"1.0\" ? toV1(query) : toV2(query);\r\n}\r\n\r\nfunction convertOptionKeysToLowerCase(options: SearchOptions): SearchOptions {\r\n const newOptions: SearchOptions = {};\r\n\r\n for (const key in options) {\r\n newOptions[key.toLowerCase()] = options[key];\r\n }\r\n\r\n return newOptions;\r\n}\r\n\r\n//we need a reviver to change the keys of the search options to camel case\r\nfunction searchOptionsReviver(this: SearchOptions, key: string, value: any): any {\r\n switch (key) {\r\n case \"searchmode\":\r\n this.searchMode = value;\r\n break;\r\n case \"querytype\":\r\n this.queryType = value;\r\n break;\r\n default:\r\n return value;\r\n }\r\n}\r\n\r\nconst specialProperties = [\"orderBy\", \"facets\"];\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { QueryResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface QueryResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseQueryResponse(queryResponse: QueryResponseInternal, config: InternalApiConfig): QueryResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): QueryResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as QueryResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.facets = responseValue.Facets;\r\n toReturn.totalrecordcount = responseValue.Count;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): QueryResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: QueryResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Count: queryResponse.totalrecordcount,\r\n Value: queryResponse.value,\r\n Facets: queryResponse.facets,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { SuggestRequest, SuggestResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseSuggestResponse } from \"./responseParsers/parseSuggestResponse\";\r\n\r\nconst FUNCTION_NAME = \"suggest\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function suggest(request: string | SuggestRequest, client: IDataverseClient): Promise> {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseSuggestResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { SuggestResponse, SuggestResponseValue } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface SuggestResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseSuggestResponse(queryResponse: SuggestResponseInternal, config: InternalApiConfig): SuggestResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): SuggestResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as SuggestResponse[\"response\"];\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n responseValue.Value?.forEach((item: SuggestResponseValue) => {\r\n item.document = item.Document;\r\n item.text = item.Text;\r\n });\r\n }\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): SuggestResponse => {\r\n if (config.enableSearchApiResponseCompatibility) {\r\n queryResponse.value?.forEach((item: SuggestResponseValue) => {\r\n item.Document = item.document;\r\n item.Text = item.text;\r\n });\r\n }\r\n\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: SuggestResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { AutocompleteRequest, AutocompleteResponse } from \"../../dynamics-web-api\";\r\nimport { copyObject } from \"../../utils/Utility\";\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\nimport { convertSearchQuery } from \"./convertSearchQuery\";\r\nimport { parseAutocompleteResponse } from \"./responseParsers/parseAutocompleteResponse\";\r\n\r\nconst FUNCTION_NAME = \"autocomplete\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function autocomplete(request: string | AutocompleteRequest, client: IDataverseClient): Promise {\r\n ErrorHelper.parameterCheck(request, REQUEST_NAME, \"request\");\r\n\r\n const _isObject = typeof request !== \"string\";\r\n const parameterName = _isObject ? \"request.query.search\" : \"term\";\r\n const internalRequest: InternalRequest = _isObject ? copyObject(request) : { query: { search: request } };\r\n\r\n if (_isObject) ErrorHelper.parameterCheck(internalRequest.query, REQUEST_NAME, \"request.query\");\r\n ErrorHelper.stringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName);\r\n ErrorHelper.maxLengthStringParameterCheck(internalRequest.query.search, REQUEST_NAME, parameterName, 100);\r\n\r\n internalRequest.functionName = internalRequest.collection = FUNCTION_NAME;\r\n internalRequest.method = \"POST\";\r\n internalRequest.data = convertSearchQuery(internalRequest.query, FUNCTION_NAME, client.config.searchApi);\r\n internalRequest.apiConfig = client.config.searchApi;\r\n\r\n delete internalRequest.query;\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return parseAutocompleteResponse(response!.data, client.config.searchApi);\r\n}\r\n", "import { dateReviver } from \"../../../client/helpers\";\r\nimport type { AutocompleteResponse } from \"../../../dynamics-web-api\";\r\nimport type { InternalApiConfig } from \"../../../utils/Config\";\r\n\r\nexport interface AutocompleteResponseInternal extends Omit {\r\n response: string;\r\n}\r\n\r\nexport function parseAutocompleteResponse(queryResponse: AutocompleteResponseInternal, config: InternalApiConfig): AutocompleteResponse {\r\n if (!queryResponse) return queryResponse;\r\n\r\n const toV1 = (): AutocompleteResponse => {\r\n const responseValue = JSON.parse(queryResponse.response, dateReviver) as AutocompleteResponse[\"response\"];\r\n\r\n const toReturn = {\r\n ...queryResponse,\r\n response: responseValue,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.value = responseValue.Value;\r\n toReturn.querycontext = responseValue.QueryContext;\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n const toV2 = (): AutocompleteResponse => {\r\n // @ts-ignore we don't enforce to have all properties in the response if the compatibility is disabled\r\n const toReturn: AutocompleteResponse = {\r\n ...queryResponse,\r\n };\r\n\r\n if (config.enableSearchApiResponseCompatibility) {\r\n toReturn.response = {\r\n Value: queryResponse.value,\r\n QueryContext: queryResponse.querycontext,\r\n Error: null,\r\n };\r\n }\r\n\r\n return toReturn;\r\n };\r\n\r\n return config?.version === \"2.0\" ? toV1() : toV2();\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"getBackgroundOperationStatus\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function getBackgroundOperationStatus(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"GET\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n //todo: need to get rid of this parameter somehow\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "import type { IDataverseClient } from \"../../client/dataverse\";\r\nimport type { BackgroundOperationStatusResponse } from \"../../dynamics-web-api\";\r\n\r\nimport { ErrorHelper } from \"../../helpers/ErrorHelper\";\r\nimport { InternalRequest } from \"../../types\";\r\nimport { LIBRARY_NAME } from \"../constants\";\r\n\r\nconst FUNCTION_NAME = \"cancelBackgroundOperation\";\r\nconst REQUEST_NAME = `${LIBRARY_NAME}.${FUNCTION_NAME}`;\r\n\r\nexport async function cancelBackgroundOperation(backgroundOperationId: string, client: IDataverseClient): Promise {\r\n ErrorHelper.throwBatchIncompatible(REQUEST_NAME, client.isBatch);\r\n ErrorHelper.keyParameterCheck(backgroundOperationId, REQUEST_NAME, \"backgroundOperationId\");\r\n\r\n const internalRequest: InternalRequest = {\r\n method: \"DELETE\",\r\n addPath: `backgroundoperation/${backgroundOperationId}`,\r\n functionName: FUNCTION_NAME,\r\n apiConfig: client.config.serviceApi,\r\n includeDefaultDataverseHeaders: false,\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n },\r\n _isUnboundRequest: true,\r\n };\r\n\r\n const response = await client.makeRequest(internalRequest);\r\n return response?.data;\r\n}\r\n", "\uFEFFimport { DataverseClient, type IDataverseClient } from \"./client/dataverse\";\r\nimport { getCollectionName } from \"./client/RequestClient\";\r\nimport * as Dataverse from \"./requests\";\r\nimport { toAbsoluteUrl } from \"./utils/Utility\";\r\n\r\n/**\r\n * Microsoft Dataverse Web API helper library for Node.js and Browser.\r\n * It is compatible with: Dataverse, Dynamics 365 (online), Dynamics 365 (on-premise), Dynamics CRM 2016, Dynamics CRM Online.\r\n */\r\nexport class DynamicsWebApi {\r\n #client: IDataverseClient;\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 this.#client = new DataverseClient(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) => this.#client.setConfig(config);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\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 => Dataverse.create(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\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 => Dataverse.retrieve(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n update = async (request: UpdateRequest): Promise => Dataverse.update(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateSingleProperty = async (request: UpdateSinglePropertyRequest): Promise =>\r\n Dataverse.updateSingleProperty(request, this.#client);\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 => Dataverse.deleteRecord(request, this.#client);\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 * @template TData - Type of the data to be created.\r\n * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n upsert = async (request: UpsertRequest): Promise => Dataverse.upsert(request, this.#client);\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 => Dataverse.uploadFile(request, this.#client);\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 => Dataverse.downloadFile(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\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 Dataverse.retrieveMultiple(request, this.#client, nextPageLink);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAll = (request: RetrieveMultipleRequest): Promise> => Dataverse.retrieveAll(request, this.#client);\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.\r\n * 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 => Dataverse.count(request, this.#client);\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 => Dataverse.countAll(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetch = async (request: FetchXmlRequest): Promise> => Dataverse.fetchXml(request, this.#client);\r\n\r\n /**\r\n * Sends an asynchronous request to execute FetchXml to retrieve all records.\r\n *\r\n * @param request - An object that represents all possible options for a current request.\r\n * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n fetchAll = async (request: FetchAllRequest): Promise> => Dataverse.fetchXmlAll(request, this.#client);\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 => Dataverse.associate(request, this.#client);\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 => Dataverse.disassociate(request, this.#client);\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 => Dataverse.associateSingleValued(request, this.#client);\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 => Dataverse.disassociateSingleValued(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callFunction: CallFunction = async (request: string | BoundFunctionRequest | UnboundFunctionRequest): Promise =>\r\n Dataverse.callFunction(request, this.#client);\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 * @template TResponse - Type of the response to be returned.\r\n * @template TAction - Type of the action to be executed.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n callAction: CallAction = async (request: BoundActionRequest | UnboundActionRequest): Promise =>\r\n Dataverse.callAction(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createEntity = (request: CreateEntityRequest): Promise => Dataverse.createEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateEntity = (request: UpdateEntityRequest): Promise => Dataverse.updateEntity(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntity = (request: RetrieveEntityRequest): Promise => Dataverse.retrieveEntity(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveEntities = (request?: RetrieveEntitiesRequest): Promise> =>\r\n Dataverse.retrieveEntities(this.#client, request);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createAttribute = (request: CreateAttributeRequest): Promise => Dataverse.createAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateAttribute = (request: UpdateAttributeRequest): Promise => Dataverse.updateAttribute(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttributes = (request: RetrieveAttributesRequest): Promise> =>\r\n Dataverse.retrieveAttributes(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveAttribute = (request: RetrieveAttributeRequest): Promise => Dataverse.retrieveAttribute(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createRelationship = (request: CreateRelationshipRequest): Promise => Dataverse.createRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateRelationship = (request: UpdateRelationshipRequest): Promise => Dataverse.updateRelationship(request, this.#client);\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 => Dataverse.deleteRelationship(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationships = (request?: RetrieveRelationshipsRequest): Promise> =>\r\n Dataverse.retrieveRelationships(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveRelationship = (request: RetrieveRelationshipRequest): Promise => Dataverse.retrieveRelationship(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n createGlobalOptionSet = (request: CreateGlobalOptionSetRequest): Promise =>\r\n Dataverse.createGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n updateGlobalOptionSet = (request: UpdateGlobalOptionSetRequest): Promise =>\r\n Dataverse.updateGlobalOptionSet(request, this.#client);\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 => Dataverse.deleteGlobalOptionSet(request, this.#client);\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 * @template TResponse - Type of the metadata to be returned.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSet = (request: RetrieveGlobalOptionSetRequest): Promise =>\r\n Dataverse.retrieveGlobalOptionSet(request, this.#client);\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 * @template TValue - Type of the item returned in the \"value\" array.\r\n * @returns {Promise} D365 Web Api Response\r\n */\r\n retrieveGlobalOptionSets = (request?: RetrieveGlobalOptionSetsRequest): Promise> =>\r\n Dataverse.retrieveGlobalOptionSets(request, this.#client);\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 => Dataverse.retrieveCsdlMetadata(request, this.#client);\r\n\r\n /**\r\n * @deprecated Use \"query\" instead.\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 //@ts-ignore Ignoring the type error issue, because SearchFunction is deprecated and it will return what needs to return with a conversion.\r\n Dataverse.query(request, this.#client);\r\n\r\n /**\r\n * The query operation returns search results based on a search term.\r\n * @param request - An object that represents all possible options for a current request.\r\n * @returns {Promise} Query result.\r\n */\r\n query: QueryFunction = async (request: string | QueryRequest): Promise => Dataverse.query(request, this.#client);\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 Dataverse.suggest(request, this.#client);\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 an autocomplete.\r\n */\r\n autocomplete: AutocompleteFunction = async (request: string | AutocompleteRequest): Promise =>\r\n Dataverse.autocomplete(request, this.#client);\r\n\r\n /**\r\n * Sends a request to the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n getBackgroundOperationStatus = async (backgroundOperationId: string): Promise =>\r\n Dataverse.getBackgroundOperationStatus(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Cancels a background operation via the status monitor resource.\r\n * @param backgroundOperationId - The ID of the background operation.\r\n * @returns {Promise} Background operation status.\r\n */\r\n cancelBackgroundOperation = async (backgroundOperationId: string): Promise =>\r\n Dataverse.cancelBackgroundOperation(backgroundOperationId, this.#client);\r\n\r\n /**\r\n * Starts a batch request.\r\n */\r\n startBatch = (): void => Dataverse.startBatch(this.#client);\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 => Dataverse.executeBatch(request, this.#client);\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.#client.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 => getCollectionName(entityName),\r\n\r\n /**\r\n * Adds an absolute Web API URL to the beginning of a provided value.\r\n * @param value The value to modify.\r\n * @returns The absolute URL.\r\n */\r\n toAbsoluteUrl: (value: string): string => toAbsoluteUrl(this.#client,value),\r\n };\r\n}\r\n\r\n//have to put all types in here, so it is possible to export just a single d.ts file (there are no good solutions to automatically bundle all dts files currently)\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.\r\n * 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.\r\n * 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 /**\r\n * Custom query parameters. Can be used to set parameter aliases for \"$filter\" and \"$orderBy\".\r\n * Important! These parameters ARE NOT URI encoded! */\r\n queryParams?: string[];\r\n /**\r\n * Use this parameter to include a shared variable value that is accessible within a plug-in.\r\n */\r\n tag?: 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 /**\r\n * A String representing collection record's Primary Key (GUID) or Alternate Key(s).\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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}\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?: TData;\r\n /**An array of Expand Objects representing the $expand OData System Query Option value to control which related records are also returned. Can also accept a string. */\r\n expand?: string | 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 CreateWithRepresentationRequest extends Omit, \"returnRepresentation\"> {\r\n returnRepresentation: true;\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 /**\r\n * Field name that needs to be cleared (for example File Field)\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n /**Single property that needs to be cleared (including the File property) */\r\n property?: string;\r\n}\r\n\r\nexport interface RetrieveRequest extends CRUDRequest {\r\n /**A name of the Entity Collection or Entity Logical name. */\r\n collection: 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 /**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 /**A name of the Entity Collection or Entity Logical name. */\r\n collection: string;\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 /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Relationship name. */\r\n relationshipName: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 AssociateSingleValuedRequest extends Request {\r\n /**\r\n * Primary entity record id/key.\r\n * Can be ommitted in a Batch request when contentId is set.\r\n */\r\n primaryKey?: string;\r\n /**Navigation property name. */\r\n navigationProperty: string;\r\n /**\r\n * Related name of the Entity Collection or Entity Logical name.\r\n * Can be omitted in a Batch request when relatedKey is set to a ContentId.\r\n */\r\n relatedCollection?: string;\r\n /**Related entity record id/key or a ContentId in a Batch request (e.g. $2). */\r\n relatedKey: string;\r\n /**v2.3.1+ 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 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 /**\r\n * Name of the function.\r\n */\r\n name?: string;\r\n /**\r\n * Name of the function.\r\n * @deprecated Use \"name\" parameter.\r\n */\r\n functionName?: string;\r\n /**Function's input parameters. Example: { param1: \"test\", param2: 3 }. */\r\n parameters?: any;\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}\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 * A callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Use background operations to send requests that Dataverse processes asynchronously.\r\n * Background operations are useful when you don't want to maintain a connection while a request runs.\r\n */\r\n respondAsync?: boolean;\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 /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\r\n fieldName?: string;\r\n}\r\n\r\nexport interface DownloadRequest extends CRUDRequest {\r\n /**The name of File Column (field) */\r\n property?: string;\r\n /**\r\n * File Field Name\r\n * @deprecated Use \"property\".\r\n */\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 BackgroundOperationResponse = {\r\n /**\r\n * Location URL of the background operation.\r\n */\r\n location: string;\r\n /**\r\n * The ID of the background operation.\r\n */\r\n backgroundOperationId: string;\r\n};\r\n\r\nexport type SearchMode = \"any\" | \"all\";\r\nexport type SearchType = \"simple\" | \"full\";\r\n\r\nexport type SearchEntity = {\r\n /**Logical name of the table. Specifies scope of the query. */\r\n name: string;\r\n /**List of columns that needs to be projected when table documents are returned in response. If empty, only the table primary name is returned. */\r\n selectColumns?: string[];\r\n /**List of columns to scope the query on. If empty, only the table primary name is searched on.*/\r\n searchColumns?: string[];\r\n /**Filters applied on the entity.*/\r\n filter?: string;\r\n};\r\n\r\nexport type SearchOptions = Record & {\r\n /**Values can be simple or lucene. */\r\n queryType?: \"simple\" | \"lucene\";\r\n /**Enables intelligent query workflow to return probable set of results if no good matches are found for the search request terms.*/\r\n bestEffortSearchEnabled?: boolean;\r\n /**Enable ranking of results in the response optimized for display in search results pages where results are grouped by table.*/\r\n searchMode?: SearchMode;\r\n /**When specified as all the search terms must be matched in order to consider the document as a match. Setting its value to any defaults to matching any word in the search term.*/\r\n groupRankingEnabled?: boolean;\r\n};\r\n\r\nexport type SuggestOptions = Record & {\r\n /**Enables advanced suggestions for the search query. The default is false. */\r\n advancedSuggestEnabled?: boolean;\r\n};\r\n\r\nexport interface SearchQueryBase {\r\n /**The text to search with. It has a 100-character limit. For suggestions, min 3 characters in addition. */\r\n search: string;\r\n /**Limits the scope of search to a subset of tables. The default set is configured by your administrator when Dataverse search is enabled. */\r\n entities?: string[] | SearchEntity[] | string;\r\n /**Limits the scope of the search results returned. */\r\n filter?: string;\r\n}\r\n\r\nexport interface Query extends SearchQueryBase {\r\n /**V2. Specify true to return the total record count; otherwise false. The default is false. */\r\n count?: boolean;\r\n /**Facets support the ability to drill down into data results after they've been retrieved. */\r\n facets?: string | string[];\r\n /**\r\n * V1. Specify true to return the total record count; otherwise false. The default is false.\r\n * @deprecated Use \"count\".\r\n */\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 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 | string[];\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SearchOptions;\r\n /**\r\n * V1. Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.\r\n * @deprecated Use \"options.searchmode\".\r\n */\r\n searchMode?: SearchMode;\r\n /**\r\n * V1. 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 * @deprecated Use \"options.querytype\".\r\n */\r\n searchType?: SearchType;\r\n}\r\n\r\n/**@deprecated Use Query instead */\r\nexport interface Search extends Query {}\r\n\r\nexport interface Suggest extends SearchQueryBase {\r\n /**Use fuzzy search to aid with misspellings. The default is false. */\r\n fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n /**V2. Options are settings configured to search a search term. */\r\n options?: string | SuggestOptions;\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 | 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 fuzzy?: boolean;\r\n /**\r\n * Use fuzzy search to aid with misspellings. The default is false.\r\n * @deprecated Use \"fuzzy\".\r\n */\r\n useFuzzy?: boolean;\r\n}\r\n\r\nexport interface QueryRequest extends BaseRequest {\r\n /**Search query object */\r\n query: Query;\r\n}\r\n\r\n/**@deprecated Use QueryRequest instead. */\r\nexport interface SearchRequest extends QueryRequest {}\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 type SearchApiOptions = {\r\n /**\r\n * Escapes the search string.\r\n * Special characters that require escaping include the following: + - & | ! ( ) { } [ ] ^ \" ~ * ? : \\ /.\r\n */\r\n escapeSpecialCharacters?: boolean;\r\n /**\r\n * Enables compatibility of the responses between v1 and v2.\r\n * Only enable this option temporarily, because it will force all response properties to be duplicated to achieve a full compatibility.\r\n */\r\n enableResponseCompatibility?: boolean;\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 /** Specific API options. Currently it is only available for the Search API .*/\r\n options?: TOptions;\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 * A default callback URL when the background operation is completed.\r\n * Dataverse uses this URL to send a POST request.\r\n * You can also set a callback URL per request.\r\n */\r\n backgroundOperationCallbackUrl?: string;\r\n /**\r\n * Disables enforcement of absolute URLs for @odata.id properties in the request body.\r\n * In some cases, @odata.id has an alternate key format that does not use absolute URLs, for example:\r\n * In an UpsertMultiple action body.\r\n */\r\n disableODataIdAbsoluteUrl?: boolean;\r\n}\r\n\r\n/**Header collection type */\r\nexport type HeaderCollection = Record;\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: TValue[];\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\n/**@deprecated Use QueryResponse instead */\r\nexport interface SearchResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: TValue[];\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n * @deprecated Use \"response.Facets\" instead.\r\n */\r\n facets: any | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n * @deprecated Use \"response.Count\" instead.\r\n */\r\n totalrecordcount: number;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n}\r\n\r\nexport interface QueryResponse extends SearchResponse {\r\n /** Query response */\r\n response: {\r\n /**\r\n * A collection of matching records.\r\n */\r\n Value: SearchQueryResult[];\r\n /**\r\n * Provides error information from Azure Cognitive search.\r\n */\r\n Error: SearchErrorDetail | null;\r\n /**\r\n * If facets were requested in the query, a dictionary of facet values.\r\n */\r\n Facets: Record | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n /**\r\n * If \"Count\": true is included in the body of the request, the count of all documents that match the search, ignoring top and skip.\r\n */\r\n Count: number;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface SuggestResponse {\r\n /**\r\n * A collection of matching records.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: SuggestResponseValue[];\r\n /**\r\n * Suggestions query context\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Suggestion response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** A collection of matching records. */\r\n Value: SuggestResponseValue[];\r\n /**\r\n * The query context returned as part of response. This property is used for backend search.\r\n * It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\r\n}\r\n\r\nexport interface AutocompleteResponse {\r\n /**\r\n * Autocomplete text result.\r\n * @deprecated Use \"response.Value\" instead.\r\n */\r\n value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n * @deprecated Use \"response.QueryContext\" instead.\r\n */\r\n querycontext: any | null;\r\n /** Autocomplete response. */\r\n response: {\r\n /** Provides error information from Azure Cognitive search. */\r\n Error: SearchErrorDetail | null;\r\n /** Autocomplete text result. */\r\n Value: string | null;\r\n /**\r\n * This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\n QueryContext: SearchQueryContext | null;\r\n };\r\n \"@odata.context\": string;\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\n/**@deprecated Use \"QueryFunction\" instead */\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: QueryRequest): Promise>;\r\n};\r\n\r\ntype QueryFunction = {\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: QueryRequest): 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\r\n/**\r\n * The Azure Cognitive search error returned as part of the response.\r\n */\r\nexport type SearchErrorDetail = {\r\n /**\r\n * The error code.\r\n */\r\n code: string;\r\n /**\r\n * The error message.\r\n */\r\n message: string;\r\n /**\r\n * More error information.\r\n */\r\n propertybag: Record;\r\n};\r\n\r\n/**\r\n * A facet query result that reports the number of documents with a field falling within a particular range or having a particular value or interval.\r\n */\r\nexport type SearchFacetResult = {\r\n /**\r\n * The count of documents falling within the bucket described by this facet.\r\n */\r\n count?: number;\r\n /**\r\n * Value indicating the inclusive lower bound of the facet's range, or null to indicate that there's no lower bound.\r\n */\r\n from: any;\r\n /**\r\n * Value indicating the exclusive upper bound of the facet's range, or null to indicate that there's no upper bound.\r\n */\r\n to: any;\r\n /**\r\n * Type of the facet.\r\n */\r\n type: \"Value\" | \"Range\";\r\n /**\r\n * Value of the facet, or the inclusive lower bound if it's an interval facet.\r\n */\r\n value: any;\r\n /**\r\n * Another or optional value of the facet, populated while faceting on lookups.\r\n */\r\n optionalvalue: any;\r\n};\r\n\r\n/**\r\n * The query context returned as part of response. This property is used for backend search. It's included for future feature releases and isn't currently used.\r\n */\r\nexport type SearchQueryContext = {\r\n /** The query string as specified in the request. */\r\n originalquery: string;\r\n /**\r\n * The query string that Dataverse search used to perform the query. Dataverse search uses the altered query string\r\n * if the original query string contained spelling mistakes or didn't yield optimal results.\r\n */\r\n alteredquery: string;\r\n /** The reasons behind query alter decision by Dataverse search. */\r\n reason: string[];\r\n /** The spell suggestion that is the likely words that represent user's intent. Populated only when Dataverse alters the query search due to spell check. */\r\n spellsuggestions: string[];\r\n};\r\n\r\n/**\r\n * Represents a record in Dataverse.\r\n */\r\nexport type SearchQueryResult = {\r\n /**\r\n * The identifier of the record.\r\n */\r\n Id: string;\r\n /**\r\n * The logical name of the table.\r\n */\r\n EntityName: string;\r\n /**\r\n * The object type code.\r\n */\r\n ObjectTypeCode: number;\r\n /**\r\n * Record attributes\r\n */\r\n Attributes: Record;\r\n /**\r\n * The highlights.\r\n */\r\n Highlights: Record;\r\n /**\r\n * The document score.\r\n */\r\n Score: number;\r\n};\r\n\r\nexport interface SuggestResponseValue {\r\n /**\r\n * Provides the suggested text.\r\n * @deprecated Use \"Text\" instead.\r\n */\r\n text: string;\r\n /**\r\n * Provides the suggested text.\r\n */\r\n Text: string;\r\n /**\r\n * The document.\r\n * @deprecated Use \"Document\" instead.\r\n */\r\n document: TDocument;\r\n /**\r\n * The document.\r\n */\r\n Document: TDocument;\r\n}\r\n\r\nexport type BackgroundOperationStatusResponse = Record & {\r\n /**\r\n * Background operation error code.\r\n */\r\n backgroundOperationErrorCode?: number;\r\n /**\r\n * Background operation error message.\r\n */\r\n backgroundOperationErrorMessage?: string;\r\n /**\r\n * Background operation state code.\r\n */\r\n backgroundOperationStateCode: number;\r\n /**\r\n * Background operation status code.\r\n */\r\n backgroundOperationStatusCode: number;\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,QAAsB,OAAO,OAAO,SAAe,0CAAyB,UAAU;AACjG;AAFA;AAAA;AAAA;AAAA;AAAA;;;ACWO,SAAS,OAAO,OAAwB;AAC3C,QAAM,QAAQ,WAAW,KAAK,KAAK;AACnC,SAAO,CAAC,CAAC;AACb;AAEO,SAAS,YA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AAA,MAEhC,MAAM,SAAS,mBAAK,QAAO;AAAA;AAOzC;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAuB,OAAO,YAAqE,MAAM,SAAS,mBAAK,QAAO;AAO9H;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B,OAA6B,YAC1C,QAAQ,SAAS,mBAAK,QAAO;AAO3C;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqC,OAAO,YAC9B,aAAa,SAAS,mBAAK,QAAO;AAOhD;AAAA;AAAA;AAAA;AAAA;AAAA,wCAA+B,OAAO,0BACxB,6BAA6B,uBAAuB,mBAAK,QAAO;AAO9E;AAAA;AAAA;AAAA;AAAA;AAAA,qCAA4B,OAAO,0BACrB,0BAA0B,uBAAuB,mBAAK,QAAO;AAK3E;AAAA;AAAA;AAAA,sBAAa,MAAsB,WAAW,mBAAK,QAAO;AAO1D;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe,OAAO,YAAqD,aAAa,SAAS,mBAAK,QAAO;AAQ7G;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAqB,CAAC,WAAoC,IAAI,gBAAe,UAAU,mBAAK,SAAQ,MAAM;AAE1G,mBAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQN,mBAAmB,CAAC,eAAsC,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOtF,eAAe,CAAC,UAA0B,cAAc,mBAAK,UAAQ,KAAK;AAAA,IAC9E;AAzdI,uBAAK,SAAU,IAAI,gBAAgB,MAAM;AAAA,EAC7C;AAydJ;AAjeI;AADG,IAAM,iBAAN;", "names": ["getCrypto", "getCrypto", "count", "_a", "_a", "_a", "executeRequest", "_a", "_b", "_a", "_b", "headers", "batchBody", "_a", "_a", "executeRequest", "FUNCTION_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "request", "isObject", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "_a", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "_a", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "query", "_a", "FUNCTION_NAME", "REQUEST_NAME", "_a", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME", "FUNCTION_NAME", "REQUEST_NAME"] } diff --git a/package-lock.json b/package-lock.json index 1934d84..c249915 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dynamics-web-api", - "version": "2.3.2", + "version": "2.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dynamics-web-api", - "version": "2.3.2", + "version": "2.4.0", "license": "MIT", "dependencies": { "http-proxy-agent": "^4.0.1", @@ -16,23 +16,23 @@ "@types/chai": "^4.3.20", "@types/mocha": "^10.0.10", "@types/node": "^20.16.5", - "@types/sinon": "^10.0.20", - "@types/xrm": "^9.0.82", + "@types/sinon": "^17.0.4", + "@types/xrm": "^9.0.87", "Base64": "^1.3.0", "chai": "^4.5.0", "copyfiles": "^2.4.1", - "esbuild": "^0.25.0", - "glob": "^11.0.1", - "mocha": "^11.1.0", + "esbuild": "^0.25.11", + "glob": "^11.0.3", + "mocha": "^11.7.4", "mocha-lcov-reporter": "^1.3.0", - "nock": "^14.0.1", + "nock": "^14.0.10", "npm-run-all": "^4.1.5", "nyc": "^17.1.0", - "prettier": "^3.5.1", + "prettier": "^3.6.2", "rimraf": "^6.0.1", - "sinon": "^19.0.2", + "sinon": "^19.0.5", "ts-node": "^10.9.2", - "typescript": "^5.7.3" + "typescript": "^5.9.3" } }, "node_modules/@ampproject/remapping": { @@ -50,15 +50,15 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.26.2", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", - "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.25.9", + "@babel/helper-validator-identifier": "^7.27.1", "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" + "picocolors": "^1.1.1" }, "engines": { "node": ">=6.9.0" @@ -199,9 +199,9 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", - "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", "dev": true, "license": "MIT", "engines": { @@ -209,9 +209,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", - "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", "dev": true, "license": "MIT", "engines": { @@ -229,27 +229,27 @@ } }, "node_modules/@babel/helpers": { - "version": "7.26.9", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.9.tgz", - "integrity": "sha512-Mz/4+y8udxBKdmzt/UjPACs4G3j5SshJJEFFKxlCGPydG4JAHXxjWjAwjd09tf6oINvl1VfMJo+nB7H2YKQ0dA==", + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.4.tgz", + "integrity": "sha512-HFN59MmQXGHVyYadKLVumYsA9dBFun/ldYxipEjzA4196jpLZd8UjEEBLkbEkvfYreDqJhZxYAWFPtrfhNpj4w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/template": "^7.26.9", - "@babel/types": "^7.26.9" + "@babel/template": "^7.27.2", + "@babel/types": "^7.28.4" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.26.9", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.9.tgz", - "integrity": "sha512-81NWa1njQblgZbQHxWHpxxCzNsa3ZwvFqpUg7P+NNUU6f3UU2jBEg4OlF/J6rl8+PQGh1q6/zWScd001YwcA5A==", + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.5.tgz", + "integrity": "sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.26.9" + "@babel/types": "^7.28.5" }, "bin": { "parser": "bin/babel-parser.js" @@ -259,15 +259,15 @@ } }, "node_modules/@babel/template": { - "version": "7.26.9", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.26.9.tgz", - "integrity": "sha512-qyRplbeIpNZhmzOysF/wFMuP9sctmh2cFzRAZOn1YapxBsE1i9bJIY586R/WBLfLcmcBlM8ROBiQURnnNy+zfA==", + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", + "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.26.2", - "@babel/parser": "^7.26.9", - "@babel/types": "^7.26.9" + "@babel/code-frame": "^7.27.1", + "@babel/parser": "^7.27.2", + "@babel/types": "^7.27.1" }, "engines": { "node": ">=6.9.0" @@ -293,14 +293,14 @@ } }, "node_modules/@babel/types": { - "version": "7.26.9", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.9.tgz", - "integrity": "sha512-Y3IR1cRnOxOCDvMmNiym7XpXQ93iGDDPHx+Zj+NM+rg0fBaShfQLkg+hKPaZCEvg5N/LeCo4+Rj/i3FuJsIQaw==", + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.5.tgz", + "integrity": "sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.25.9", - "@babel/helper-validator-identifier": "^7.25.9" + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" }, "engines": { "node": ">=6.9.0" @@ -331,9 +331,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.0.tgz", - "integrity": "sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.11.tgz", + "integrity": "sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg==", "cpu": [ "ppc64" ], @@ -348,9 +348,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.0.tgz", - "integrity": "sha512-PTyWCYYiU0+1eJKmw21lWtC+d08JDZPQ5g+kFyxP0V+es6VPPSUhM6zk8iImp2jbV6GwjX4pap0JFbUQN65X1g==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.11.tgz", + "integrity": "sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==", "cpu": [ "arm" ], @@ -365,9 +365,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.0.tgz", - "integrity": "sha512-grvv8WncGjDSyUBjN9yHXNt+cq0snxXbDxy5pJtzMKGmmpPxeAmAhWxXI+01lU5rwZomDgD3kJwulEnhTRUd6g==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.11.tgz", + "integrity": "sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==", "cpu": [ "arm64" ], @@ -382,9 +382,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.0.tgz", - "integrity": "sha512-m/ix7SfKG5buCnxasr52+LI78SQ+wgdENi9CqyCXwjVR2X4Jkz+BpC3le3AoBPYTC9NHklwngVXvbJ9/Akhrfg==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.11.tgz", + "integrity": "sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==", "cpu": [ "x64" ], @@ -399,9 +399,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.0.tgz", - "integrity": "sha512-mVwdUb5SRkPayVadIOI78K7aAnPamoeFR2bT5nszFUZ9P8UpK4ratOdYbZZXYSqPKMHfS1wdHCJk1P1EZpRdvw==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.11.tgz", + "integrity": "sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==", "cpu": [ "arm64" ], @@ -416,9 +416,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.0.tgz", - "integrity": "sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.11.tgz", + "integrity": "sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==", "cpu": [ "x64" ], @@ -433,9 +433,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.0.tgz", - "integrity": "sha512-VN4ocxy6dxefN1MepBx/iD1dH5K8qNtNe227I0mnTRjry8tj5MRk4zprLEdG8WPyAPb93/e4pSgi1SoHdgOa4w==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.11.tgz", + "integrity": "sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==", "cpu": [ "arm64" ], @@ -450,9 +450,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.0.tgz", - "integrity": "sha512-mrSgt7lCh07FY+hDD1TxiTyIHyttn6vnjesnPoVDNmDfOmggTLXRv8Id5fNZey1gl/V2dyVK1VXXqVsQIiAk+A==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.11.tgz", + "integrity": "sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==", "cpu": [ "x64" ], @@ -467,9 +467,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.0.tgz", - "integrity": "sha512-vkB3IYj2IDo3g9xX7HqhPYxVkNQe8qTK55fraQyTzTX/fxaDtXiEnavv9geOsonh2Fd2RMB+i5cbhu2zMNWJwg==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.11.tgz", + "integrity": "sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==", "cpu": [ "arm" ], @@ -484,9 +484,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.0.tgz", - "integrity": "sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.11.tgz", + "integrity": "sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==", "cpu": [ "arm64" ], @@ -501,9 +501,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.0.tgz", - "integrity": "sha512-43ET5bHbphBegyeqLb7I1eYn2P/JYGNmzzdidq/w0T8E2SsYL1U6un2NFROFRg1JZLTzdCoRomg8Rvf9M6W6Gg==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.11.tgz", + "integrity": "sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==", "cpu": [ "ia32" ], @@ -518,9 +518,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.0.tgz", - "integrity": "sha512-fC95c/xyNFueMhClxJmeRIj2yrSMdDfmqJnyOY4ZqsALkDrrKJfIg5NTMSzVBr5YW1jf+l7/cndBfP3MSDpoHw==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.11.tgz", + "integrity": "sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==", "cpu": [ "loong64" ], @@ -535,9 +535,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.0.tgz", - "integrity": "sha512-nkAMFju7KDW73T1DdH7glcyIptm95a7Le8irTQNO/qtkoyypZAnjchQgooFUDQhNAy4iu08N79W4T4pMBwhPwQ==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.11.tgz", + "integrity": "sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==", "cpu": [ "mips64el" ], @@ -552,9 +552,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.0.tgz", - "integrity": "sha512-NhyOejdhRGS8Iwv+KKR2zTq2PpysF9XqY+Zk77vQHqNbo/PwZCzB5/h7VGuREZm1fixhs4Q/qWRSi5zmAiO4Fw==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.11.tgz", + "integrity": "sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==", "cpu": [ "ppc64" ], @@ -569,9 +569,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.0.tgz", - "integrity": "sha512-5S/rbP5OY+GHLC5qXp1y/Mx//e92L1YDqkiBbO9TQOvuFXM+iDqUNG5XopAnXoRH3FjIUDkeGcY1cgNvnXp/kA==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.11.tgz", + "integrity": "sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==", "cpu": [ "riscv64" ], @@ -586,9 +586,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.0.tgz", - "integrity": "sha512-XM2BFsEBz0Fw37V0zU4CXfcfuACMrppsMFKdYY2WuTS3yi8O1nFOhil/xhKTmE1nPmVyvQJjJivgDT+xh8pXJA==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.11.tgz", + "integrity": "sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==", "cpu": [ "s390x" ], @@ -603,9 +603,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.0.tgz", - "integrity": "sha512-9yl91rHw/cpwMCNytUDxwj2XjFpxML0y9HAOH9pNVQDpQrBxHy01Dx+vaMu0N1CKa/RzBD2hB4u//nfc+Sd3Cw==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.11.tgz", + "integrity": "sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==", "cpu": [ "x64" ], @@ -620,9 +620,9 @@ } }, "node_modules/@esbuild/netbsd-arm64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.0.tgz", - "integrity": "sha512-RuG4PSMPFfrkH6UwCAqBzauBWTygTvb1nxWasEJooGSJ/NwRw7b2HOwyRTQIU97Hq37l3npXoZGYMy3b3xYvPw==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.11.tgz", + "integrity": "sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==", "cpu": [ "arm64" ], @@ -637,9 +637,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.0.tgz", - "integrity": "sha512-jl+qisSB5jk01N5f7sPCsBENCOlPiS/xptD5yxOx2oqQfyourJwIKLRA2yqWdifj3owQZCL2sn6o08dBzZGQzA==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.11.tgz", + "integrity": "sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==", "cpu": [ "x64" ], @@ -654,9 +654,9 @@ } }, "node_modules/@esbuild/openbsd-arm64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.0.tgz", - "integrity": "sha512-21sUNbq2r84YE+SJDfaQRvdgznTD8Xc0oc3p3iW/a1EVWeNj/SdUCbm5U0itZPQYRuRTW20fPMWMpcrciH2EJw==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.11.tgz", + "integrity": "sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==", "cpu": [ "arm64" ], @@ -671,9 +671,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.0.tgz", - "integrity": "sha512-2gwwriSMPcCFRlPlKx3zLQhfN/2WjJ2NSlg5TKLQOJdV0mSxIcYNTMhk3H3ulL/cak+Xj0lY1Ym9ysDV1igceg==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.11.tgz", + "integrity": "sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==", "cpu": [ "x64" ], @@ -687,10 +687,27 @@ "node": ">=18" } }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.11.tgz", + "integrity": "sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/sunos-x64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.0.tgz", - "integrity": "sha512-bxI7ThgLzPrPz484/S9jLlvUAHYMzy6I0XiU1ZMeAEOBcS0VePBFxh1JjTQt3Xiat5b6Oh4x7UC7IwKQKIJRIg==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.11.tgz", + "integrity": "sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==", "cpu": [ "x64" ], @@ -705,9 +722,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.0.tgz", - "integrity": "sha512-ZUAc2YK6JW89xTbXvftxdnYy3m4iHIkDtK3CLce8wg8M2L+YZhIvO1DKpxrd0Yr59AeNNkTiic9YLf6FTtXWMw==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.11.tgz", + "integrity": "sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==", "cpu": [ "arm64" ], @@ -722,9 +739,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.0.tgz", - "integrity": "sha512-eSNxISBu8XweVEWG31/JzjkIGbGIJN/TrRoiSVZwZ6pkC6VX4Im/WV2cz559/TXLcYbcrDN8JtKgd9DJVIo8GA==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.11.tgz", + "integrity": "sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==", "cpu": [ "ia32" ], @@ -739,9 +756,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.0.tgz", - "integrity": "sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.11.tgz", + "integrity": "sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==", "cpu": [ "x64" ], @@ -755,6 +772,29 @@ "node": ">=18" } }, + "node_modules/@isaacs/balanced-match": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", + "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@isaacs/brace-expansion": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", + "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@isaacs/balanced-match": "^4.0.1" + }, + "engines": { + "node": "20 || >=22" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -934,9 +974,9 @@ } }, "node_modules/@mswjs/interceptors": { - "version": "0.37.6", - "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.37.6.tgz", - "integrity": "sha512-wK+5pLK5XFmgtH3aQ2YVvA3HohS3xqV/OxuVOdNx9Wpnz7VE/fnC+e1A7ln6LFYeck7gOJ/dsZV6OLplOtAJ2w==", + "version": "0.39.8", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.39.8.tgz", + "integrity": "sha512-2+BzZbjRO7Ct61k8fMNHEtoKjeWI9pIlHFTqBwZ5icHpqszIgEZbjb1MW5Z0+bITTCTl3gk4PDBxs9tA/csXvA==", "dev": true, "license": "MIT", "dependencies": { @@ -1008,14 +1048,13 @@ } }, "node_modules/@sinonjs/samsam": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-8.0.2.tgz", - "integrity": "sha512-v46t/fwnhejRSFTGqbpn9u+LQ9xJDse10gNnPgAcxgdoCDMXj/G2asWAC/8Qs+BAZDicX+MNZouXT1A7c83kVw==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-8.0.3.tgz", + "integrity": "sha512-hw6HbX+GyVZzmaYNh82Ecj1vdGZrqVIn/keDTg63IgAwiQPO+xCz99uG6Woqgb4tM0mUiFENKZ4cqd7IX94AXQ==", "dev": true, "license": "BSD-3-Clause", "dependencies": { "@sinonjs/commons": "^3.0.1", - "lodash.get": "^4.4.2", "type-detect": "^4.1.0" } }, @@ -1098,9 +1137,9 @@ } }, "node_modules/@types/sinon": { - "version": "10.0.20", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.20.tgz", - "integrity": "sha512-2APKKruFNCAZgx3daAyACGzWuJ028VVCUDk6o2rw/Z4PXT0ogwdV4KUegW0MwVs0Zu59auPXbbuBJHF12Sx1Eg==", + "version": "17.0.4", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-17.0.4.tgz", + "integrity": "sha512-RHnIrhfPO3+tJT0s7cFaXGZvsL4bbR3/k7z3P312qMS4JaS2Tk+KiwiLx1S0rQ56ERj00u1/BtdyVd0FY+Pdew==", "dev": true, "license": "MIT", "dependencies": { @@ -1115,9 +1154,9 @@ "license": "MIT" }, "node_modules/@types/xrm": { - "version": "9.0.83", - "resolved": "https://registry.npmjs.org/@types/xrm/-/xrm-9.0.83.tgz", - "integrity": "sha512-TCwHYbw2lYfzWSzPOQNF3a/NoIE35xzfMSKqM6W8wQisVfuC9xMHQW9u7GWG0ogCk1YQ/tAdjIvSeQf80MJ5BA==", + "version": "9.0.87", + "resolved": "https://registry.npmjs.org/@types/xrm/-/xrm-9.0.87.tgz", + "integrity": "sha512-5CQ16PpBH/8G6Ewxox1KGsshGZG/uvNiV3y0VjYVwayE3oYudEe3NUujL2dNKA1WDRus3i1tLRYqsDd0w++Evw==", "dev": true, "license": "MIT" }, @@ -1173,16 +1212,6 @@ "node": ">=8" } }, - "node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/ansi-regex": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", @@ -1212,20 +1241,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "license": "ISC", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/append-transform": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", @@ -1349,23 +1364,10 @@ "dev": true, "license": "(Apache-2.0 OR WTFPL)" }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "license": "MIT", "dependencies": { @@ -1373,19 +1375,6 @@ "concat-map": "0.0.1" } }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "license": "MIT", - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -1596,28 +1585,19 @@ } }, "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", "dev": true, "license": "MIT", "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" + "readdirp": "^4.0.1" }, "engines": { - "node": ">= 8.10.0" + "node": ">= 14.16.0" }, "funding": { "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" } }, "node_modules/clean-stack": { @@ -1964,9 +1944,9 @@ } }, "node_modules/diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", + "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", "dev": true, "license": "BSD-3-Clause", "engines": { @@ -2160,9 +2140,9 @@ "license": "MIT" }, "node_modules/esbuild": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.0.tgz", - "integrity": "sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw==", + "version": "0.25.11", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.11.tgz", + "integrity": "sha512-KohQwyzrKTQmhXDW1PjCv3Tyspn9n5GcY2RTDqeORIdIJY8yKIF7sTSopFmn/wpMPW4rdPXI0UE5LJLuq3bx0Q==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -2173,31 +2153,32 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.25.0", - "@esbuild/android-arm": "0.25.0", - "@esbuild/android-arm64": "0.25.0", - "@esbuild/android-x64": "0.25.0", - "@esbuild/darwin-arm64": "0.25.0", - "@esbuild/darwin-x64": "0.25.0", - "@esbuild/freebsd-arm64": "0.25.0", - "@esbuild/freebsd-x64": "0.25.0", - "@esbuild/linux-arm": "0.25.0", - "@esbuild/linux-arm64": "0.25.0", - "@esbuild/linux-ia32": "0.25.0", - "@esbuild/linux-loong64": "0.25.0", - "@esbuild/linux-mips64el": "0.25.0", - "@esbuild/linux-ppc64": "0.25.0", - "@esbuild/linux-riscv64": "0.25.0", - "@esbuild/linux-s390x": "0.25.0", - "@esbuild/linux-x64": "0.25.0", - "@esbuild/netbsd-arm64": "0.25.0", - "@esbuild/netbsd-x64": "0.25.0", - "@esbuild/openbsd-arm64": "0.25.0", - "@esbuild/openbsd-x64": "0.25.0", - "@esbuild/sunos-x64": "0.25.0", - "@esbuild/win32-arm64": "0.25.0", - "@esbuild/win32-ia32": "0.25.0", - "@esbuild/win32-x64": "0.25.0" + "@esbuild/aix-ppc64": "0.25.11", + "@esbuild/android-arm": "0.25.11", + "@esbuild/android-arm64": "0.25.11", + "@esbuild/android-x64": "0.25.11", + "@esbuild/darwin-arm64": "0.25.11", + "@esbuild/darwin-x64": "0.25.11", + "@esbuild/freebsd-arm64": "0.25.11", + "@esbuild/freebsd-x64": "0.25.11", + "@esbuild/linux-arm": "0.25.11", + "@esbuild/linux-arm64": "0.25.11", + "@esbuild/linux-ia32": "0.25.11", + "@esbuild/linux-loong64": "0.25.11", + "@esbuild/linux-mips64el": "0.25.11", + "@esbuild/linux-ppc64": "0.25.11", + "@esbuild/linux-riscv64": "0.25.11", + "@esbuild/linux-s390x": "0.25.11", + "@esbuild/linux-x64": "0.25.11", + "@esbuild/netbsd-arm64": "0.25.11", + "@esbuild/netbsd-x64": "0.25.11", + "@esbuild/openbsd-arm64": "0.25.11", + "@esbuild/openbsd-x64": "0.25.11", + "@esbuild/openharmony-arm64": "0.25.11", + "@esbuild/sunos-x64": "0.25.11", + "@esbuild/win32-arm64": "0.25.11", + "@esbuild/win32-ia32": "0.25.11", + "@esbuild/win32-x64": "0.25.11" } }, "node_modules/escalade": { @@ -2237,19 +2218,6 @@ "node": ">=4" } }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "license": "MIT", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/find-cache-dir": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", @@ -2312,13 +2280,13 @@ } }, "node_modules/foreground-child": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", - "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", "dev": true, "license": "ISC", "dependencies": { - "cross-spawn": "^7.0.0", + "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" }, "engines": { @@ -2356,21 +2324,6 @@ "dev": true, "license": "ISC" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -2510,15 +2463,15 @@ } }, "node_modules/glob": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.1.tgz", - "integrity": "sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==", + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", + "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", "dev": true, "license": "ISC", "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^4.0.1", - "minimatch": "^10.0.0", + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.0.3", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^2.0.0" @@ -2533,37 +2486,14 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/glob/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, "node_modules/glob/node_modules/minimatch": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", - "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", + "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", "dev": true, "license": "ISC", "dependencies": { - "brace-expansion": "^2.0.1" + "@isaacs/brace-expansion": "^5.0.0" }, "engines": { "node": "20 || >=22" @@ -2896,19 +2826,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-boolean-object": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz", @@ -2990,16 +2907,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-finalizationregistry": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz", @@ -3045,19 +2952,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-map": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", @@ -3078,16 +2972,6 @@ "dev": true, "license": "MIT" }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, "node_modules/is-number-object": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", @@ -3105,6 +2989,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -3488,9 +3382,9 @@ } }, "node_modules/jackspeak": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.3.tgz", - "integrity": "sha512-oSwM7q8PTHQWuZAlp995iPpPJ4Vkl7qT0ZRD+9duL9j2oBy6KcTfyxc8mEuHJYC+z/kbps80aJLkaNzTOrf/kw==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", + "integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -3619,14 +3513,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", - "deprecated": "This package is deprecated. Use the optional chaining (?.) operator instead.", - "dev": true, - "license": "MIT" - }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -3753,29 +3639,30 @@ } }, "node_modules/mocha": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.1.0.tgz", - "integrity": "sha512-8uJR5RTC2NgpY3GrYcgpZrsEd9zKbPDpob1RezyR2upGHRQtHWofmzTMzTMSV6dru3tj5Ukt0+Vnq1qhFEEwAg==", + "version": "11.7.4", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.7.4.tgz", + "integrity": "sha512-1jYAaY8x0kAZ0XszLWu14pzsf4KV740Gld4HXkhNTXwcHx4AUEDkPzgEHg9CM5dVcW+zv036tjpsEbLraPJj4w==", "dev": true, "license": "MIT", "dependencies": { - "ansi-colors": "^4.1.3", "browser-stdout": "^1.3.1", - "chokidar": "^3.5.3", + "chokidar": "^4.0.1", "debug": "^4.3.5", - "diff": "^5.2.0", + "diff": "^7.0.0", "escape-string-regexp": "^4.0.0", "find-up": "^5.0.0", "glob": "^10.4.5", "he": "^1.2.0", + "is-path-inside": "^3.0.3", "js-yaml": "^4.1.0", "log-symbols": "^4.1.0", - "minimatch": "^5.1.6", + "minimatch": "^9.0.5", "ms": "^2.1.3", + "picocolors": "^1.1.1", "serialize-javascript": "^6.0.2", "strip-json-comments": "^3.1.1", "supports-color": "^8.1.1", - "workerpool": "^6.5.1", + "workerpool": "^9.2.0", "yargs": "^17.7.2", "yargs-parser": "^21.1.1", "yargs-unparser": "^2.0.0" @@ -3809,9 +3696,9 @@ } }, "node_modules/mocha/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", "dev": true, "license": "MIT", "dependencies": { @@ -3861,22 +3748,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/mocha/node_modules/glob/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/mocha/node_modules/jackspeak": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", @@ -3901,16 +3772,19 @@ "license": "ISC" }, "node_modules/mocha/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=10" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/mocha/node_modules/path-scurry": { @@ -4023,13 +3897,13 @@ } }, "node_modules/nock": { - "version": "14.0.1", - "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.1.tgz", - "integrity": "sha512-IJN4O9pturuRdn60NjQ7YkFt6Rwei7ZKaOwb1tvUIIqTgeD0SDDAX3vrqZD4wcXczeEy/AsUXxpGpP/yHqV7xg==", + "version": "14.0.10", + "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.10.tgz", + "integrity": "sha512-Q7HjkpyPeLa0ZVZC5qpxBt5EyLczFJ91MEewQiIi9taWuA0KB/MDJlUWtON+7dGouVdADTQsf9RA7TZk6D8VMw==", "dev": true, "license": "MIT", "dependencies": { - "@mswjs/interceptors": "^0.37.3", + "@mswjs/interceptors": "^0.39.5", "json-stringify-safe": "^5.0.1", "propagate": "^2.0.0" }, @@ -4091,16 +3965,6 @@ "semver": "bin/semver" } }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/npm-run-all": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz", @@ -4774,13 +4638,14 @@ } }, "node_modules/path-to-regexp": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", - "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", "dev": true, "license": "MIT", - "engines": { - "node": ">=16" + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/path-type": { @@ -4813,19 +4678,6 @@ "dev": true, "license": "ISC" }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/pidtree": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz", @@ -4929,9 +4781,9 @@ } }, "node_modules/prettier": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.1.tgz", - "integrity": "sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, "license": "MIT", "bin": { @@ -5013,16 +4865,17 @@ } }, "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", "dev": true, "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, "engines": { - "node": ">=8.10.0" + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" } }, "node_modules/reflect.getprototypeof": { @@ -5445,14 +5298,14 @@ } }, "node_modules/sinon": { - "version": "19.0.2", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-19.0.2.tgz", - "integrity": "sha512-euuToqM+PjO4UgXeLETsfQiuoyPXlqFezr6YZDFwHR3t4qaX0fZUe1MfPMznTL5f8BWrVS89KduLdMUsxFCO6g==", + "version": "19.0.5", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-19.0.5.tgz", + "integrity": "sha512-r15s9/s+ub/d4bxNXqIUmwp6imVSdTorIRaxoecYjqTVLZ8RuoXr/4EDGwIBo6Waxn7f2gnURX9zuhAfCwaF6Q==", "dev": true, "license": "BSD-3-Clause", "dependencies": { "@sinonjs/commons": "^3.0.1", - "@sinonjs/fake-timers": "^13.0.2", + "@sinonjs/fake-timers": "^13.0.5", "@sinonjs/samsam": "^8.0.1", "diff": "^7.0.0", "nise": "^6.1.1", @@ -5463,16 +5316,6 @@ "url": "https://opencollective.com/sinon" } }, - "node_modules/sinon/node_modules/diff": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", - "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/sinon/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -5953,19 +5796,6 @@ "safe-buffer": "~5.1.0" } }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", @@ -6129,9 +5959,9 @@ } }, "node_modules/typescript": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", - "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -6363,9 +6193,9 @@ } }, "node_modules/workerpool": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", - "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "version": "9.3.4", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-9.3.4.tgz", + "integrity": "sha512-TmPRQYYSAnnDiEB0P/Ytip7bFGvqnSU6I2BcuSw7Hx+JSg/DsUi5ebYfc8GYaSdpuvOcEs6dXxPurOYpe9QFwg==", "dev": true, "license": "Apache-2.0" }, diff --git a/package.json b/package.json index c5f695c..770af70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dynamics-web-api", - "version": "2.3.2", + "version": "2.4.0", "description": "DynamicsWebApi is a Microsoft Dataverse Web API helper library", "keywords": [ "dataverse", @@ -42,23 +42,23 @@ "@types/chai": "^4.3.20", "@types/mocha": "^10.0.10", "@types/node": "^20.16.5", - "@types/sinon": "^10.0.20", - "@types/xrm": "^9.0.82", + "@types/sinon": "^17.0.4", + "@types/xrm": "^9.0.87", "Base64": "^1.3.0", "chai": "^4.5.0", "copyfiles": "^2.4.1", - "esbuild": "^0.25.0", - "glob": "^11.0.1", - "mocha": "^11.1.0", + "esbuild": "^0.25.11", + "glob": "^11.0.3", + "mocha": "^11.7.4", "mocha-lcov-reporter": "^1.3.0", - "nock": "^14.0.1", + "nock": "^14.0.10", "npm-run-all": "^4.1.5", "nyc": "^17.1.0", - "prettier": "^3.5.1", + "prettier": "^3.6.2", "rimraf": "^6.0.1", - "sinon": "^19.0.2", + "sinon": "^19.0.5", "ts-node": "^10.9.2", - "typescript": "^5.7.3" + "typescript": "^5.9.3" }, "dependencies": { "http-proxy-agent": "^4.0.1", diff --git a/src/client/request/processData.ts b/src/client/request/processData.ts index 649c4c2..0d12c81 100644 --- a/src/client/request/processData.ts +++ b/src/client/request/processData.ts @@ -33,13 +33,18 @@ export const processData = (data: any, config: InternalConfig): string | Uint8Ar }; const stringifiedData = JSON.stringify(data, (key, value) => { - if (key.endsWith("@odata.bind") || key.endsWith("@odata.id")) { + if (key === "@odata.id" || key.endsWith("@odata.bind")) { if (typeof value === "string" && !value.startsWith("$")) { value = removeCurlyBracketsFromUuid(value); if (config.useEntityNames) { value = replaceEntityNameWithCollectionName(value); } - value = addFullWebApiUrl(key, value); + + // the full Web API URL is only added in requests to /$ref + // the value itself is set directly in the requests that require it + if (key !== "@odata.id") { + value = addFullWebApiUrl(key, value); + } } } else if (key.startsWith("oData") || key.endsWith("_Formatted") || key.endsWith("_NavigationProperty") || key.endsWith("_LogicalName")) { return undefined; diff --git a/src/dynamics-web-api.ts b/src/dynamics-web-api.ts index 0cddb97..aeb86e8 100644 --- a/src/dynamics-web-api.ts +++ b/src/dynamics-web-api.ts @@ -1,6 +1,7 @@ import { DataverseClient, type IDataverseClient } from "./client/dataverse"; import { getCollectionName } from "./client/RequestClient"; import * as Dataverse from "./requests"; +import { toAbsoluteUrl } from "./utils/Utility"; /** * Microsoft Dataverse Web API helper library for Node.js and Browser. @@ -480,6 +481,13 @@ export class DynamicsWebApi { * @returns {string | null} collection name */ getCollectionName: (entityName: string): string | null => getCollectionName(entityName), + + /** + * Adds an absolute Web API URL to the beginning of a provided value. + * @param value The value to modify. + * @returns The absolute URL. + */ + toAbsoluteUrl: (value: string): string => toAbsoluteUrl(this.#client,value), }; } @@ -1193,6 +1201,12 @@ export interface Config { * You can also set a callback URL per request. */ backgroundOperationCallbackUrl?: string; + /** + * Disables enforcement of absolute URLs for @odata.id properties in the request body. + * In some cases, @odata.id has an alternate key format that does not use absolute URLs, for example: + * In an UpsertMultiple action body. + */ + disableODataIdAbsoluteUrl?: boolean; } /**Header collection type */ diff --git a/src/helpers/Regex.ts b/src/helpers/Regex.ts index 35b6872..f502f41 100644 --- a/src/helpers/Regex.ts +++ b/src/helpers/Regex.ts @@ -97,9 +97,8 @@ function sanitizeCookie(cookie: string): string { return cookie.replace(SPECIAL_CHARACTER_REGEX, (char) => characterMap[char]); } -const LEADING_SLASH_REGEX = /^\//; export function removeLeadingSlash(value: string): string { - return value.replace(LEADING_SLASH_REGEX, ""); + return value.startsWith("/") ? value.slice(1) : value; } const UNICODE_SYMBOLS_REGEX = /[\u007F-\uFFFF]/g; diff --git a/src/requests/associate.ts b/src/requests/associate.ts index 0fa6f2c..b6cb59d 100644 --- a/src/requests/associate.ts +++ b/src/requests/associate.ts @@ -20,7 +20,7 @@ export const associate = async (request: AssociateRequest, client: IDataverseCli if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith("$"))) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); diff --git a/src/requests/associateSingleValued.ts b/src/requests/associateSingleValued.ts index 4611c0d..f23076d 100644 --- a/src/requests/associateSingleValued.ts +++ b/src/requests/associateSingleValued.ts @@ -20,7 +20,7 @@ export const associateSingleValued = async (request: AssociateSingleValuedReques if (!client.isBatch || (client.isBatch && !request.relatedKey.startsWith("$"))) { ErrorHelper.stringParameterCheck(request.relatedCollection, REQUEST_NAME, "request.relatedCollection"); relatedKey = ErrorHelper.keyParameterCheck(request.relatedKey, REQUEST_NAME, "request.relatedKey"); - odataId = `${request.relatedCollection}(${relatedKey})`; + odataId = `${client.config.dataApi.url}${request.relatedCollection}(${relatedKey})`; } let internalRequest = copyRequest(request, ["primaryKey"]); diff --git a/src/utils/Utility.ts b/src/utils/Utility.ts index 3bdd3c6..7b8c00f 100644 --- a/src/utils/Utility.ts +++ b/src/utils/Utility.ts @@ -1,6 +1,7 @@ import type * as Core from "../types"; import { getCrypto } from "../helpers/Crypto"; -import { isUuid, extractUuid, parsePagingCookie } from "../helpers/Regex"; +import { isUuid, extractUuid, parsePagingCookie, removeLeadingSlash } from "../helpers/Regex"; +import { IDataverseClient } from "../client/dataverse"; declare var GetGlobalContext: any; declare var Xrm: any; @@ -206,3 +207,7 @@ export function convertToFileBuffer(binaryString: string): Uint8Array | Buffer { } return bytes; } + +export function toAbsoluteUrl(client: IDataverseClient, value: string): string { + return `${client.config.dataApi.url}${removeLeadingSlash(value)}`; +} diff --git a/tests/common-converted.spec.ts b/tests/common-converted.spec.ts index e809ab2..194c38e 100644 --- a/tests/common-converted.spec.ts +++ b/tests/common-converted.spec.ts @@ -2117,10 +2117,11 @@ describe("dateReviver", function () { describe("RequestClient.makeRequest", function () { before(() => { + //@ts-ignore global.DWA_BROWSER = false; }); describe("useEntityNames", function () { - var scope; + var scope: nock.Scope; before(function () { var response = responses.response200; var response2 = responses.responseEntityDefinitions; @@ -2167,7 +2168,7 @@ describe("RequestClient.makeRequest", function () { }); describe("useEntityNames - entity metadata requested only once", function () { - var scope; + var scope: nock.Scope; before(function () { var response = responses.response200; var response2 = responses.responseEntityDefinitions; @@ -2231,7 +2232,7 @@ describe("RequestClient.makeRequest", function () { }); describe("useEntityNames - request with collection name does not fail", function () { - var scope; + var scope: nock.Scope; before(function () { var response = responses.response200; var response2 = responses.responseEntityDefinitions; @@ -2277,7 +2278,7 @@ describe("RequestClient.makeRequest", function () { }); describe("useEntityNames - $batch", function () { - var scope; + var scope: nock.Scope; before(function () { var response = responses.response200; var response2 = responses.responseEntityDefinitions; @@ -2324,7 +2325,7 @@ describe("RequestClient.makeRequest", function () { }); describe("timeout - socket (request timeout)", function () { - var scope; + var scope: nock.Scope; var url = "test"; before(function () { var response = responses.basicEmptyResponseSuccess; @@ -2365,7 +2366,7 @@ describe("RequestClient.makeRequest", function () { }); describe("timeout - socket (config)", async function () { - var scope; + var scope: nock.Scope; var url = "test"; before(function () { var response = responses.basicEmptyResponseSuccess; @@ -2405,7 +2406,7 @@ describe("RequestClient.makeRequest", function () { }); describe("timeout - connection delay (request timeout)", function () { - var scope; + var scope: nock.Scope; var url = "test"; before(function () { var response = responses.basicEmptyResponseSuccess; @@ -2446,7 +2447,7 @@ describe("RequestClient.makeRequest", function () { }); describe("timeout - connection delay (config)", function () { - var scope; + var scope: nock.Scope; var url = "test"; before(function () { var response = responses.basicEmptyResponseSuccess; @@ -2487,7 +2488,7 @@ describe("RequestClient.makeRequest", function () { }); describe("when url is long, request is converted to batch", function () { - var scope; + var scope: nock.Scope; var url = "test"; while (url.length < 2001) { url += "test"; @@ -2551,10 +2552,11 @@ describe("RequestClient.makeRequest", function () { describe("RequestClient.sendRequest", function () { before(() => { + //@ts-ignore global.DWA_BROWSER = false; }); describe("removes additional properties set by DynamicsWebApi", function () { - var scope; + var scope: nock.Scope; var url = "test"; before(function () { var response = responses.basicEmptyResponseSuccess; @@ -2618,7 +2620,7 @@ describe("RequestClient.sendRequest", function () { // }); describe("timeout - socket", function () { - var scope; + var scope: nock.Scope; var url = "test"; before(function () { var response = responses.basicEmptyResponseSuccess; @@ -2649,7 +2651,7 @@ describe("RequestClient.sendRequest", function () { }); describe("timeout - connection delay", function () { - var scope; + var scope: nock.Scope; var url = "test"; before(function () { var response = responses.basicEmptyResponseSuccess; diff --git a/tests/common.spec.ts b/tests/common.spec.ts index 09bb4b4..e2a30e7 100644 --- a/tests/common.spec.ts +++ b/tests/common.spec.ts @@ -127,6 +127,7 @@ describe("RequestClient.sendRequest", () => { describe("RequestClient.makeRequest", () => { before(() => { + //@ts-ignore global.DWA_BROWSER = false; }); describe("AbortSignal", () => { @@ -277,7 +278,7 @@ describe("RequestUtility.", () => { }, }; - it("removes brackets from the guids & adds a slash in front", () => { + it("@odata.bind - removes brackets from the guids & adds a slash in front", () => { const guid = "00000000-0000-0000-0000-000000000001"; const data = { "ref1@odata.bind": `contacts({${guid}})`, @@ -285,7 +286,18 @@ describe("RequestUtility.", () => { const result = RequestUtility.processData(data, config); - expect(result).to.be.eq('{"ref1@odata.bind":"/contacts(00000000-0000-0000-0000-000000000001)"}'); + expect(result).to.be.eq(`{"ref1@odata.bind":"/contacts(${guid})"}`); + }); + + it("@odata.id - removes brackets from the guids and does not prepend an absolute URL", () => { + const guid = "00000000-0000-0000-0000-000000000001"; + const data = { + "@odata.id": `contacts({${guid}})`, + }; + + const result = RequestUtility.processData(data, config); + + expect(result).to.be.eq(`{"@odata.id":"contacts(${guid})"}`); }); }); }); diff --git a/tests/main-converted.spec.ts b/tests/main-converted.spec.ts index 9438e7b..4c2f89f 100644 --- a/tests/main-converted.spec.ts +++ b/tests/main-converted.spec.ts @@ -13,7 +13,7 @@ var dynamicsWebApiTest = new DynamicsWebApi({ serverUrl: _serverUrl, dataApi: { describe("dynamicsWebApi.upsert -", function () { describe("basic & update an existing entity", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl).patch(responses.testEntityUrl, _data.testEntity).reply(response.status, response.responseText, response.responseHeaders); @@ -40,7 +40,7 @@ describe("dynamicsWebApi.upsert -", function () { }); describe("basic & create an entity", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl).patch(responses.testEntityUrl, _data.testEntity).reply(response.status, response.responseText, response.responseHeaders); @@ -68,7 +68,7 @@ describe("dynamicsWebApi.upsert -", function () { }); describe("return representation & update an existing entity", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.updateReturnRepresentation; scope = nock(webApiUrl, { @@ -102,7 +102,7 @@ describe("dynamicsWebApi.upsert -", function () { }); describe("return representation & create an entity", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnRepresentation; scope = nock(webApiUrl, { @@ -136,7 +136,7 @@ describe("dynamicsWebApi.upsert -", function () { }); describe("return representation & update an existing entity & select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.updateReturnRepresentation; scope = nock(webApiUrl, { @@ -196,7 +196,7 @@ describe("dynamicsWebApi.upsert -", function () { }); describe("return representation & create an entity & select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnRepresentation; scope = nock(webApiUrl, { @@ -258,7 +258,7 @@ describe("dynamicsWebApi.upsert -", function () { describe("dynamicsWebApi.retrieve -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl).get(responses.testEntityUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -286,7 +286,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("basic - alternate key", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -316,7 +316,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -360,7 +360,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("single value or navigation property", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -418,7 +418,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("reference", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.retrieveReferenceResponse; scope = nock(webApiUrl) @@ -448,7 +448,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("expand basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -478,7 +478,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("select & expand basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -532,7 +532,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("select & expand navigation property", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -607,7 +607,7 @@ describe("dynamicsWebApi.retrieve -", function () { describe("dynamicsWebApi.count -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.countBasic; scope = nock(webApiUrl) @@ -637,7 +637,7 @@ describe("dynamicsWebApi.count -", function () { }); describe("filter", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleWithCountResponse; scope = nock(webApiUrl) @@ -669,7 +669,7 @@ describe("dynamicsWebApi.count -", function () { describe("dynamicsWebApi.countAll -", function () { describe("filter", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleWithCountResponse; scope = nock(webApiUrl) @@ -701,7 +701,7 @@ describe("dynamicsWebApi.countAll -", function () { describe("dynamicsWebApi.fetch -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.fetchXmlResponsePage1Cookie; scope = nock(webApiUrl) @@ -731,7 +731,7 @@ describe("dynamicsWebApi.fetch -", function () { }); describe("paging", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.fetchXmlResponsePage2Cookie; scope = nock(webApiUrl) @@ -762,7 +762,7 @@ describe("dynamicsWebApi.fetch -", function () { }); describe("paging - no cookie", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.fetchXmlResponsePage1; scope = nock(webApiUrl) @@ -792,7 +792,7 @@ describe("dynamicsWebApi.fetch -", function () { }); describe("with prefer", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.fetchXmlResponsePage2Cookie; scope = nock(webApiUrl, { @@ -833,7 +833,7 @@ describe("dynamicsWebApi.fetch -", function () { }); describe("with top attribute", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.fetchXmlResponsePage1Cookie; scope = nock(webApiUrl) @@ -868,7 +868,7 @@ describe("dynamicsWebApi.fetch -", function () { describe("dynamicsWebApi.fetchAll -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.fetchXmlResponsePage1Cookie; var response2 = responses.fetchXmlResponsePage2NoCookie; @@ -905,7 +905,7 @@ describe("dynamicsWebApi.fetchAll -", function () { describe("dynamicsWebApi.associate -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl) @@ -942,7 +942,7 @@ describe("dynamicsWebApi.associate -", function () { }); describe("basic - use entity names: true", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; var response2 = responses.responseEntityDefinitions; @@ -987,7 +987,7 @@ describe("dynamicsWebApi.associate -", function () { }); describe("impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -1031,7 +1031,7 @@ describe("dynamicsWebApi.associate -", function () { describe("dynamicsWebApi.disassociate -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl) @@ -1065,7 +1065,7 @@ describe("dynamicsWebApi.disassociate -", function () { }); describe("impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -1106,7 +1106,7 @@ describe("dynamicsWebApi.disassociate -", function () { describe("dynamicsWebApi.associateSingleValued -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl) @@ -1143,7 +1143,7 @@ describe("dynamicsWebApi.associateSingleValued -", function () { }); describe("impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -1187,7 +1187,7 @@ describe("dynamicsWebApi.associateSingleValued -", function () { describe("dynamicsWebApi.disassociateSingleValued -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl) @@ -1216,7 +1216,7 @@ describe("dynamicsWebApi.disassociateSingleValued -", function () { }); describe("impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -1252,7 +1252,7 @@ describe("dynamicsWebApi.disassociateSingleValued -", function () { describe("dynamicsWebApi.callFunction -", function () { describe("unbound", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -1296,7 +1296,7 @@ describe("dynamicsWebApi.callFunction -", function () { }); describe("unbound - short version", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl).get("/FUN()").reply(response.status, response.responseText, response.responseHeaders); @@ -1324,7 +1324,7 @@ describe("dynamicsWebApi.callFunction -", function () { }); describe("unbound impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl, { @@ -1372,7 +1372,7 @@ describe("dynamicsWebApi.callFunction -", function () { }); describe("bound", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; var response2 = responses.basicEmptyResponseSuccess; @@ -1421,7 +1421,7 @@ describe("dynamicsWebApi.callFunction -", function () { }); describe("bound impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl, { @@ -1477,7 +1477,7 @@ describe("dynamicsWebApi.callFunction -", function () { describe("dynamicsWebApi.callAction -", function () { describe("unbound", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl).post("/FUN", responses.actionRequestModified).reply(response.status, response.responseText, response.responseHeaders); @@ -1504,7 +1504,7 @@ describe("dynamicsWebApi.callAction -", function () { }); describe("unbound impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -1537,7 +1537,7 @@ describe("dynamicsWebApi.callAction -", function () { }); describe("bound", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -1567,7 +1567,7 @@ describe("dynamicsWebApi.callAction -", function () { }); describe("bound impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl, { @@ -1609,7 +1609,7 @@ describe("dynamicsWebApi.callAction -", function () { describe("dynamicsWebApi.update -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -1649,7 +1649,7 @@ describe("dynamicsWebApi.update -", function () { }); describe("return representation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.updateReturnRepresentation; scope = nock(webApiUrl, { @@ -1713,7 +1713,7 @@ describe("dynamicsWebApi.update -", function () { }); describe("(success) check optimistic concurrency", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; @@ -1755,7 +1755,7 @@ describe("dynamicsWebApi.update -", function () { }); describe("(pre condition failed) check optimistic concurrency", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.upsertPreventUpdateResponse; @@ -1797,7 +1797,7 @@ describe("dynamicsWebApi.update -", function () { }); describe("(error response) check optimistic concurrency", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.upsertPreventCreateResponse; @@ -1847,7 +1847,7 @@ describe("dynamicsWebApi.upsert -", function () { data: _data.testEntity, }; - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; var response2 = responses.createReturnId; @@ -1892,7 +1892,7 @@ describe("dynamicsWebApi.upsert -", function () { }); describe("return representation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.updateReturnRepresentation; var response2 = responses.createReturnRepresentation; @@ -1964,7 +1964,7 @@ describe("dynamicsWebApi.upsert -", function () { returnRepresentation: true, ifmatch: "*", }; - var scope; + let scope: nock.Scope; before(function () { var response = responses.upsertPreventCreateResponse; var response2 = responses.createReturnRepresentation; @@ -2039,7 +2039,7 @@ describe("dynamicsWebApi.upsert -", function () { returnRepresentation: true, ifnonematch: "*", }; - var scope; + let scope: nock.Scope; before(function () { var response = responses.upsertPreventUpdateResponse; var response2 = responses.updateReturnRepresentation; @@ -2109,7 +2109,7 @@ describe("dynamicsWebApi.upsert -", function () { describe("dynamicsWebApi.retrieve -", function () { describe("match and impersonation", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl, { @@ -2152,7 +2152,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("match and impersonation - expand filter", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl, { @@ -2195,7 +2195,7 @@ describe("dynamicsWebApi.retrieve -", function () { }); describe("match and impersonation - retrieve reference", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.retrieveReferenceResponse; scope = nock(webApiUrl, { @@ -2241,7 +2241,7 @@ describe("dynamicsWebApi.retrieve -", function () { describe("dynamicsWebApi.retrieveMultiple -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl).get(responses.collectionUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -2269,7 +2269,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl) @@ -2313,7 +2313,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("filter", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl) @@ -2357,7 +2357,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("includeAnnotations", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; var response2 = responses.multipleWithCountResponse; @@ -2419,7 +2419,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("retrieves the next page link", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleWithLinkResponse; scope = nock(webApiUrl, { @@ -2459,7 +2459,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("when goes by next page link", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; var linkQuery = responses.multipleWithLink().oDataNextLink.split("?"); @@ -2502,7 +2502,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("retrieves the delta link (@odata.deltaLink)", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleWithDeltaLinkResponse; scope = nock(webApiUrl, { @@ -2542,7 +2542,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("when goes by delta link (@odata.deltaLink)", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; var linkQuery = responses.multipleWithDeltaLink().oDataDeltaLink.split("?"); @@ -2585,7 +2585,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("$apply", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -2625,7 +2625,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { }); describe("filter & queryParams parameters", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -2671,7 +2671,7 @@ describe("dynamicsWebApi.retrieveMultiple -", function () { describe("dynamicsWebApi.retrieveAll -", function () { describe("single page", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -2712,8 +2712,8 @@ describe("dynamicsWebApi.retrieveAll -", function () { }); describe("multiple pages", function () { - var scope; - var scope2; + let scope: nock.Scope; + let scope2: nock.Scope; before(function () { var response = responses.multipleWithLinkResponse; var response2 = responses.multipleResponse; @@ -2767,8 +2767,8 @@ describe("dynamicsWebApi.retrieveAll -", function () { }); describe("multiple pages - delta link", function () { - var scope; - var scope2; + let scope: nock.Scope; + let scope2: nock.Scope; before(function () { var response = responses.multipleWithLinkResponse; var response2 = responses.multipleWithDeltaLinkResponse; @@ -2812,7 +2812,7 @@ describe("dynamicsWebApi.retrieveAll -", function () { describe("dynamicsWebApi.deleteRecord -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -2852,7 +2852,7 @@ describe("dynamicsWebApi.deleteRecord -", function () { }); describe("single property", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl) @@ -2882,7 +2882,7 @@ describe("dynamicsWebApi.deleteRecord -", function () { }); describe("If-Match", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; var response2 = responses.upsertPreventUpdateResponse; @@ -2970,7 +2970,7 @@ describe("dynamicsWebApi.deleteRecord -", function () { describe("dynamicsWebApi.createEntity -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl) @@ -3002,7 +3002,7 @@ describe("dynamicsWebApi.createEntity -", function () { describe("dynamicsWebApi.updateEntity -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3036,7 +3036,7 @@ describe("dynamicsWebApi.updateEntity -", function () { }); describe("mergeLabels = true", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3073,7 +3073,7 @@ describe("dynamicsWebApi.updateEntity -", function () { describe("dynamicsWebApi.retrieveEntity -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl).get(responses.entityDefinitionsIdUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -3101,7 +3101,7 @@ describe("dynamicsWebApi.retrieveEntity -", function () { }); describe("basic - alternate key", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -3131,7 +3131,7 @@ describe("dynamicsWebApi.retrieveEntity -", function () { }); describe("select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -3177,7 +3177,7 @@ describe("dynamicsWebApi.retrieveEntity -", function () { describe("dynamicsWebApi.retrieveEntities -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.responseEntityDefinitions; scope = nock(webApiUrl).get(responses.entityDefinitionsUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -3207,7 +3207,7 @@ describe("dynamicsWebApi.retrieveEntities -", function () { describe("dynamicsWebApi.createAttribute -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.createAttributeReturnId; scope = nock(webApiUrl) @@ -3239,7 +3239,7 @@ describe("dynamicsWebApi.createAttribute -", function () { describe("dynamicsWebApi.updateAttribute -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3273,7 +3273,7 @@ describe("dynamicsWebApi.updateAttribute -", function () { }); describe("mergeLabels = true", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3308,7 +3308,7 @@ describe("dynamicsWebApi.updateAttribute -", function () { }); describe("with Attribute Type", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3342,7 +3342,7 @@ describe("dynamicsWebApi.updateAttribute -", function () { }); describe("with Attribute Type & mergeLabels = true", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3384,7 +3384,7 @@ describe("dynamicsWebApi.updateAttribute -", function () { describe("dynamicsWebApi.retrieveAttributes -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.responseEntityDefinitions; scope = nock(webApiUrl) @@ -3414,7 +3414,7 @@ describe("dynamicsWebApi.retrieveAttributes -", function () { }); describe("with AttributeType", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.responseEntityDefinitions; scope = nock(webApiUrl) @@ -3446,7 +3446,7 @@ describe("dynamicsWebApi.retrieveAttributes -", function () { describe("dynamicsWebApi.retrieveAttribute -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -3476,7 +3476,7 @@ describe("dynamicsWebApi.retrieveAttribute -", function () { }); describe("basic - AlternateKeys", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -3506,7 +3506,7 @@ describe("dynamicsWebApi.retrieveAttribute -", function () { }); describe("with AttributeType", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -3538,7 +3538,7 @@ describe("dynamicsWebApi.retrieveAttribute -", function () { describe("dynamicsWebApi.createRelationship -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl) @@ -3570,7 +3570,7 @@ describe("dynamicsWebApi.createRelationship -", function () { describe("dynamicsWebApi.updateRelationship -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3604,7 +3604,7 @@ describe("dynamicsWebApi.updateRelationship -", function () { }); describe("cast relationship", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3638,7 +3638,7 @@ describe("dynamicsWebApi.updateRelationship -", function () { }); describe("mergeLabels = true", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3675,7 +3675,7 @@ describe("dynamicsWebApi.updateRelationship -", function () { describe("dynamicsWebApi.deleteRelationship -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl).delete(responses.relationshipDefinitionsIdUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -3705,7 +3705,7 @@ describe("dynamicsWebApi.deleteRelationship -", function () { describe("dynamicsWebApi.retrieveRelationship -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl).get(responses.relationshipDefinitionsIdUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -3733,7 +3733,7 @@ describe("dynamicsWebApi.retrieveRelationship -", function () { }); describe("select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -3777,7 +3777,7 @@ describe("dynamicsWebApi.retrieveRelationship -", function () { }); describe("cast relationship, select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -3823,7 +3823,7 @@ describe("dynamicsWebApi.retrieveRelationship -", function () { describe("dynamicsWebApi.retrieveRelationships -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.responseEntityDefinitions; scope = nock(webApiUrl).get(responses.relationshipDefinitionsUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -3851,7 +3851,7 @@ describe("dynamicsWebApi.retrieveRelationships -", function () { }); describe("cast, select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.responseEntityDefinitions; scope = nock(webApiUrl) @@ -3897,7 +3897,7 @@ describe("dynamicsWebApi.retrieveRelationships -", function () { describe("dynamicsWebApi.createGlobalOptionSet -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl) @@ -3929,7 +3929,7 @@ describe("dynamicsWebApi.createGlobalOptionSet -", function () { describe("dynamicsWebApi.updateGlobalOptionSet -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -3963,7 +3963,7 @@ describe("dynamicsWebApi.updateGlobalOptionSet -", function () { }); describe("mergeLabels = true", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -4000,7 +4000,7 @@ describe("dynamicsWebApi.updateGlobalOptionSet -", function () { describe("dynamicsWebApi.deleteGlobalOptionSet -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl).delete(responses.globalOptionSetDefinitionsIdUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -4030,7 +4030,7 @@ describe("dynamicsWebApi.deleteGlobalOptionSet -", function () { describe("dynamicsWebApi.retrieveGlobalOptionSet -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl).get(responses.globalOptionSetDefinitionsIdUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -4058,7 +4058,7 @@ describe("dynamicsWebApi.retrieveGlobalOptionSet -", function () { }); describe("select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl) @@ -4104,7 +4104,7 @@ describe("dynamicsWebApi.retrieveGlobalOptionSet -", function () { describe("dynamicsWebApi.retrieveGlobalOptionSets -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.responseEntityDefinitions; scope = nock(webApiUrl).get(responses.globalOptionSetDefinitionsUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -4132,7 +4132,7 @@ describe("dynamicsWebApi.retrieveGlobalOptionSets -", function () { }); describe("cast, select", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.responseEntityDefinitions; scope = nock(webApiUrl) @@ -4178,7 +4178,7 @@ describe("dynamicsWebApi.retrieveGlobalOptionSets -", function () { describe("dynamicsWebApi.executeBatch -", function () { describe("retrieve multiple / create / retrieve multiple", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchRetrieveMultipleCreateRetrieveMultiple; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4236,7 +4236,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("retrieve multiple / update / retrieve multiple", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchRetrieveMultipleUpdateRetrieveMultiple; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4294,7 +4294,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("retrieve multiple / delete / retrieve multiple", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchRetrieveMultipleDeleteRetrieveMultiple; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4352,7 +4352,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("retrieve multiple / count / retrieve multiple", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchRetrieveMultipleCountRetrieveMultiple; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4410,7 +4410,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("retrieve multiple / retrieve multiple (count) / retrieve multiple", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchRetrieveMultipleCountFilteredRetrieveMultiple; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4468,7 +4468,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("retrieve multiple / count (filtered) / retrieve multiple", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchRetrieveMultipleCountFilteredRetrieveMultiple; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4552,7 +4552,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("update / delete", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchUpdateDelete; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4610,7 +4610,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("update / delete - passing a request parameter", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchUpdateDelete; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4670,7 +4670,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("update / delete - returns an error", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchUpdateDelete; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4739,7 +4739,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("create / create with Content-ID", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchCreateContentID; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4795,7 +4795,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("create / create with Content-ID - URL Replacement", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchCreateContentIDURLReplace; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4851,7 +4851,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("create / create with Content-ID in a payload", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchCreateContentIDPayload; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4907,7 +4907,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("upsert / upsert / upsert with alternate keys", function () { - var scope; + let scope: nock.Scope; var rBody = _data.batchUpsertUpsertUpsertWithAlternateKeys; var rBodys = rBody.split("\r\n"); var checkBody = ""; @@ -4965,7 +4965,7 @@ describe("dynamicsWebApi.executeBatch -", function () { }); describe("next request has a new requestId", function () { - var scope; + let scope: nock.Scope; //1st request body check var rBody = _data.batchRetrieveMultipleCreateRetrieveMultiple; var rBodys = rBody.split("\r\n"); @@ -5055,9 +5055,9 @@ describe("dynamicsWebApi.uploadFile -", function () { data: Buffer.from("Welcome to DynamicsWebApi!", "utf-8"), }; - var scope; - var scope1; - var scope2; + let scope: nock.Scope; + let scope1: nock.Scope; + let scope2: nock.Scope; before(function () { var beginResponse = responses.uploadFileBeginResponse; var response1 = responses.uploadFile1stResponse; @@ -5118,8 +5118,8 @@ describe("dynamicsWebApi.downloadFile -", function () { property: "dwa_file", }; - var scope; - var scope1; + let scope: nock.Scope; + let scope1: nock.Scope; var chunk1 = responses.downloadFileResponseChunk1; var chunk2 = responses.downloadFileResponseChunk2; @@ -5168,7 +5168,7 @@ describe("dynamicsWebApi.downloadFile -", function () { describe("dynamicsWebApi.retrieveCsdlMetadata -", function () { describe("basic", function () { - var scope; + let scope: nock.Scope; before(function () { const response = responses.xmlResponse; scope = nock(webApiUrl, { @@ -5202,7 +5202,7 @@ describe("dynamicsWebApi.retrieveCsdlMetadata -", function () { }); describe("annotations = true", function () { - var scope; + let scope: nock.Scope; before(function () { const response = responses.xmlResponse; scope = nock(webApiUrl, { @@ -5242,7 +5242,7 @@ describe("dynamicsWebApi.retrieveCsdlMetadata -", function () { describe("dynamicsWebApi.constructor -", function () { describe("dataApi.version", function () { var dynamicsWebApi92 = new DynamicsWebApi(); - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl92).post("/tests", _data.testEntity).reply(response.status, response.responseText, response.responseHeaders); @@ -5271,7 +5271,7 @@ describe("dynamicsWebApi.constructor -", function () { describe("impersonate", function () { var dynamicsWebApi92 = new DynamicsWebApi({ impersonate: _data.testEntityId2 }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl92, { @@ -5305,7 +5305,7 @@ describe("dynamicsWebApi.constructor -", function () { }); describe("authorization", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -5323,7 +5323,7 @@ describe("dynamicsWebApi.constructor -", function () { it("sends the request to the right end point and returns a response", function (done) { const getToken = async function () { - var adalCallback = async function (token) { + var adalCallback = async function (token: string | { accessToken: string } | null) { return token; }; @@ -5350,7 +5350,7 @@ describe("dynamicsWebApi.constructor -", function () { }); describe("authorization - token is empty", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -5368,7 +5368,7 @@ describe("dynamicsWebApi.constructor -", function () { it("sends the request to the right end point and returns a response", async () => { const getToken = async function () { - const adalCallback = async function (token) { + const adalCallback = async function (token: string | { accessToken: string } | null) { return token; }; @@ -5393,7 +5393,7 @@ describe("dynamicsWebApi.constructor -", function () { }); describe("authorization - plain token", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -5411,7 +5411,7 @@ describe("dynamicsWebApi.constructor -", function () { it("sends the request to the right end point and returns a response", function (done) { const getToken = async function () { - var adalCallback = async function (token) { + var adalCallback = async function (token: string | { accessToken: string } | null) { return token; }; @@ -5438,8 +5438,8 @@ describe("dynamicsWebApi.constructor -", function () { }); describe("authorization - two requests use different authorization tokens", function () { - var scope; - var scope2; + let scope: nock.Scope; + let scope2: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -5463,9 +5463,9 @@ describe("dynamicsWebApi.constructor -", function () { cleanAll(); }); - var i = 0; + let i = 0; const getToken = async function () { - var adalCallback = async function (token) { + let adalCallback = async function (token: string | { accessToken: string } | null) { return token; }; @@ -5503,7 +5503,7 @@ describe("dynamicsWebApi.constructor -", function () { }); describe("authorization - when token set in the request it overrides token returned from a callback", function () { - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -5547,7 +5547,7 @@ describe("dynamicsWebApi.constructor -", function () { describe("prefer - include annotations added to request if set in the config", function () { var dynamicsWebApi82 = new DynamicsWebApi({ dataApi: { version: "8.2" }, includeAnnotations: "some-annotations" }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.response200; scope = nock(webApiUrl, { @@ -5582,7 +5582,7 @@ describe("dynamicsWebApi.constructor -", function () { describe("prefer - include annotations overriden if set in the request", function () { var dynamicsWebApi82 = new DynamicsWebApi({ dataApi: { version: "8.2" }, includeAnnotations: "some-annotations" }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -5623,7 +5623,7 @@ describe("dynamicsWebApi.constructor -", function () { describe("prefer - return representation added to request if set in the config", function () { var dynamicsWebApi82 = new DynamicsWebApi({ dataApi: { version: "8.2" }, returnRepresentation: true }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnRepresentation; scope = nock(webApiUrl, { @@ -5658,8 +5658,8 @@ describe("dynamicsWebApi.constructor -", function () { describe("prefer - return representation overriden if set in the request", function () { var dynamicsWebApi82 = new DynamicsWebApi({ dataApi: { version: "8.2" }, returnRepresentation: true }); - var scope; - var scope2; + let scope: nock.Scope; + let scope2: nock.Scope; before(function () { var response = responses.basicEmptyResponseSuccess; scope = nock(webApiUrl, { @@ -5714,7 +5714,7 @@ describe("dynamicsWebApi.constructor -", function () { describe("prefer - maxPageSize added to request if set in the config", function () { var dynamicsWebApi82 = new DynamicsWebApi({ dataApi: { version: "8.2" }, maxPageSize: 10 }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -5749,7 +5749,7 @@ describe("dynamicsWebApi.constructor -", function () { describe("prefer - maxPageSize overriden if set in the request", function () { var dynamicsWebApi82 = new DynamicsWebApi({ dataApi: { version: "8.2" }, maxPageSize: 10 }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleWithLinkResponse; scope = nock(webApiUrl, { @@ -5795,7 +5795,7 @@ describe("dynamicsWebApi.setConfig -", function () { var dynamicsWebApi81 = new DynamicsWebApi(); dynamicsWebApi81.setConfig({ dataApi: { version: "8.1" }, impersonate: _data.testEntityId2 }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl81, { @@ -5831,7 +5831,7 @@ describe("dynamicsWebApi.setConfig -", function () { describe("impersonate overriden with a request.impersonate", function () { var dynamicsWebApi81 = new DynamicsWebApi(); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl81, { @@ -5869,7 +5869,7 @@ describe("dynamicsWebApi.setConfig -", function () { var dynamicsWebApi90 = new DynamicsWebApi(); dynamicsWebApi90.setConfig({ dataApi: { version: "9.0" }, impersonateAAD: _data.testEntityId2 }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl90, { @@ -5905,7 +5905,7 @@ describe("dynamicsWebApi.setConfig -", function () { describe("impersonateAAD overriden with a request.impersonateAAD", function () { var dynamicsWebApi90 = new DynamicsWebApi(); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl90, { @@ -5942,7 +5942,7 @@ describe("dynamicsWebApi.setConfig -", function () { describe("dataApi.version is overriden by version set in setConfig", function () { var dynamicsWebApi81 = new DynamicsWebApi({ dataApi: { version: "8.1" }, impersonate: _data.testEntityId2 }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -5979,7 +5979,7 @@ describe("dynamicsWebApi.setConfig -", function () { describe("impersonate uses the same url as original instance", function () { var dynamicsWebApi82 = new DynamicsWebApi({ dataApi: { version: "8.2" } }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -6016,7 +6016,7 @@ describe("dynamicsWebApi.setConfig -", function () { describe("dataApi.version is overriden by the new config set", function () { var dynamicsWebApi81 = new DynamicsWebApi({ dataApi: { version: "8.1" } }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl, { @@ -6056,7 +6056,7 @@ describe("dynamicsWebApi.initializeInstance -", function () { var dynamicsWebApi81 = new DynamicsWebApi(); dynamicsWebApi81.setConfig({ dataApi: { version: "8.1" }, impersonate: _data.testEntityId2 }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.createReturnId; scope = nock(webApiUrl81, { @@ -6094,7 +6094,7 @@ describe("dynamicsWebApi.initializeInstance -", function () { var dynamicsWebApi81 = new DynamicsWebApi(); dynamicsWebApi81.setConfig({ dataApi: { version: "8.1" }, impersonate: _data.testEntityId2 }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl).get(responses.collectionUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -6134,7 +6134,7 @@ describe("dynamicsWebApi proxy -", function () { }, }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl).get(responses.collectionUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -6173,7 +6173,7 @@ describe("dynamicsWebApi proxy -", function () { }, }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl).get(responses.collectionUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -6208,7 +6208,7 @@ describe("dynamicsWebApi proxy -", function () { }, }); - var scope; + let scope: nock.Scope; before(function () { var response = responses.multipleResponse; scope = nock(webApiUrl).get(responses.collectionUrl).reply(response.status, response.responseText, response.responseHeaders); @@ -6236,7 +6236,7 @@ describe("dynamicsWebApi proxy -", function () { }); }); -const expectThrowsAsync = async (method, errorMessage) => { +const expectThrowsAsync = async (method: () => Promise, errorMessage?: string) => { let error = null; try { await method(); diff --git a/tests/main.spec.ts b/tests/main.spec.ts index 73bdade..7432e82 100644 --- a/tests/main.spec.ts +++ b/tests/main.spec.ts @@ -13,6 +13,7 @@ const dynamicsWebApiTest = new DynamicsWebApi({ describe("dynamicsWebApi.create -", function () { before(() => { + //@ts-ignore global.DWA_BROWSER = false; }); @@ -367,6 +368,7 @@ describe("dynamicsWebApi.updateSingleProperty -", function () { describe("dynamicsWebApi.retrieveMultiple -", () => { before(() => { + //@ts-ignore global.DWA_BROWSER = false; }); describe("AbortSignal - multiple requests", () => { @@ -611,7 +613,7 @@ describe("dynamicsWebApi.fetchAll -", () => { describe("dynamicsWebApi.executeBatch -", () => { describe("non-atomic global - create / create (Content-ID in a header gets cleared)", function () { - let scope; + let scope: nock.Scope; const rBody = mocks.data.batchCreateContentIDPayloadNonAtomic; const rBodys = rBody.split("\r\n"); let checkBody = ""; @@ -668,7 +670,7 @@ describe("dynamicsWebApi.executeBatch -", () => { }); describe("non-atomic per request - create / create (Content-ID in a header gets cleared)", function () { - let scope; + let scope: nock.Scope; const rBody = mocks.data.batchCreateContentIDPayloadNonAtomic; const rBodys = rBody.split("\r\n"); let checkBody = ""; @@ -723,7 +725,7 @@ describe("dynamicsWebApi.executeBatch -", () => { }); describe("non-atomic & atomic mixed - create / create (Content-ID in a payload)", function () { - let scope; + let scope: nock.Scope; const rBody = mocks.data.batchCreateContentIDPayloadNonAtomicMixed; const rBodys = rBody.split("\r\n"); let checkBody = ""; @@ -778,7 +780,7 @@ describe("dynamicsWebApi.executeBatch -", () => { }); describe("create / create with Content-ID / No Collection", function () { - let scope; + let scope: nock.Scope; const rBody = mocks.data.batchCreateContentIDNoCollection; const rBodys = rBody.split("\r\n"); let checkBody = ""; @@ -832,7 +834,7 @@ describe("dynamicsWebApi.executeBatch -", () => { }); describe("associate - contentId + relatedKey starts with '$'", function () { - let scope; + let scope: nock.Scope; const rBody = mocks.data.batchAssociateContentIDNoCollection; const rBodys = rBody.split("\r\n"); let checkBody = ""; @@ -1025,7 +1027,7 @@ describe("dynamicsWebApi: custom headers - ", () => { }, headers: { "my-header": "success!" }, }); - let scope; + let scope: nock.Scope; const rBody = mocks.data.batchCreateContentIDPayloadNonAtomicCustomHeaders; const rBodys = rBody.split("\r\n"); let checkBody = ""; @@ -1332,3 +1334,16 @@ describe("dynamicsWebApi.getBackgroundOperationStatus -", () => { }); }); }); + +describe("dynamicsWebApi.Utility.toAbsoluteUrl -", () => { + it("prepends web API URL to provided value", () => { + const value = "accounts(key='value')" + const absoluteUrl = dynamicsWebApiTest.Utility.toAbsoluteUrl(value); + expect(absoluteUrl).to.equal(`${mocks.webApiUrl}${value}`); + + //should remove slash at the beginning + const value2 = "/accounts(key='value')" + const absoluteUrl2 = dynamicsWebApiTest.Utility.toAbsoluteUrl(value2); + expect(absoluteUrl2).to.equal(`${mocks.webApiUrl}${value}`); + }); +}); diff --git a/tests/requests.spec.ts b/tests/requests.spec.ts index 44c3a8b..b798c2d 100644 --- a/tests/requests.spec.ts +++ b/tests/requests.spec.ts @@ -269,3 +269,9 @@ describe("associateSingleValued", () => { } }); }); + +describe("callAction", () => { + it ("multipleUpsert action with @odata.id should not prepend full URL", async () => { + + }); +}); \ No newline at end of file diff --git a/tests/searchApi.spec.ts b/tests/searchApi.spec.ts index 6c443a3..26bf353 100644 --- a/tests/searchApi.spec.ts +++ b/tests/searchApi.spec.ts @@ -31,10 +31,11 @@ const dynamicsWebApiSearchV2NoCompatibility = new DynamicsWebApi({ describe("dynamicsWebApi.query -", () => { before(() => { + //@ts-ignore global.DWA_BROWSER = false; }); describe("basic", () => { - let scope; + let scope: nock.Scope; const searchQuery: Query = { search: "test", }; @@ -67,7 +68,7 @@ describe("dynamicsWebApi.query -", () => { }); }); describe("basic - term parameter", () => { - let scope; + let scope: nock.Scope; const searchQuery: Query = { search: "test", }; @@ -98,7 +99,7 @@ describe("dynamicsWebApi.query -", () => { }); }); describe("impersonate", () => { - let scope; + let scope: nock.Scope; const searchQuery: Query = { search: "test", }; @@ -136,7 +137,7 @@ describe("dynamicsWebApi.query -", () => { }); }); describe("v2.0 - basic, count", () => { - let scope; + let scope: nock.Scope; const searchQuery: Query = { search: "test", count: true, @@ -171,7 +172,7 @@ describe("dynamicsWebApi.query -", () => { }); describe("v2.0 - enableResponseCompatibility = false", () => { - let scope; + let scope: nock.Scope; const searchQuery: Query = { search: "test", count: true, @@ -206,7 +207,7 @@ describe("dynamicsWebApi.query -", () => { }); describe("v1.0 - enableResponseCompatibility = false", () => { - let scope; + let scope: nock.Scope; const searchQuery: Query = { search: "test", returnTotalRecordCount: true, @@ -243,7 +244,7 @@ describe("dynamicsWebApi.query -", () => { describe("dynamicsWebApi.suggest -", () => { describe("basic", () => { - let scope; + let scope: nock.Scope; const suggestQuery: Suggest = { search: "test", }; @@ -276,7 +277,7 @@ describe("dynamicsWebApi.suggest -", () => { }); }); describe("basic - term parameter", () => { - let scope; + let scope: nock.Scope; const suggestQuery: Suggest = { search: "test", }; @@ -307,7 +308,7 @@ describe("dynamicsWebApi.suggest -", () => { }); }); describe("additional header", () => { - let scope; + let scope: nock.Scope; const suggestQuery: Suggest = { search: "test", }; @@ -346,7 +347,7 @@ describe("dynamicsWebApi.suggest -", () => { }); describe("v1.0 - enableResponseCompatibility = false", () => { - let scope; + let scope: nock.Scope; const suggestQuery: Suggest = { search: "test", }; @@ -380,7 +381,7 @@ describe("dynamicsWebApi.suggest -", () => { }); describe("v2.0 - enableResponseCompatibility = false", () => { - let scope; + let scope: nock.Scope; const suggestQuery: Suggest = { search: "test", }; @@ -416,7 +417,7 @@ describe("dynamicsWebApi.suggest -", () => { describe("dynamicsWebApi.autocomplete -", () => { describe("basic", () => { - let scope; + let scope: nock.Scope; const autocompleteQuery: Autocomplete = { search: "test", }; @@ -449,7 +450,7 @@ describe("dynamicsWebApi.autocomplete -", () => { }); }); describe("additional header", () => { - let scope; + let scope: nock.Scope; const autocompleteQuery: Autocomplete = { search: "test", }; @@ -487,7 +488,7 @@ describe("dynamicsWebApi.autocomplete -", () => { }); }); describe("basic - term parameter", () => { - let scope; + let scope: nock.Scope; const autocompleteQuery: Autocomplete = { search: "test", }; @@ -518,7 +519,7 @@ describe("dynamicsWebApi.autocomplete -", () => { }); }); describe("v1.0 - enableResponseCompatibility = false", () => { - let scope; + let scope: nock.Scope; const autocompleteQuery: Autocomplete = { search: "test", }; @@ -551,7 +552,7 @@ describe("dynamicsWebApi.autocomplete -", () => { }); }); describe("v2.0 - enableResponseCompatibility = false", () => { - let scope; + let scope: nock.Scope; const autocompleteQuery: Autocomplete = { search: "test", }; diff --git a/tests/stubs.ts b/tests/stubs.ts index de61b7a..bb2c936 100644 --- a/tests/stubs.ts +++ b/tests/stubs.ts @@ -1753,7 +1753,7 @@ const responseStubs = { }; const utils = { - toTypedArray: (b) => new Uint8Array(b.buffer, b.byteOffset, b.byteLength / Uint8Array.BYTES_PER_ELEMENT), + toTypedArray: (b: any) => new Uint8Array(b.buffer, b.byteOffset, b.byteLength / Uint8Array.BYTES_PER_ELEMENT), }; export { diff --git a/tests/xhr.spec.ts b/tests/xhr.spec.ts index 66b2949..0b802ab 100644 --- a/tests/xhr.spec.ts +++ b/tests/xhr.spec.ts @@ -1,12 +1,13 @@ import { expect } from "chai"; import * as mocks from "./stubs"; -import sinon, { SinonFakeXMLHttpRequest, SinonFakeXMLHttpRequestStatic } from "sinon"; +import sinon, { SinonFakeXMLHttpRequest } from "sinon"; import crypto from "crypto"; import { DynamicsWebApi, RetrieveRequest } from "../src/dynamics-web-api"; import { XhrWrapper } from "../src/client/xhr"; import { DWA } from "../src/dwa"; import * as Utility from "../src/utils/Utility"; +//@ts-ignore import base64 from "Base64"; Utility.setDownloadChunkSize(15); @@ -29,6 +30,7 @@ const requests: SinonFakeXMLHttpRequest[] = []; describe("xhr -", () => { before(function () { + //@ts-ignore global.DWA_BROWSER = true; //@ts-ignore global.window = { @@ -43,7 +45,7 @@ describe("xhr -", () => { after(function () { //@ts-ignore global.XMLHttpRequest.restore(); - + //@ts-ignore global.DWA_BROWSER = false; //@ts-ignore global.window = null; @@ -1127,7 +1129,7 @@ describe("xhr -", () => { it("sends correct headers", function () { expect(requests[0]?.requestHeaders["x-ms-transfer-mode"]).to.be.eq("chunked"); - expect(requests[0]?.requestHeaders["Content-Type"]).not.to.contain('application/json'); + expect(requests[0]?.requestHeaders["Content-Type"]).not.to.contain("application/json"); expect(requests[1]?.requestHeaders["Content-Range"]).to.be.eq( `bytes 0-${beginResponse.responseHeaders["x-ms-chunk-size"] - 1}/${dwaRequest.data.length}`, );