Socket
Socket
Sign inDemoInstall

dynamics-web-api

Package Overview
Dependencies
6
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.1.1

6

dist/dynamics-web-api.d.ts

@@ -1,2 +0,2 @@

/*! dynamics-web-api v2.1.0 (c) 2023 Aleksandr Rogov */
/*! dynamics-web-api v2.1.1 (c) 2023 Aleksandr Rogov */
/// <reference types="node" />

@@ -402,2 +402,4 @@ /**

headers?: HeaderCollection;
/**Custom query parameters. Can be used to set parameter aliases for "$filter" and "$orderBy". Important! These parameters ARE NOT URI encoded! */
queryParams?: string[];
}

@@ -571,4 +573,2 @@ export interface BatchRequest extends BaseRequest {

partitionId?: string;
/**Additional query parameters that either have not been implemented yet or they are parameter aliases for "$filter" and "$orderBy". Important! These parameters ARE NOT URI encoded! */
queryParams?: string[];
}

@@ -575,0 +575,0 @@ export interface AssociateRequest extends Request {

@@ -1,7 +0,7 @@

/*! dynamics-web-api v2.1.0 (c) 2023 Aleksandr Rogov */
"use strict";var _dynamicsWebApiExports=(()=>{var q=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var b=(s,e)=>()=>(s&&(e=s(s=0)),e);var z=(s,e)=>{for(var t in e)q(s,t,{get:e[t],enumerable:!0})},me=(s,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pe(e))!ue.call(s,n)&&n!==t&&q(s,n,{get:()=>e[n],enumerable:!(a=le(e,n))||a.enumerable});return s};var X=s=>me(q({},"__esModule",{value:!0}),s);function de(){return window.crypto}function j(){return de().getRandomValues(new Uint8Array(1))}var Q=b(()=>{"use strict"});function J(s){return!!new RegExp(M,"i").exec(s)}function S(s){let e=new RegExp("^{?("+M+")}?$","i").exec(s);return e?e[1]:null}function F(s){let e=new RegExp("("+M+")\\)$","i").exec(s);return e?e[1]:null}var M,w=b(()=>{"use strict";M="[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}"});var ye,g,c,v=b(()=>{"use strict";Q();w();ye=4194304,g=class g{static buildFunctionParameters(e){if(e){let a=Object.keys(e),n="",r="";for(var t=1;t<=a.length;t++){let l=a[t-1],o=e[l];o!=null&&(typeof o=="string"&&!o.startsWith("Microsoft.Dynamics.CRM")&&!J(o)?o="'"+o+"'":typeof o=="object"&&(o=JSON.stringify(o)),t>1&&(n+=",",r+="&"),n+=l+"=@p"+t,r+="@p"+t+"="+(S(o)||o))}return r&&(r="?"+r),"("+n+")"+r}else return"()"}static getFetchXmlPagingCookie(e="",t=1){e=decodeURIComponent(decodeURIComponent(e));let a=/pagingcookie="(<cookie page="(\d+)".+<\/cookie>)/.exec(e);if(a!=null){let n=parseInt(a[2]);return{cookie:a[1].replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"'").replace(/\'/g,"&quot;"),page:n,nextPage:n+1}}else return{cookie:"",page:t,nextPage:t+1}}static convertToReferenceObject(e){let t=/\/(\w+)\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(e["@odata.id"]);return{id:t[2],collection:t[1],oDataContext:e["@odata.context"]}}static isNull(e){return typeof e>"u"||e==null}static generateUUID(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^j()[0]&15>>e/4).toString(16))}static getXrmContext(){if(typeof GetGlobalContext<"u")return GetGlobalContext();if(typeof Xrm<"u"){if(!g.isNull(Xrm.Utility)&&!g.isNull(Xrm.Utility.getGlobalContext))return Xrm.Utility.getGlobalContext();if(!g.isNull(Xrm.Page)&&!g.isNull(Xrm.Page.context))return Xrm.Page.context}throw new Error("Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.")}static getClientUrl(){let t=g.getXrmContext().getClientUrl();return t.match(/\/$/)&&(t=t.substring(0,t.length-1)),t}static isRunningWithinPortals(){return!!window.shell}static isObject(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&Object.prototype.toString.call(e)!=="[object Date]"}static copyObject(e,t){let a={};for(let n in e)e.hasOwnProperty(n)&&!t?.includes(n)&&(g.isObject(e[n])?a[n]=g.copyObject(e[n]):Array.isArray(e[n])?a[n]=e[n].slice():a[n]=e[n]);return a}static copyRequest(e,t=[]){t.includes("signal")||t.push("signal");let a=g.copyObject(e,t);return a.signal=e.signal,a}static setFileChunk(e,t,a,n){n=n||0;let r=n+a>t.length?t.length%a:a,l;l=new Uint8Array(r);for(let o=0;o<r;o++)l[o]=t[n+o];e.data=l,e.contentRange="bytes "+n+"-"+(n+r-1)+"/"+t.length}static convertToFileBuffer(e){let t=new Uint8Array(e.length);for(var a=0;a<e.length;a++)t[a]=e.charCodeAt(a);return t}};g.downloadChunkSize=ye;c=g});function C(s,e,t){throw new Error(t?`${s} requires a ${e} parameter to be of type ${t}.`:`${s} requires a ${e} parameter.`)}var i,P=b(()=>{"use strict";w();i=class s{static handleErrorResponse(e){throw new Error(`Error: ${e.status}: ${e.message}`)}static parameterCheck(e,t,a,n){(typeof e>"u"||e===null||e==="")&&C(t,a,n)}static stringParameterCheck(e,t,a){typeof e!="string"&&C(t,a,"String")}static maxLengthStringParameterCheck(e,t,a,n){if(e&&e.length>n)throw new Error(`${a} has a ${n} character limit.`)}static arrayParameterCheck(e,t,a){e.constructor!==Array&&C(t,a,"Array")}static stringOrArrayParameterCheck(e,t,a){e.constructor!==Array&&typeof e!="string"&&C(t,a,"String or Array")}static numberParameterCheck(e,t,a){if(typeof e!="number"){if(typeof e=="string"&&e&&!isNaN(parseInt(e)))return;C(t,a,"Number")}}static batchIsEmpty(){return[new Error("Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.")]}static handleHttpError(e,t){let a=new Error;return Object.keys(e).forEach(n=>{a[n]=e[n]}),t&&Object.keys(t).forEach(n=>{a[n]=t[n]}),a}static boolParameterCheck(e,t,a){typeof e!="boolean"&&C(t,a,"Boolean")}static guidParameterCheck(e,t,a){let n=S(e);return n||C(t,a,"GUID String"),n}static keyParameterCheck(e,t,a){try{s.stringParameterCheck(e,t,a);let n=S(e);if(n)return n;let r=e.split(",");if(r.length)for(let l=0;l<r.length;l++)r[l]=r[l].trim().replace(/"/g,"'"),/^[\w\d\_]+\=(.+)$/i.exec(r[l])[0];return r.join(",")}catch{C(t,a,"String representing GUID or Alternate Key")}}static callbackParameterCheck(e,t,a){typeof e!="function"&&C(t,a,"Function")}static throwBatchIncompatible(e,t){if(t)throw t=!1,new Error(e+" cannot be used in a BATCH request.")}static throwBatchNotStarted(e){if(!e)throw new Error("Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.")}}});var D,E,$,A,Z=b(()=>{"use strict";$=class ${};$.Prefer=(E=class{static get(e){return`${$.Prefer.IncludeAnnotations}="${e}"`}},E.ReturnRepresentation="return=representation",E.Annotations=(D=class{},D.AssociatedNavigationProperty="Microsoft.Dynamics.CRM.associatednavigationproperty",D.LookupLogicalName="Microsoft.Dynamics.CRM.lookuplogicalname",D.All="*",D.FormattedValue="OData.Community.Display.V1.FormattedValue",D.FetchXmlPagingCookie="Microsoft.Dynamics.CRM.fetchxmlpagingcookie",D),E.IncludeAnnotations="odata.include-annotations",E);A=$});function K(s,e){if(typeof e=="string"){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:Z|[-+]\d{2}:\d{2})$/.exec(e);if(t)return new Date(Date.UTC(+t[1],+t[2]-1,+t[3],+t[4],+t[5],+t[6]))}return e}var Y=b(()=>{"use strict"});function G(s,e){let t=null;if(s.indexOf("@")!==-1){let a=s.split("@");switch(a[1]){case"odata.context":t="oDataContext";break;case"odata.count":t="oDataCount",e=e!=null?parseInt(e):0;break;case"odata.nextLink":t="oDataNextLink";break;case"odata.deltaLink":t="oDataDeltaLink";break;case A.Prefer.Annotations.FormattedValue:t=a[0]+"_Formatted";break;case A.Prefer.Annotations.AssociatedNavigationProperty:t=a[0]+"_NavigationProperty";break;case A.Prefer.Annotations.LookupLogicalName:t=a[0]+"_LogicalName";break}}return[t,e]}function B(s,e){if(e){if(e.isRef&&s["@odata.id"]!=null)return c.convertToReferenceObject(s);if(e.toCount)return G("@odata.count",s["@odata.count"])[1]||0}let t=Object.keys(s);for(let n=0;n<t.length;n++){let r=t[n];if(s[r]!=null)if(s[r].constructor===Array)for(var a=0;a<s[r].length;a++)s[r][a]=B(s[r][a]);else typeof s[r]=="object"&&B(s[r]);let l=G(r,s[r]);if(l[0]&&(s[l[0]]=l[1]),r.indexOf("_x002e_")!==-1){let o=r.split("_x002e_");if(!s.hasOwnProperty(o[0]))s[o[0]]={_dwaType:"alias"};else if(typeof s[o[0]]!="object"||typeof s[o[0]]=="object"&&!s[o[0]].hasOwnProperty("_dwaType"))throw new Error("The alias name of the linked entity must be unique!");s[o[0]][o[1]]=s[r],l=G(o[1],s[r]),l[0]&&(s[o[0]][l[0]]=l[1])}}return e&&e.hasOwnProperty("pageNumber")&&s["@"+A.Prefer.Annotations.FetchXmlPagingCookie]!=null&&(s.PagingInfo=c.getFetchXmlPagingCookie(s["@"+A.Prefer.Annotations.FetchXmlPagingCookie],e.pageNumber)),s}function ge(s){let e={position:0},t={},a,n,r;do r=e.position,n=Re(s,e),a=fe.exec(n),a!==null?t[a[1].toLowerCase()]=a[2]:e.position=r;while(n&&a);return t}function Re(s,e){return be(s,e,`\r
/*! dynamics-web-api v2.1.1 (c) 2023 Aleksandr Rogov */
"use strict";var _dynamicsWebApiExports=(()=>{var q=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var C=(s,e)=>()=>(s&&(e=s(s=0)),e);var z=(s,e)=>{for(var t in e)q(s,t,{get:e[t],enumerable:!0})},me=(s,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pe(e))!ue.call(s,n)&&n!==t&&q(s,n,{get:()=>e[n],enumerable:!(a=le(e,n))||a.enumerable});return s};var X=s=>me(q({},"__esModule",{value:!0}),s);function de(){return window.crypto}function j(){return de().getRandomValues(new Uint8Array(1))}var Q=C(()=>{"use strict"});function J(s){return!!new RegExp(M,"i").exec(s)}function S(s){let e=new RegExp("^{?("+M+")}?$","i").exec(s);return e?e[1]:null}function _(s){let e=new RegExp("("+M+")\\)$","i").exec(s);return e?e[1]:null}var M,$=C(()=>{"use strict";M="[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}"});var ye,g,c,W=C(()=>{"use strict";Q();$();ye=4194304,g=class{static buildFunctionParameters(e){if(e){let a=Object.keys(e),n="",r="";for(var t=1;t<=a.length;t++){let l=a[t-1],o=e[l];o!=null&&(typeof o=="string"&&!o.startsWith("Microsoft.Dynamics.CRM")&&!J(o)?o="'"+o+"'":typeof o=="object"&&(o=JSON.stringify(o)),t>1&&(n+=",",r+="&"),n+=l+"=@p"+t,r+="@p"+t+"="+(S(o)||o))}return r&&(r="?"+r),"("+n+")"+r}else return"()"}static getFetchXmlPagingCookie(e="",t=1){e=decodeURIComponent(decodeURIComponent(e));let a=/pagingcookie="(<cookie page="(\d+)".+<\/cookie>)/.exec(e);if(a!=null){let n=parseInt(a[2]);return{cookie:a[1].replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"'").replace(/\'/g,"&quot;"),page:n,nextPage:n+1}}else return{cookie:"",page:t,nextPage:t+1}}static convertToReferenceObject(e){let t=/\/(\w+)\(([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})/i.exec(e["@odata.id"]);return{id:t[2],collection:t[1],oDataContext:e["@odata.context"]}}static isNull(e){return typeof e>"u"||e==null}static generateUUID(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^j()[0]&15>>e/4).toString(16))}static getXrmContext(){if(typeof GetGlobalContext<"u")return GetGlobalContext();if(typeof Xrm<"u"){if(!g.isNull(Xrm.Utility)&&!g.isNull(Xrm.Utility.getGlobalContext))return Xrm.Utility.getGlobalContext();if(!g.isNull(Xrm.Page)&&!g.isNull(Xrm.Page.context))return Xrm.Page.context}throw new Error("Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.")}static getClientUrl(){let t=g.getXrmContext().getClientUrl();return t.match(/\/$/)&&(t=t.substring(0,t.length-1)),t}static isRunningWithinPortals(){return!!window.shell}static isObject(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&Object.prototype.toString.call(e)!=="[object Date]"}static copyObject(e,t){let a={};for(let n in e)e.hasOwnProperty(n)&&!t?.includes(n)&&(g.isObject(e[n])?a[n]=g.copyObject(e[n]):Array.isArray(e[n])?a[n]=e[n].slice():a[n]=e[n]);return a}static copyRequest(e,t=[]){t.includes("signal")||t.push("signal");let a=g.copyObject(e,t);return a.signal=e.signal,a}static setFileChunk(e,t,a,n){n=n||0;let r=n+a>t.length?t.length%a:a,l;l=new Uint8Array(r);for(let o=0;o<r;o++)l[o]=t[n+o];e.data=l,e.contentRange="bytes "+n+"-"+(n+r-1)+"/"+t.length}static convertToFileBuffer(e){let t=new Uint8Array(e.length);for(var a=0;a<e.length;a++)t[a]=e.charCodeAt(a);return t}},c=g;c.downloadChunkSize=ye});function A(s,e,t){throw new Error(t?`${s} requires a ${e} parameter to be of type ${t}.`:`${s} requires a ${e} parameter.`)}var i,k=C(()=>{"use strict";$();i=class{static handleErrorResponse(e){throw new Error(`Error: ${e.status}: ${e.message}`)}static parameterCheck(e,t,a,n){(typeof e>"u"||e===null||e==="")&&A(t,a,n)}static stringParameterCheck(e,t,a){typeof e!="string"&&A(t,a,"String")}static maxLengthStringParameterCheck(e,t,a,n){if(e&&e.length>n)throw new Error(`${a} has a ${n} character limit.`)}static arrayParameterCheck(e,t,a){e.constructor!==Array&&A(t,a,"Array")}static stringOrArrayParameterCheck(e,t,a){e.constructor!==Array&&typeof e!="string"&&A(t,a,"String or Array")}static numberParameterCheck(e,t,a){if(typeof e!="number"){if(typeof e=="string"&&e&&!isNaN(parseInt(e)))return;A(t,a,"Number")}}static batchIsEmpty(){return[new Error("Payload of the batch operation is empty. Please make that you have other operations in between startBatch() and executeBatch() to successfuly build a batch payload.")]}static handleHttpError(e,t){let a=new Error;return Object.keys(e).forEach(n=>{a[n]=e[n]}),t&&Object.keys(t).forEach(n=>{a[n]=t[n]}),a}static boolParameterCheck(e,t,a){typeof e!="boolean"&&A(t,a,"Boolean")}static guidParameterCheck(e,t,a){let n=S(e);return n||A(t,a,"GUID String"),n}static keyParameterCheck(e,t,a){try{i.stringParameterCheck(e,t,a);let n=S(e);if(n)return n;let r=e.split(",");if(r.length)for(let l=0;l<r.length;l++)r[l]=r[l].trim().replace(/"/g,"'"),/^[\w\d\_]+\=(.+)$/i.exec(r[l])[0];return r.join(",")}catch{A(t,a,"String representing GUID or Alternate Key")}}static callbackParameterCheck(e,t,a){typeof e!="function"&&A(t,a,"Function")}static throwBatchIncompatible(e,t){if(t)throw t=!1,new Error(e+" cannot be used in a BATCH request.")}static throwBatchNotStarted(e){if(!e)throw new Error("Batch operation has not been started. Please call a DynamicsWebApi.startBatch() function prior to calling DynamicsWebApi.executeBatch() to perform a batch request correctly.")}}});var T,E,K,x,Z=C(()=>{"use strict";K=class{},x=K;x.Prefer=(E=class{static get(e){return`${K.Prefer.IncludeAnnotations}="${e}"`}},E.ReturnRepresentation="return=representation",E.Annotations=(T=class{},T.AssociatedNavigationProperty="Microsoft.Dynamics.CRM.associatednavigationproperty",T.LookupLogicalName="Microsoft.Dynamics.CRM.lookuplogicalname",T.All="*",T.FormattedValue="OData.Community.Display.V1.FormattedValue",T.FetchXmlPagingCookie="Microsoft.Dynamics.CRM.fetchxmlpagingcookie",T),E.IncludeAnnotations="odata.include-annotations",E)});function G(s,e){if(typeof e=="string"){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:Z|[-+]\d{2}:\d{2})$/.exec(e);if(t)return new Date(Date.UTC(+t[1],+t[2]-1,+t[3],+t[4],+t[5],+t[6]))}return e}var Y=C(()=>{"use strict"});function V(s,e){let t=null;if(s.indexOf("@")!==-1){let a=s.split("@");switch(a[1]){case"odata.context":t="oDataContext";break;case"odata.count":t="oDataCount",e=e!=null?parseInt(e):0;break;case"odata.nextLink":t="oDataNextLink";break;case"odata.deltaLink":t="oDataDeltaLink";break;case x.Prefer.Annotations.FormattedValue:t=a[0]+"_Formatted";break;case x.Prefer.Annotations.AssociatedNavigationProperty:t=a[0]+"_NavigationProperty";break;case x.Prefer.Annotations.LookupLogicalName:t=a[0]+"_LogicalName";break}}return[t,e]}function B(s,e){if(e){if(e.isRef&&s["@odata.id"]!=null)return c.convertToReferenceObject(s);if(e.toCount)return V("@odata.count",s["@odata.count"])[1]||0}let t=Object.keys(s);for(let n=0;n<t.length;n++){let r=t[n];if(s[r]!=null)if(s[r].constructor===Array)for(var a=0;a<s[r].length;a++)s[r][a]=B(s[r][a]);else typeof s[r]=="object"&&B(s[r]);let l=V(r,s[r]);if(l[0]&&(s[l[0]]=l[1]),r.indexOf("_x002e_")!==-1){let o=r.split("_x002e_");if(!s.hasOwnProperty(o[0]))s[o[0]]={_dwaType:"alias"};else if(typeof s[o[0]]!="object"||typeof s[o[0]]=="object"&&!s[o[0]].hasOwnProperty("_dwaType"))throw new Error("The alias name of the linked entity must be unique!");s[o[0]][o[1]]=s[r],l=V(o[1],s[r]),l[0]&&(s[o[0]][l[0]]=l[1])}}return e&&e.hasOwnProperty("pageNumber")&&s["@"+x.Prefer.Annotations.FetchXmlPagingCookie]!=null&&(s.PagingInfo=c.getFetchXmlPagingCookie(s["@"+x.Prefer.Annotations.FetchXmlPagingCookie],e.pageNumber)),s}function ge(s){let e={position:0},t={},a,n,r;do r=e.position,n=Re(s,e),a=fe.exec(n),a!==null?t[a[1].toLowerCase()]=a[2]:e.position=r;while(n&&a);return t}function Re(s,e){return be(s,e,`\r
`)}function be(s,e,t){let a=e.position||0,n=s.length;if(t){if(n=s.indexOf(t,a),n===-1)return null;e.position=n+t.length}else e.position=n;return s.substring(a,n)}function ee(s,e,t=0){let a=s.substr(0,s.indexOf(`\r
`)),n=s.split(a);n.shift(),n.pop();let r=[];for(let l=0;l<n.length;l++){let o=n[l];if(o.indexOf("--changesetresponse_")>-1){o=o.trim();let u=o.substring(o.indexOf(`\r
`)+1).trim();r=r.concat(ee(u,e,t))}else{let u=/HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/gm.exec(o),p=parseInt(u[1]),m=u[2].trim(),f=o.substring(o.indexOf("{"),o.lastIndexOf("}")+1);if(f){let d=B(JSON.parse(f,K),e[t]);if(p>=400){let R=ge(o.substring(o.indexOf(u[0])+u[0].length+1,o.indexOf("{")));r.push(i.handleHttpError(d,{status:p,statusText:m,statusMessage:m,headers:R}))}else r.push(d)}else if(/Content-Type: text\/plain/i.test(o)){let d=/\w+$/gi.exec(o.trim()),R=d&&d.length?d[0]:void 0;r.push(isNaN(Number(R))?R:Number(R))}else if(e.length&&e[t]&&e[t].hasOwnProperty("valueIfEmpty"))r.push(e[t].valueIfEmpty);else{let d=/OData-EntityId.+/i.exec(o);if(d&&d.length){let R=F(d[0]);r.push(R||void 0)}else r.push(void 0)}}t++}return r}function Ce(s){return window.atob(s)}function Ae(s,e,t){let a=s;t.hasOwnProperty("parse")&&(a=JSON.parse(a).value,a=Ce(a));var n={value:a};return e["x-ms-file-name"]&&(n.fileName=e["x-ms-file-name"]),e["x-ms-file-size"]&&(n.fileSize=parseInt(e["x-ms-file-size"])),O(e,"Location")&&(n.location=U(e,"Location")),n}function O(s,e){return s.hasOwnProperty(e)||s.hasOwnProperty(e.toLowerCase())}function U(s,e){return s[e]?s[e]:s[e.toLowerCase()]}function V(s,e,t){let a;if(s.length)if(s.indexOf("--batchresponse_")>-1){let n=ee(s,t);a=t.length===1&&t[0].convertedToBatch?n[0]:n}else O(e,"Content-Disposition")?a=Ae(s,e,t[0]):U(e,"Content-Type").startsWith("application/json")?a=B(JSON.parse(s,K),t[0]):a=isNaN(Number(s))?s:Number(s);else if(t.length&&t[0].hasOwnProperty("valueIfEmpty"))a=t[0].valueIfEmpty;else if(O(e,"OData-EntityId")){let n=U(e,"OData-EntityId"),r=F(n);r&&(a=r)}else O(e,"Location")&&(a={location:U(e,"Location")},e["x-ms-chunk-size"]&&(a.chunkSize=parseInt(e["x-ms-chunk-size"])));return a}var fe,te=b(()=>{"use strict";Z();v();P();Y();w();fe=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/});function T(s){let e={};if(!s)return e;let t=s.split(`\r
`);for(let a=0,n=t.length;a<n;a++){let r=t[a],l=r.indexOf(": ");l>0&&(e[r.substring(0,l)]=r.substring(l+2))}return e}var ne=b(()=>{"use strict"});var ae={};z(ae,{XhrWrapper:()=>I,executeRequest:()=>xe});function xe(s){return new Promise((e,t)=>{Pe(s,e,t)})}function Pe(s,e,t){let a=s.data,n=s.additionalHeaders,r=s.responseParams,l=s.abortSignal;if(l?.aborted){t(i.handleHttpError({name:"AbortError",code:20,message:"The user aborted a request."}));return}let o=new XMLHttpRequest;o.open(s.method,s.uri,s.isAsync||!1);for(let p in n)o.setRequestHeader(p,n[p]);o.onreadystatechange=function(){if(o.readyState===4)switch(l&&l.removeEventListener("abort",u),o.status){case 200:case 201:case 204:case 206:case 304:{let d=T(o.getAllResponseHeaders()),ce={data:V(o.responseText,d,r[s.requestId]),headers:d,status:o.status};o=null,e(ce);break}case 0:break;default:if(!o)break;let p,m;try{m=T(o.getAllResponseHeaders());let d=V(o.responseText,m,r[s.requestId]);if(Array.isArray(d)){t(d);break}p=d.error}catch{o.response.length>0?p={message:o.response}:p={message:"Unexpected Error"}}let f={status:o.status,statusText:o.statusText,headers:m};o=null,t(i.handleHttpError(p,f));break}},s.timeout&&(o.timeout=s.timeout),o.onerror=function(){let p=T(o.getAllResponseHeaders());t(i.handleHttpError({status:o.status,statusText:o.statusText,message:o.responseText||"Network Error",headers:p})),o=null},o.ontimeout=function(){let p=T(o.getAllResponseHeaders());t(i.handleHttpError({name:"TimeoutError",status:o.status,statusText:o.statusText,message:o.responseText||"Request Timed Out",headers:p})),o=null},o.onabort=function(){if(!o)return;let p=T(o.getAllResponseHeaders());t(i.handleHttpError({status:o.status,statusText:o.statusText,message:"Request aborted",headers:p})),o=null};let u=()=>{if(!o)return;let p=T(o.getAllResponseHeaders());t(i.handleHttpError({name:"AbortError",code:20,status:o.status,statusText:o.statusText,message:"The user aborted a request.",headers:p})),o.abort(),o=null};l&&l.addEventListener("abort",u),a?o.send(a):o.send(),I.afterSendEvent&&I.afterSendEvent()}var I,ie=b(()=>{"use strict";P();te();ne();I=class{}});var De={};z(De,{DynamicsWebApi:()=>L});v();P();var he=(s,e)=>c.isRunningWithinPortals()?`${window.location.origin}/_api/`:(s||(s=c.getClientUrl()),`${s}/api/${e.path}/v${e.version}/`),_=(s,e,t)=>{let a=t[e];s?.version&&(i.stringParameterCheck(s.version,"DynamicsWebApi.setConfig",`config.${e}.version`),a.version=s.version),s?.path&&(i.stringParameterCheck(s.path,"DynamicsWebApi.setConfig",`config.${e}.path`),a.path=s.path),a.url=he(t.serverUrl,a)},k=class{static merge(e,t){t?.serverUrl&&(i.stringParameterCheck(t.serverUrl,"DynamicsWebApi.setConfig","config.serverUrl"),e.serverUrl=t.serverUrl),_(t?.dataApi,"dataApi",e),_(t?.searchApi,"searchApi",e),t?.impersonate&&(e.impersonate=i.guidParameterCheck(t.impersonate,"DynamicsWebApi.setConfig","config.impersonate")),t?.impersonateAAD&&(e.impersonateAAD=i.guidParameterCheck(t.impersonateAAD,"DynamicsWebApi.setConfig","config.impersonateAAD")),t?.onTokenRefresh&&(i.callbackParameterCheck(t.onTokenRefresh,"DynamicsWebApi.setConfig","config.onTokenRefresh"),e.onTokenRefresh=t.onTokenRefresh),t?.includeAnnotations&&(i.stringParameterCheck(t.includeAnnotations,"DynamicsWebApi.setConfig","config.includeAnnotations"),e.includeAnnotations=t.includeAnnotations),t?.timeout&&(i.numberParameterCheck(t.timeout,"DynamicsWebApi.setConfig","config.timeout"),e.timeout=t.timeout),t?.maxPageSize&&(i.numberParameterCheck(t.maxPageSize,"DynamicsWebApi.setConfig","config.maxPageSize"),e.maxPageSize=t.maxPageSize),t?.returnRepresentation&&(i.boolParameterCheck(t.returnRepresentation,"DynamicsWebApi.setConfig","config.returnRepresentation"),e.returnRepresentation=t.returnRepresentation),t?.useEntityNames&&(i.boolParameterCheck(t.useEntityNames,"DynamicsWebApi.setConfig","config.useEntityNames"),e.useEntityNames=t.useEntityNames),t?.headers&&(e.headers=t.headers)}static default(){return{serverUrl:null,impersonate:null,impersonateAAD:null,onTokenRefresh:null,includeAnnotations:null,maxPageSize:null,returnRepresentation:null,proxy:null,dataApi:{path:"data",version:"9.2",url:""},searchApi:{path:"search",version:"1.0",url:""}}}};k.mergeApiConfigs=_;v();P();v();v();P();var h=class h{static compose(e,t){if(e.path=e.path||"",e.functionName=e.functionName||"",e.url)i.stringParameterCheck(e.url,`DynamicsWebApi.${e.functionName}`,"request.url"),e.path=e.url.replace(t.dataApi.url,""),e.path=h.composeUrl(e,t,e.path);else if(!e._isUnboundRequest&&!e.collection&&i.parameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.collection!=null&&(i.stringParameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.path=e.collection,e.contentId&&(i.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")&&(e.path=`${e.contentId}/${e.path}`)),e.key&&(e.key=i.keyParameterCheck(e.key,`DynamicsWebApi.${e.functionName}`,"request.key"),e.path+=`(${e.key})`)),e._additionalUrl&&(e.path&&(e.path+="/"),e.path+=e._additionalUrl),e.path=h.composeUrl(e,t,e.path),e.fetchXml){i.stringParameterCheck(e.fetchXml,`DynamicsWebApi.${e.functionName}`,"request.fetchXml");let a=e.path.indexOf("?")===-1?"?":"&";e.path+=`${a}fetchXml=${encodeURIComponent(e.fetchXml)}`}return e.hasOwnProperty("async")&&e.async!=null?i.boolParameterCheck(e.async,`DynamicsWebApi.${e.functionName}`,"request.async"):e.async=!0,e.headers=h.composeHeaders(e,t),e}static composeUrl(e,t,a="",n="&"){let r=[];if(e){if(e.navigationProperty){if(i.stringParameterCheck(e.navigationProperty,`DynamicsWebApi.${e.functionName}`,"request.navigationProperty"),a+="/"+e.navigationProperty,e.navigationPropertyKey){let l=i.keyParameterCheck(e.navigationPropertyKey,`DynamicsWebApi.${e.functionName}`,"request.navigationPropertyKey");a+="("+l+")"}e.navigationProperty==="Attributes"&&e.metadataAttributeType&&(i.stringParameterCheck(e.metadataAttributeType,`DynamicsWebApi.${e.functionName}`,"request.metadataAttributeType"),a+="/"+e.metadataAttributeType)}if(e.select?.length&&(i.arrayParameterCheck(e.select,`DynamicsWebApi.${e.functionName}`,"request.select"),e.functionName=="retrieve"&&e.select.length==1&&e.select[0].endsWith("/$ref")?a+="/"+e.select[0]:(e.select[0].startsWith("/")&&e.functionName=="retrieve"&&(e.navigationProperty==null?a+=e.select.shift():e.select.shift()),e.select.length&&r.push("$select="+e.select.join(",")))),e.filter){i.stringParameterCheck(e.filter,`DynamicsWebApi.${e.functionName}`,"request.filter");let l=/[^"']{([\w\d]{8}[-]?(?:[\w\d]{4}[-]?){3}[\w\d]{12})}(?:[^"']|$)/g,o=e.filter,u=null;for(;(u=l.exec(o))!==null;){u.index===l.lastIndex&&l.lastIndex++;let p=u[0].endsWith(")")?")":" ";o=o.replace(u[0]," "+u[1]+p)}r.push("$filter="+encodeURIComponent(o))}if(e.fieldName&&(i.stringParameterCheck(e.fieldName,`DynamicsWebApi.${e.functionName}`,"request.fieldName"),a+="/"+e.fieldName),e.savedQuery&&r.push("savedQuery="+i.guidParameterCheck(e.savedQuery,`DynamicsWebApi.${e.functionName}`,"request.savedQuery")),e.userQuery&&r.push("userQuery="+i.guidParameterCheck(e.userQuery,`DynamicsWebApi.${e.functionName}`,"request.userQuery")),e.apply&&(i.stringParameterCheck(e.apply,`DynamicsWebApi.${e.functionName}`,"request.apply"),r.push("$apply="+e.apply)),e.count&&(i.boolParameterCheck(e.count,`DynamicsWebApi.${e.functionName}`,"request.count"),r.push("$count="+e.count)),e.top&&e.top>0&&(i.numberParameterCheck(e.top,`DynamicsWebApi.${e.functionName}`,"request.top"),r.push("$top="+e.top)),e.orderBy!=null&&e.orderBy.length&&(i.arrayParameterCheck(e.orderBy,`DynamicsWebApi.${e.functionName}`,"request.orderBy"),r.push("$orderby="+e.orderBy.join(","))),e.partitionId&&(i.stringParameterCheck(e.partitionId,`DynamicsWebApi.${e.functionName}`,"request.partitionId"),r.push("partitionid='"+e.partitionId+"'")),e.downloadSize&&(i.stringParameterCheck(e.downloadSize,`DynamicsWebApi.${e.functionName}`,"request.downloadSize"),r.push("size="+e.downloadSize)),e.queryParams?.length&&(i.arrayParameterCheck(e.queryParams,`DynamicsWebApi.${e.functionName}`,"request.queryParams"),r.push(e.queryParams.join("&"))),e.fileName&&(i.stringParameterCheck(e.fileName,`DynamicsWebApi.${e.functionName}`,"request.fileName"),r.push("x-ms-file-name="+e.fileName)),e.data&&i.parameterCheck(e.data,`DynamicsWebApi.${e.functionName}`,"request.data"),e.isBatch&&i.boolParameterCheck(e.isBatch,`DynamicsWebApi.${e.functionName}`,"request.isBatch"),c.isNull(e.inChangeSet)||i.boolParameterCheck(e.inChangeSet,`DynamicsWebApi.${e.functionName}`,"request.inChangeSet"),e.isBatch&&c.isNull(e.inChangeSet)&&(e.inChangeSet=!0),e.timeout&&i.numberParameterCheck(e.timeout,`DynamicsWebApi.${e.functionName}`,"request.timeout"),e.expand?.length)if(i.stringOrArrayParameterCheck(e.expand,`DynamicsWebApi.${e.functionName}`,"request.expand"),typeof e.expand=="string")r.push("$expand="+e.expand);else{let l=[];for(let o=0;o<e.expand.length;o++)if(e.expand[o].property){let u=e.expand[o];u.functionName=`${e.functionName} $expand`;let p=h.composeUrl(u,t,"",";");p&&(p=`(${p.substr(1)})`),l.push(e.expand[o].property+p)}l.length&&r.push("$expand="+l.join(","))}}return r.length?a+"?"+r.join(n):a}static composeHeaders(e,t){let a={...t.headers,...e.userHeaders},n=h.composePreferHeader(e,t);if(n.length&&(a.Prefer=n),e.collection==="$metadata"&&(a.Accept="application/xml"),e.transferMode&&(a["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&&(i.stringParameterCheck(e.ifmatch,`DynamicsWebApi.${e.functionName}`,"request.ifmatch"),a["If-Match"]=e.ifmatch),e.ifnonematch&&(i.stringParameterCheck(e.ifnonematch,`DynamicsWebApi.${e.functionName}`,"request.ifnonematch"),a["If-None-Match"]=e.ifnonematch),e.impersonate&&(i.stringParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate"),a.MSCRMCallerID=i.guidParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate")),e.impersonateAAD&&(i.stringParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD"),a.CallerObjectId=i.guidParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD")),e.token&&(i.stringParameterCheck(e.token,`DynamicsWebApi.${e.functionName}`,"request.token"),a.Authorization="Bearer "+e.token),e.duplicateDetection&&(i.boolParameterCheck(e.duplicateDetection,`DynamicsWebApi.${e.functionName}`,"request.duplicateDetection"),a["MSCRM.SuppressDuplicateDetection"]="false"),e.bypassCustomPluginExecution&&(i.boolParameterCheck(e.bypassCustomPluginExecution,`DynamicsWebApi.${e.functionName}`,"request.bypassCustomPluginExecution"),a["MSCRM.BypassCustomPluginExecution"]="true"),e.noCache&&(i.boolParameterCheck(e.noCache,`DynamicsWebApi.${e.functionName}`,"request.noCache"),a["Cache-Control"]="no-cache"),e.mergeLabels&&(i.boolParameterCheck(e.mergeLabels,`DynamicsWebApi.${e.functionName}`,"request.mergeLabels"),a["MSCRM.MergeLabels"]="true"),e.contentId&&(i.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")||(a["Content-ID"]=e.contentId)),e.contentRange&&(i.stringParameterCheck(e.contentRange,`DynamicsWebApi.${e.functionName}`,"request.contentRange"),a["Content-Range"]=e.contentRange),e.range&&(i.stringParameterCheck(e.range,`DynamicsWebApi.${e.functionName}`,"request.range"),a.Range=e.range),a}static composePreferHeader(e,t){let a=e.returnRepresentation,n=e.includeAnnotations,r=e.maxPageSize,l=e.trackChanges,o=e.continueOnError,u=[];if(e.prefer&&e.prefer.length){i.stringOrArrayParameterCheck(e.prefer,`DynamicsWebApi.${e.functionName}`,"request.prefer"),typeof e.prefer=="string"&&(u=e.prefer.split(","));for(let p in u){let m=u[p].trim();m==="return=representation"?a=!0:m.includes("odata.include-annotations=")?n=m.replace("odata.include-annotations=","").replace(/"/g,""):m.startsWith("odata.maxpagesize=")?r=Number(m.replace("odata.maxpagesize=","").replace(/"/g,""))||0:m.includes("odata.track-changes")?l=!0:m.includes("odata.continue-on-error")&&(o=!0)}}return u=[],t&&(a==null&&(a=t.returnRepresentation),n=n||t.includeAnnotations,r=r||t.maxPageSize),a&&(i.boolParameterCheck(a,`DynamicsWebApi.${e.functionName}`,"request.returnRepresentation"),u.push("return=representation")),n&&(i.stringParameterCheck(n,`DynamicsWebApi.${e.functionName}`,"request.includeAnnotations"),u.push(`odata.include-annotations="${n}"`)),r&&r>0&&(i.numberParameterCheck(r,`DynamicsWebApi.${e.functionName}`,"request.maxPageSize"),u.push("odata.maxpagesize="+r)),l&&(i.boolParameterCheck(l,`DynamicsWebApi.${e.functionName}`,"request.trackChanges"),u.push("odata.track-changes")),o&&(i.boolParameterCheck(o,`DynamicsWebApi.${e.functionName}`,"request.continueOnError"),u.push("odata.continue-on-error")),u.join(",")}static convertToBatch(e,t,a){let n=`dwa_batch_${c.generateUUID()}`,r=[],l=null,o=1e5;e.forEach(p=>{p.functionName="executeBatch",a?.inChangeSet===!1&&(p.inChangeSet=!1);let m=p.method==="GET"?!1:!!p.inChangeSet;if(!m&&l&&(r.push(`
`)+1).trim();r=r.concat(ee(u,e,t))}else{let u=/HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/gm.exec(o),p=parseInt(u[1]),m=u[2].trim(),f=o.substring(o.indexOf("{"),o.lastIndexOf("}")+1);if(f){let d=B(JSON.parse(f,G),e[t]);if(p>=400){let b=ge(o.substring(o.indexOf(u[0])+u[0].length+1,o.indexOf("{")));r.push(i.handleHttpError(d,{status:p,statusText:m,statusMessage:m,headers:b}))}else r.push(d)}else if(/Content-Type: text\/plain/i.test(o)){let d=/\w+$/gi.exec(o.trim()),b=d&&d.length?d[0]:void 0;r.push(isNaN(Number(b))?b:Number(b))}else if(e.length&&e[t]&&e[t].hasOwnProperty("valueIfEmpty"))r.push(e[t].valueIfEmpty);else{let d=/OData-EntityId.+/i.exec(o);if(d&&d.length){let b=_(d[0]);r.push(b||void 0)}else r.push(void 0)}}t++}return r}function Ce(s){return window.atob(s)}function Ae(s,e,t){let a=s;t.hasOwnProperty("parse")&&(a=JSON.parse(a).value,a=Ce(a));var n={value:a};return e["x-ms-file-name"]&&(n.fileName=e["x-ms-file-name"]),e["x-ms-file-size"]&&(n.fileSize=parseInt(e["x-ms-file-size"])),O(e,"Location")&&(n.location=U(e,"Location")),n}function O(s,e){return s.hasOwnProperty(e)||s.hasOwnProperty(e.toLowerCase())}function U(s,e){return s[e]?s[e]:s[e.toLowerCase()]}function H(s,e,t){let a;if(s.length)if(s.indexOf("--batchresponse_")>-1){let n=ee(s,t);a=t.length===1&&t[0].convertedToBatch?n[0]:n}else O(e,"Content-Disposition")?a=Ae(s,e,t[0]):U(e,"Content-Type").startsWith("application/json")?a=B(JSON.parse(s,G),t[0]):a=isNaN(Number(s))?s:Number(s);else if(t.length&&t[0].hasOwnProperty("valueIfEmpty"))a=t[0].valueIfEmpty;else if(O(e,"OData-EntityId")){let n=U(e,"OData-EntityId"),r=_(n);r&&(a=r)}else O(e,"Location")&&(a={location:U(e,"Location")},e["x-ms-chunk-size"]&&(a.chunkSize=parseInt(e["x-ms-chunk-size"])));return a}var fe,te=C(()=>{"use strict";Z();W();k();Y();$();fe=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/});function v(s){let e={};if(!s)return e;let t=s.split(`\r
`);for(let a=0,n=t.length;a<n;a++){let r=t[a],l=r.indexOf(": ");l>0&&(e[r.substring(0,l)]=r.substring(l+2))}return e}var ne=C(()=>{"use strict"});var ae={};z(ae,{XhrWrapper:()=>I,executeRequest:()=>xe});function xe(s){return new Promise((e,t)=>{Pe(s,e,t)})}function Pe(s,e,t){let a=s.data,n=s.additionalHeaders,r=s.responseParams,l=s.abortSignal;if(l?.aborted){t(i.handleHttpError({name:"AbortError",code:20,message:"The user aborted a request."}));return}let o=new XMLHttpRequest;o.open(s.method,s.uri,s.isAsync||!1);for(let p in n)o.setRequestHeader(p,n[p]);o.onreadystatechange=function(){if(o.readyState===4)switch(l&&l.removeEventListener("abort",u),o.status){case 200:case 201:case 204:case 206:case 304:{let d=v(o.getAllResponseHeaders()),ce={data:H(o.responseText,d,r[s.requestId]),headers:d,status:o.status};o=null,e(ce);break}case 0:break;default:if(!o)break;let p,m;try{m=v(o.getAllResponseHeaders());let d=H(o.responseText,m,r[s.requestId]);if(Array.isArray(d)){t(d);break}p=d.error}catch{o.response.length>0?p={message:o.response}:p={message:"Unexpected Error"}}let f={status:o.status,statusText:o.statusText,headers:m};o=null,t(i.handleHttpError(p,f));break}},s.timeout&&(o.timeout=s.timeout),o.onerror=function(){let p=v(o.getAllResponseHeaders());t(i.handleHttpError({status:o.status,statusText:o.statusText,message:o.responseText||"Network Error",headers:p})),o=null},o.ontimeout=function(){let p=v(o.getAllResponseHeaders());t(i.handleHttpError({name:"TimeoutError",status:o.status,statusText:o.statusText,message:o.responseText||"Request Timed Out",headers:p})),o=null},o.onabort=function(){if(!o)return;let p=v(o.getAllResponseHeaders());t(i.handleHttpError({status:o.status,statusText:o.statusText,message:"Request aborted",headers:p})),o=null};let u=()=>{if(!o)return;let p=v(o.getAllResponseHeaders());t(i.handleHttpError({name:"AbortError",code:20,status:o.status,statusText:o.statusText,message:"The user aborted a request.",headers:p})),o.abort(),o=null};l&&l.addEventListener("abort",u),a?o.send(a):o.send(),I.afterSendEvent&&I.afterSendEvent()}var I,ie=C(()=>{"use strict";k();te();ne();I=class{}});var De={};z(De,{DynamicsWebApi:()=>w});W();k();var he=(s,e)=>c.isRunningWithinPortals()?`${window.location.origin}/_api/`:(s||(s=c.getClientUrl()),`${s}/api/${e.path}/v${e.version}/`),F=(s,e,t)=>{let a=t[e];s?.version&&(i.stringParameterCheck(s.version,"DynamicsWebApi.setConfig",`config.${e}.version`),a.version=s.version),s?.path&&(i.stringParameterCheck(s.path,"DynamicsWebApi.setConfig",`config.${e}.path`),a.path=s.path),a.url=he(t.serverUrl,a)},D=class{static merge(e,t){t?.serverUrl&&(i.stringParameterCheck(t.serverUrl,"DynamicsWebApi.setConfig","config.serverUrl"),e.serverUrl=t.serverUrl),F(t?.dataApi,"dataApi",e),F(t?.searchApi,"searchApi",e),t?.impersonate&&(e.impersonate=i.guidParameterCheck(t.impersonate,"DynamicsWebApi.setConfig","config.impersonate")),t?.impersonateAAD&&(e.impersonateAAD=i.guidParameterCheck(t.impersonateAAD,"DynamicsWebApi.setConfig","config.impersonateAAD")),t?.onTokenRefresh&&(i.callbackParameterCheck(t.onTokenRefresh,"DynamicsWebApi.setConfig","config.onTokenRefresh"),e.onTokenRefresh=t.onTokenRefresh),t?.includeAnnotations&&(i.stringParameterCheck(t.includeAnnotations,"DynamicsWebApi.setConfig","config.includeAnnotations"),e.includeAnnotations=t.includeAnnotations),t?.timeout&&(i.numberParameterCheck(t.timeout,"DynamicsWebApi.setConfig","config.timeout"),e.timeout=t.timeout),t?.maxPageSize&&(i.numberParameterCheck(t.maxPageSize,"DynamicsWebApi.setConfig","config.maxPageSize"),e.maxPageSize=t.maxPageSize),t?.returnRepresentation&&(i.boolParameterCheck(t.returnRepresentation,"DynamicsWebApi.setConfig","config.returnRepresentation"),e.returnRepresentation=t.returnRepresentation),t?.useEntityNames&&(i.boolParameterCheck(t.useEntityNames,"DynamicsWebApi.setConfig","config.useEntityNames"),e.useEntityNames=t.useEntityNames),t?.headers&&(e.headers=t.headers)}static default(){return{serverUrl:null,impersonate:null,impersonateAAD:null,onTokenRefresh:null,includeAnnotations:null,maxPageSize:null,returnRepresentation:null,proxy:null,dataApi:{path:"data",version:"9.2",url:""},searchApi:{path:"search",version:"1.0",url:""}}}};D.mergeApiConfigs=F;W();k();W();W();k();var h=class{static compose(e,t){if(e.path=e.path||"",e.functionName=e.functionName||"",e.url)i.stringParameterCheck(e.url,`DynamicsWebApi.${e.functionName}`,"request.url"),e.path=e.url.replace(t.dataApi.url,""),e.path=h.composeUrl(e,t,e.path);else if(!e._isUnboundRequest&&!e.collection&&i.parameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.collection!=null&&(i.stringParameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.path=e.collection,e.contentId&&(i.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")&&(e.path=`${e.contentId}/${e.path}`)),e.key&&(e.key=i.keyParameterCheck(e.key,`DynamicsWebApi.${e.functionName}`,"request.key"),e.path+=`(${e.key})`)),e._additionalUrl&&(e.path&&(e.path+="/"),e.path+=e._additionalUrl),e.path=h.composeUrl(e,t,e.path),e.fetchXml){i.stringParameterCheck(e.fetchXml,`DynamicsWebApi.${e.functionName}`,"request.fetchXml");let a=e.path.indexOf("?")===-1?"?":"&";e.path+=`${a}fetchXml=${encodeURIComponent(e.fetchXml)}`}return e.hasOwnProperty("async")&&e.async!=null?i.boolParameterCheck(e.async,`DynamicsWebApi.${e.functionName}`,"request.async"):e.async=!0,e.headers=h.composeHeaders(e,t),e}static composeUrl(e,t,a="",n="&"){let r=[];if(e){if(e.navigationProperty){if(i.stringParameterCheck(e.navigationProperty,`DynamicsWebApi.${e.functionName}`,"request.navigationProperty"),a+="/"+e.navigationProperty,e.navigationPropertyKey){let l=i.keyParameterCheck(e.navigationPropertyKey,`DynamicsWebApi.${e.functionName}`,"request.navigationPropertyKey");a+="("+l+")"}e.navigationProperty==="Attributes"&&e.metadataAttributeType&&(i.stringParameterCheck(e.metadataAttributeType,`DynamicsWebApi.${e.functionName}`,"request.metadataAttributeType"),a+="/"+e.metadataAttributeType)}if(e.select?.length&&(i.arrayParameterCheck(e.select,`DynamicsWebApi.${e.functionName}`,"request.select"),e.functionName=="retrieve"&&e.select.length==1&&e.select[0].endsWith("/$ref")?a+="/"+e.select[0]:(e.select[0].startsWith("/")&&e.functionName=="retrieve"&&(e.navigationProperty==null?a+=e.select.shift():e.select.shift()),e.select.length&&r.push("$select="+e.select.join(",")))),e.filter){i.stringParameterCheck(e.filter,`DynamicsWebApi.${e.functionName}`,"request.filter");let l=/[^"']{([\w\d]{8}[-]?(?:[\w\d]{4}[-]?){3}[\w\d]{12})}(?:[^"']|$)/g,o=e.filter,u=null;for(;(u=l.exec(o))!==null;){u.index===l.lastIndex&&l.lastIndex++;let p=u[0].endsWith(")")?")":" ";o=o.replace(u[0]," "+u[1]+p)}r.push("$filter="+encodeURIComponent(o))}if(e.fieldName&&(i.stringParameterCheck(e.fieldName,`DynamicsWebApi.${e.functionName}`,"request.fieldName"),a+="/"+e.fieldName),e.savedQuery&&r.push("savedQuery="+i.guidParameterCheck(e.savedQuery,`DynamicsWebApi.${e.functionName}`,"request.savedQuery")),e.userQuery&&r.push("userQuery="+i.guidParameterCheck(e.userQuery,`DynamicsWebApi.${e.functionName}`,"request.userQuery")),e.apply&&(i.stringParameterCheck(e.apply,`DynamicsWebApi.${e.functionName}`,"request.apply"),r.push("$apply="+e.apply)),e.count&&(i.boolParameterCheck(e.count,`DynamicsWebApi.${e.functionName}`,"request.count"),r.push("$count="+e.count)),e.top&&e.top>0&&(i.numberParameterCheck(e.top,`DynamicsWebApi.${e.functionName}`,"request.top"),r.push("$top="+e.top)),e.orderBy!=null&&e.orderBy.length&&(i.arrayParameterCheck(e.orderBy,`DynamicsWebApi.${e.functionName}`,"request.orderBy"),r.push("$orderby="+e.orderBy.join(","))),e.partitionId&&(i.stringParameterCheck(e.partitionId,`DynamicsWebApi.${e.functionName}`,"request.partitionId"),r.push("partitionid='"+e.partitionId+"'")),e.downloadSize&&(i.stringParameterCheck(e.downloadSize,`DynamicsWebApi.${e.functionName}`,"request.downloadSize"),r.push("size="+e.downloadSize)),e.queryParams?.length&&(i.arrayParameterCheck(e.queryParams,`DynamicsWebApi.${e.functionName}`,"request.queryParams"),r.push(e.queryParams.join("&"))),e.fileName&&(i.stringParameterCheck(e.fileName,`DynamicsWebApi.${e.functionName}`,"request.fileName"),r.push("x-ms-file-name="+e.fileName)),e.data&&i.parameterCheck(e.data,`DynamicsWebApi.${e.functionName}`,"request.data"),e.isBatch&&i.boolParameterCheck(e.isBatch,`DynamicsWebApi.${e.functionName}`,"request.isBatch"),c.isNull(e.inChangeSet)||i.boolParameterCheck(e.inChangeSet,`DynamicsWebApi.${e.functionName}`,"request.inChangeSet"),e.isBatch&&c.isNull(e.inChangeSet)&&(e.inChangeSet=!0),e.timeout&&i.numberParameterCheck(e.timeout,`DynamicsWebApi.${e.functionName}`,"request.timeout"),e.expand?.length)if(i.stringOrArrayParameterCheck(e.expand,`DynamicsWebApi.${e.functionName}`,"request.expand"),typeof e.expand=="string")r.push("$expand="+e.expand);else{let l=[];for(let o=0;o<e.expand.length;o++)if(e.expand[o].property){let u=e.expand[o];u.functionName=`${e.functionName} $expand`;let p=h.composeUrl(u,t,"",";");p&&(p=`(${p.substr(1)})`),l.push(e.expand[o].property+p)}l.length&&r.push("$expand="+l.join(","))}}return r.length?a+"?"+r.join(n):a}static composeHeaders(e,t){let a={...t.headers,...e.userHeaders},n=h.composePreferHeader(e,t);if(n.length&&(a.Prefer=n),e.collection==="$metadata"&&(a.Accept="application/xml"),e.transferMode&&(a["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&&(i.stringParameterCheck(e.ifmatch,`DynamicsWebApi.${e.functionName}`,"request.ifmatch"),a["If-Match"]=e.ifmatch),e.ifnonematch&&(i.stringParameterCheck(e.ifnonematch,`DynamicsWebApi.${e.functionName}`,"request.ifnonematch"),a["If-None-Match"]=e.ifnonematch),e.impersonate&&(i.stringParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate"),a.MSCRMCallerID=i.guidParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate")),e.impersonateAAD&&(i.stringParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD"),a.CallerObjectId=i.guidParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD")),e.token&&(i.stringParameterCheck(e.token,`DynamicsWebApi.${e.functionName}`,"request.token"),a.Authorization="Bearer "+e.token),e.duplicateDetection&&(i.boolParameterCheck(e.duplicateDetection,`DynamicsWebApi.${e.functionName}`,"request.duplicateDetection"),a["MSCRM.SuppressDuplicateDetection"]="false"),e.bypassCustomPluginExecution&&(i.boolParameterCheck(e.bypassCustomPluginExecution,`DynamicsWebApi.${e.functionName}`,"request.bypassCustomPluginExecution"),a["MSCRM.BypassCustomPluginExecution"]="true"),e.noCache&&(i.boolParameterCheck(e.noCache,`DynamicsWebApi.${e.functionName}`,"request.noCache"),a["Cache-Control"]="no-cache"),e.mergeLabels&&(i.boolParameterCheck(e.mergeLabels,`DynamicsWebApi.${e.functionName}`,"request.mergeLabels"),a["MSCRM.MergeLabels"]="true"),e.contentId&&(i.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")||(a["Content-ID"]=e.contentId)),e.contentRange&&(i.stringParameterCheck(e.contentRange,`DynamicsWebApi.${e.functionName}`,"request.contentRange"),a["Content-Range"]=e.contentRange),e.range&&(i.stringParameterCheck(e.range,`DynamicsWebApi.${e.functionName}`,"request.range"),a.Range=e.range),a}static composePreferHeader(e,t){let a=e.returnRepresentation,n=e.includeAnnotations,r=e.maxPageSize,l=e.trackChanges,o=e.continueOnError,u=[];if(e.prefer&&e.prefer.length){i.stringOrArrayParameterCheck(e.prefer,`DynamicsWebApi.${e.functionName}`,"request.prefer"),typeof e.prefer=="string"&&(u=e.prefer.split(","));for(let p in u){let m=u[p].trim();m==="return=representation"?a=!0:m.includes("odata.include-annotations=")?n=m.replace("odata.include-annotations=","").replace(/"/g,""):m.startsWith("odata.maxpagesize=")?r=Number(m.replace("odata.maxpagesize=","").replace(/"/g,""))||0:m.includes("odata.track-changes")?l=!0:m.includes("odata.continue-on-error")&&(o=!0)}}return u=[],t&&(a==null&&(a=t.returnRepresentation),n=n||t.includeAnnotations,r=r||t.maxPageSize),a&&(i.boolParameterCheck(a,`DynamicsWebApi.${e.functionName}`,"request.returnRepresentation"),u.push("return=representation")),n&&(i.stringParameterCheck(n,`DynamicsWebApi.${e.functionName}`,"request.includeAnnotations"),u.push(`odata.include-annotations="${n}"`)),r&&r>0&&(i.numberParameterCheck(r,`DynamicsWebApi.${e.functionName}`,"request.maxPageSize"),u.push("odata.maxpagesize="+r)),l&&(i.boolParameterCheck(l,`DynamicsWebApi.${e.functionName}`,"request.trackChanges"),u.push("odata.track-changes")),o&&(i.boolParameterCheck(o,`DynamicsWebApi.${e.functionName}`,"request.continueOnError"),u.push("odata.continue-on-error")),u.join(",")}static convertToBatch(e,t,a){let n=`dwa_batch_${c.generateUUID()}`,r=[],l=null,o=1e5;e.forEach(p=>{p.functionName="executeBatch",a?.inChangeSet===!1&&(p.inChangeSet=!1);let m=p.method==="GET"?!1:!!p.inChangeSet;if(!m&&l&&(r.push(`
--${l}--`),l=null,o=1e5),l||(r.push(`

@@ -15,4 +15,4 @@ --${n}`),m&&(l=`changeset_${c.generateUUID()}`,r.push("Content-Type: multipart/mixed;boundary="+l))),m&&r.push(`

--${n}--`);let u=h.setStandardHeaders(a?.userHeaders);return u["Content-Type"]=`multipart/mixed;boundary=${n}`,{headers:u,body:r.join(`
`)}}static findCollectionName(e){let t=null;if(!c.isNull(h.entityNames)&&(t=h.entityNames[e],c.isNull(t))){for(let a in h.entityNames)if(h.entityNames[a]===e)return e}return t}static processData(e,t){let a=null;if(e){if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array)return e;a=JSON.stringify(e,(n,r)=>{if(n.endsWith("@odata.bind")||n.endsWith("@odata.id")){if(typeof r=="string"&&!r.startsWith("$")){if(/\(\{[\w\d-]+\}\)/g.test(r)&&(r=r.replace(/(.+)\(\{([\w\d-]+)\}\)/g,"$1($2)")),t.useEntityNames){let l=/([\w_]+)(\([\d\w-]+\))$/,o=l.exec(r);if(o&&o.length>2){let u=h.findCollectionName(o[1]);c.isNull(u)||(r=r.replace(l,u+"$2"))}}r.startsWith(t.dataApi.url)||(n.endsWith("@odata.bind")?r.startsWith("/")||(r="/"+r):r=t.dataApi.url+r.replace(/^\//,""))}}else(n.startsWith("oData")||n.endsWith("_Formatted")||n.endsWith("_NavigationProperty")||n.endsWith("_LogicalName"))&&(r=void 0);return r}),a=a.replace(/[\u007F-\uFFFF]/g,function(n){return"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})}return a}static setStandardHeaders(e={}){return e.Accept||(e.Accept="application/json"),e["OData-MaxVersion"]||(e["OData-MaxVersion"]="4.0"),e["OData-Version"]||(e["OData-Version"]="4.0"),e["Content-Range"]?e["Content-Type"]="application/octet-stream":e["Content-Type"]||(e["Content-Type"]="application/json; charset=utf-8"),e}};h.entityNames=null;var y=h;P();async function re(s){return(ie(),X(ae)).executeRequest(s)}var se=(s,e)=>{W[s]?W[s].push(e):W[s]=[e]},ke=(s,e)=>{x[s]?x[s].push(e):x[s]=[e]},H=s=>{delete W[s],x.hasOwnProperty(s)&&delete x[s]},oe=async(s,e)=>{try{let t=await N.sendRequest(s,e);return H(s.requestId),t}catch(t){throw H(s.requestId),t}finally{H(s.requestId)}},x={},W={},N=class s{static async sendRequest(e,t){e.headers=e.headers||{},e.responseParameters=e.responseParameters||{},e.requestId=e.requestId||c.generateUUID(),se(e.requestId,e.responseParameters);let a=null,n=e.responseParameters?.convertedToBatch;if(e.path==="$batch"&&!n){let o=x[e.requestId];if(!o)throw i.batchIsEmpty();let u=y.convertToBatch(o,t,e);a=u.body,e.headers={...u.headers,...e.headers},delete x[e.requestId]}else a=n?e.data:y.processData(e.data,t),n||(e.headers=y.setStandardHeaders(e.headers));t.impersonate&&!e.headers.MSCRMCallerID&&(e.headers.MSCRMCallerID=t.impersonate),t.impersonateAAD&&!e.headers.CallerObjectId&&(e.headers.CallerObjectId=t.impersonateAAD);let r=null;if(t.onTokenRefresh&&(!e.headers||e.headers&&!e.headers.Authorization)&&(r=await t.onTokenRefresh(),!r))throw new Error("Token is empty. Request is aborted.");r&&(e.headers.Authorization="Bearer "+(r.hasOwnProperty("accessToken")?r.accessToken:r)),c.isRunningWithinPortals()&&(e.headers.__RequestVerificationToken=await window.shell.getTokenDeferred());let l=e.apiConfig?e.apiConfig.url:t.dataApi.url;return await re({method:e.method,uri:l+e.path,data:a,additionalHeaders:e.headers,responseParams:W,isAsync:e.async,timeout:e.timeout||t.timeout,proxy:t.proxy,requestId:e.requestId,abortSignal:e.signal})}static async _getCollectionNames(e,t){if(!c.isNull(y.entityNames))return y.findCollectionName(e)||e;let a=y.compose({method:"GET",collection:"EntityDefinitions",select:["EntitySetName","LogicalName"],noCache:!0,functionName:"retrieveMultiple"},t),n=await oe(a,t);y.entityNames={};for(let r=0;r<n.data.value.length;r++)y.entityNames[n.data.value[r].LogicalName]=n.data.value[r].EntitySetName;return y.findCollectionName(e)||e}static _isEntityNameException(e){return["$metadata","EntityDefinitions","RelationshipDefinitions","GlobalOptionSetDefinitions","ManagedPropertyDefinitions","query","suggest","autocomplete"].indexOf(e)>-1}static async _checkCollectionName(e,t){if(!e||s._isEntityNameException(e)||(e=e.toLowerCase(),!t.useEntityNames))return e;try{return await s._getCollectionNames(e,t)}catch(a){throw new Error("Unable to fetch Collection Names. Error: "+a.message)}}static async makeRequest(e,t){if(e.responseParameters=e.responseParameters||{},e.userHeaders=e.headers,delete e.headers,!e.isBatch){let a=await s._checkCollectionName(e.collection,t);if(e.collection=a,y.compose(e,t),e.responseParameters.convertedToBatch=!1,e.path.length>2e3){let n=y.convertToBatch([e],t);e.method="POST",e.path="$batch",e.data=n.body,e.headers={...n.headers,...e.userHeaders},e.responseParameters.convertedToBatch=!0}return oe(e,t)}y.compose(e,t),se(e.requestId,e.responseParameters),ke(e.requestId,e)}static _clearTestData(){y.entityNames=null,W={},x={}}static getCollectionName(e){return y.findCollectionName(e)}};var L=class s{constructor(e){this._config=k.default();this._isBatch=!1;this._batchRequestId=null;this.setConfig=e=>k.merge(this._config,e);this._makeRequest=async e=>(e.isBatch=this._isBatch,this._batchRequestId&&(e.requestId=this._batchRequestId),N.makeRequest(e,this._config));this.create=async e=>{i.parameterCheck(e,"DynamicsWebApi.create","request");let t;return e.functionName?t=e:(t=c.copyRequest(e),t.functionName="create"),t.method="POST",(await this._makeRequest(t))?.data};this.retrieve=async e=>{i.parameterCheck(e,"DynamicsWebApi.retrieve","request");let t;return e.functionName?t=e:(t=c.copyRequest(e),t.functionName="retrieve"),t.method="GET",t.responseParameters={isRef:t.select?.length===1&&t.select[0].endsWith("/$ref")},(await this._makeRequest(t))?.data};this.update=async e=>{i.parameterCheck(e,"DynamicsWebApi.update","request");let t;e.functionName?t=e:(t=c.copyRequest(e),t.functionName="update"),t.method||(t.method=/EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(t.collection||"")?"PUT":"PATCH"),t.responseParameters={valueIfEmpty:!0},t.ifmatch==null&&(t.ifmatch="*");let a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};this.updateSingleProperty=async e=>{i.parameterCheck(e,"DynamicsWebApi.updateSingleProperty","request"),i.parameterCheck(e.fieldValuePair,"DynamicsWebApi.updateSingleProperty","request.fieldValuePair");var t=Object.keys(e.fieldValuePair)[0],a=e.fieldValuePair[t];let n=c.copyRequest(e);return n.navigationProperty=t,n.data={value:a},n.functionName="updateSingleProperty",n.method="PUT",delete n.fieldValuePair,(await this._makeRequest(n))?.data};this.deleteRecord=async e=>{i.parameterCheck(e,"DynamicsWebApi.deleteRecord","request");let t;e.functionName?t=e:(t=c.copyRequest(e),t.functionName="deleteRecord"),t.method="DELETE",t.responseParameters={valueIfEmpty:!0};let a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};this.upsert=async e=>{i.parameterCheck(e,"DynamicsWebApi.upsert","request");let t=c.copyRequest(e);t.method="PATCH",t.functionName="upsert";let a=t.ifnonematch,n=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(r){if(a&&r.status===412)return null;if(n&&r.status===404)return null;throw r}};this._uploadFileChunk=async(e,t,a,n=0)=>{if(c.setFileChunk(e,t,a,n),await this._makeRequest(e),n+=a,n<=t.length)return this._uploadFileChunk(e,t,a,n)};this.uploadFile=async e=>{i.throwBatchIncompatible("DynamicsWebApi.uploadFile",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.uploadFile","request");let t=c.copyRequest(e,["data"]);t.method="PATCH",t.functionName="uploadFile",t.transferMode="chunked";let a=await this._makeRequest(t);return t.url=a?.data.location,delete t.transferMode,delete t.fieldName,delete t.fileName,this._uploadFileChunk(t,e.data,a?.data.chunkSize)};this._downloadFileChunk=async(e,t=0,a="")=>{e.range="bytes="+t+"-"+(t+c.downloadChunkSize-1),e.downloadSize="full";let n=await this._makeRequest(e);return e.url=n?.data.location,a+=n?.data.value,t+=c.downloadChunkSize,t<=n?.data.fileSize?this._downloadFileChunk(e,t,a):{fileName:n?.data.fileName,fileSize:n?.data.fileSize,data:c.convertToFileBuffer(a)}};this.downloadFile=e=>{i.throwBatchIncompatible("DynamicsWebApi.downloadFile",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.downloadFile","request");let t=c.copyRequest(e);return t.method="GET",t.functionName="downloadFile",t.responseParameters={parse:!0},this._downloadFileChunk(t)};this.retrieveMultiple=async(e,t)=>{i.parameterCheck(e,"DynamicsWebApi.retrieveMultiple","request");let a;return e.functionName?a=e:(a=c.copyRequest(e),a.functionName="retrieveMultiple"),a.method="GET",t&&(i.stringParameterCheck(t,"DynamicsWebApi.retrieveMultiple","nextPageLink"),a.url=t),(await this._makeRequest(a))?.data};this._retrieveAllRequest=async(e,t,a=[])=>{let n=await this.retrieveMultiple(e,t);a=a.concat(n.value);let r=n.oDataNextLink;if(r)return this._retrieveAllRequest(e,r,a);let l={value:a};return n.oDataDeltaLink&&(l["@odata.deltaLink"]=n.oDataDeltaLink,l.oDataDeltaLink=n.oDataDeltaLink),l};this.retrieveAll=e=>(i.throwBatchIncompatible("DynamicsWebApi.retrieveAll",this._isBatch),this._retrieveAllRequest(e));this.count=async e=>{i.parameterCheck(e,"DynamicsWebApi.count","request");let t=c.copyRequest(e);return t.method="GET",t.functionName="count",t.filter?.length?t.count=!0:t.navigationProperty="$count",t.responseParameters={toCount:t.count},(await this._makeRequest(t))?.data};this.countAll=async e=>{i.throwBatchIncompatible("DynamicsWebApi.countAll",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.countAll","request");let t=await this._retrieveAllRequest(e);return t&&t.value?t.value.length:0};this.fetch=async e=>{i.parameterCheck(e,"DynamicsWebApi.fetch","request");let t=c.copyRequest(e);if(t.method="GET",t.functionName="fetch",i.stringParameterCheck(t.fetchXml,"DynamicsWebApi.fetch","request.fetchXml"),t.fetchXml&&!/^<fetch.+top=/.test(t.fetchXml)){let n="";/^<fetch.+page=/.test(t.fetchXml)||(t.pageNumber=t.pageNumber||1,i.numberParameterCheck(t.pageNumber,"DynamicsWebApi.fetch","request.pageNumber"),n=`$1 page="${t.pageNumber}"`),t.pagingCookie!=null&&(i.stringParameterCheck(t.pagingCookie,"DynamicsWebApi.fetch","request.pagingCookie"),n+=` paging-cookie="${t.pagingCookie}"`),n&&(t.fetchXml=t.fetchXml.replace(/^(<fetch)/,n))}return t.responseParameters={pageNumber:t.pageNumber},(await this._makeRequest(t))?.data};this.fetchAll=async e=>{i.parameterCheck(e,"DynamicsWebApi.fetchAll","request");let t=async(a,n=[])=>{let r=await this.fetch(a);return n=n.concat(r.value),r.PagingInfo?(a.pageNumber=r.PagingInfo.nextPage,a.pagingCookie=r.PagingInfo.cookie,t(a,n)):{value:n}};return i.throwBatchIncompatible("DynamicsWebApi.fetchAll",this._isBatch),t(e)};this.associate=async e=>{i.parameterCheck(e,"DynamicsWebApi.associate","request");let t=c.copyRequest(e);t.method="POST",t.functionName="associate",i.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associate","request.relatedcollection"),i.stringParameterCheck(e.relationshipName,"DynamicsWebApi.associate","request.relationshipName");let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associate","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associate","request.relatedKey");t.navigationProperty=e.relationshipName+"/$ref",t.key=a,t.data={"@odata.id":`${e.relatedCollection}(${n})`},await this._makeRequest(t)};this.disassociate=async e=>{i.parameterCheck(e,"DynamicsWebApi.disassociate","request");let t=c.copyRequest(e);t.method="DELETE",t.functionName="disassociate",i.stringParameterCheck(e.relationshipName,"DynamicsWebApi.disassociate","request.relationshipName");let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociate","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.disassociate","request.relatedId");t.key=a,t.navigationProperty=`${e.relationshipName}(${n})/$ref`,await this._makeRequest(t)};this.associateSingleValued=async e=>{i.parameterCheck(e,"DynamicsWebApi.associateSingleValued","request");let t=c.copyRequest(e);t.method="PUT",t.functionName="associateSingleValued";let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associateSingleValued","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associateSingleValued","request.relatedKey");i.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.associateSingleValued","request.navigationProperty"),i.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associateSingleValued","request.relatedcollection"),t.navigationProperty+="/$ref",t.key=a,t.data={"@odata.id":`${e.relatedCollection}(${n})`},await this._makeRequest(t)};this.disassociateSingleValued=async e=>{i.parameterCheck(e,"DynamicsWebApi.disassociateSingleValued","request");let t=c.copyRequest(e);t.method="DELETE",t.functionName="disassociateSingleValued";let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociateSingleValued","request.primaryKey");i.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.disassociateSingleValued","request.navigationProperty"),t.navigationProperty+="/$ref",t.key=a,await this._makeRequest(t)};this.callFunction=async e=>{i.parameterCheck(e,"DynamicsWebApi.callFunction","request");let t=c.isObject(e),a=t?"request.functionName":"name",n=t?c.copyObject(e):{functionName:e};return i.stringParameterCheck(n.functionName,"DynamicsWebApi.callFunction",a),n.method="GET",n._additionalUrl=n.functionName+c.buildFunctionParameters(n.parameters),n._isUnboundRequest=!n.collection,n.functionName="callFunction",(await this._makeRequest(n))?.data};this.callAction=async e=>{i.parameterCheck(e,"DynamicsWebApi.callAction","request"),i.stringParameterCheck(e.actionName,"DynamicsWebApi.callAction","request.actionName");let t=c.copyRequest(e,["action"]);return t.method="POST",t.functionName="callAction",t._additionalUrl=e.actionName,t._isUnboundRequest=!t.collection,t.data=e.action,(await this._makeRequest(t))?.data};this.createEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.createEntity","request"),i.parameterCheck(e.data,"DynamicsWebApi.createEntity","request.data");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="createEntity",this.create(t)};this.updateEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.updateEntity","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateEntity","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateEntity","request.data.MetadataId");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.key=t.data.MetadataId,t.functionName="updateEntity",t.method="PUT",this.update(t)};this.retrieveEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveEntity","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.retrieveEntity","request.key");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",this.retrieve(t)};this.retrieveEntities=e=>{let t=e?c.copyRequest(e):{};return t.collection="EntityDefinitions",t.functionName="retrieveEntities",this.retrieveMultiple(t)};this.createAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.createAttribute","request"),i.parameterCheck(e.data,"DynamicsWebApi.createAttribute","request.data"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.createAttribute","request.entityKey");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",t.navigationProperty="Attributes",t.key=e.entityKey,this.create(t)};this.updateAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.updateAttribute","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateAttribute","request.data"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.updateAttribute","request.entityKey"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateAttribute","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateAttribute","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.navigationPropertyKey=e.data.MetadataId,t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="updateAttribute",t.method="PUT",this.update(t)};this.retrieveAttributes=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttributes","request.entityKey"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttributes","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="retrieveAttributes",this.retrieveMultiple(t)};this.retrieveAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttribute","request.entityKey"),i.keyParameterCheck(e.attributeKey,"DynamicsWebApi.retrieveAttribute","request.attributeKey"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttribute","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.navigationPropertyKey=e.attributeKey,t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="retrieveAttribute",this.retrieve(t)};this.createRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.createRelationship","request"),i.parameterCheck(e.data,"DynamicsWebApi.createRelationship","request.data");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="createRelationship",this.create(t)};this.updateRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.updateRelationship","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateRelationship","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateRelationship","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateRelationship","request.castType");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.key=e.data.MetadataId,t.navigationProperty=e.castType,t.functionName="updateRelationship",t.method="PUT",this.update(t)};this.deleteRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.deleteRelationship","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.deleteRelationship","request.key");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="deleteRelationship",this.deleteRecord(t)};this.retrieveRelationships=e=>{let t=e?c.copyRequest(e):{};return t.collection="RelationshipDefinitions",t.functionName="retrieveRelationships",e&&e.castType&&(i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationships","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveRelationship","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.retrieveRelationship","request.key"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationship","request.castType");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveRelationship",this.retrieve(t)};this.createGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.createGlobalOptionSet","request"),i.parameterCheck(e.data,"DynamicsWebApi.createGlobalOptionSet","request.data");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="createGlobalOptionSet",this.create(t)};this.updateGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.updateGlobalOptionSet","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateGlobalOptionSet","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateGlobalOptionSet","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateGlobalOptionSet","request.castType");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.key=e.data.MetadataId,t.functionName="updateGlobalOptionSet",t.method="PUT",this.update(t)};this.deleteGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.deleteGlobalOptionSet","request");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="deleteGlobalOptionSet",this.deleteRecord(t)};this.retrieveGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveGlobalOptionSet","request"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSet","request.castType");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveGlobalOptionSet",this.retrieve(t)};this.retrieveGlobalOptionSets=e=>{let t=e?c.copyRequest(e):{};return t.collection="GlobalOptionSetDefinitions",t.functionName="retrieveGlobalOptionSets",e?.castType&&(i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSets","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveCsdlMetadata=async e=>{let t=e?c.copyRequest(e):{};return t.collection="$metadata",t.functionName="retrieveCsdlMetadata",e?.addAnnotations&&(i.boolParameterCheck(e.addAnnotations,"DynamicsWebApi.retrieveCsdlMetadata","request.addAnnotations"),t.includeAnnotations="*"),(await this._makeRequest(t))?.data};this.search=async e=>{i.parameterCheck(e,"DynamicsWebApi.search","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return i.parameterCheck(n.query,"DynamicsWebApi.search","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.search",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.search",a,100),n.collection="query",n.functionName="search",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.suggest=async e=>{i.parameterCheck(e,"DynamicsWebApi.suggest","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return i.parameterCheck(n.query,"DynamicsWebApi.suggest","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.suggest",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.suggest",a,100),n.functionName=n.collection="suggest",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.autocomplete=async e=>{i.parameterCheck(e,"DynamicsWebApi.autocomplete","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return t&&i.parameterCheck(n.query,"DynamicsWebApi.autocomplete","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.autocomplete",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.autocomplete",a,100),n.functionName=n.collection="autocomplete",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.startBatch=()=>{this._isBatch=!0,this._batchRequestId=c.generateUUID()};this.executeBatch=async e=>{i.throwBatchNotStarted(this._isBatch);let t=e?c.copyRequest(e):{};return t.collection="$batch",t.method="POST",t.functionName="executeBatch",t.requestId=this._batchRequestId,this._batchRequestId=null,this._isBatch=!1,(await this._makeRequest(t))?.data};this.initializeInstance=e=>new s(e||this._config);this.Utility={getCollectionName:e=>N.getCollectionName(e)};k.merge(this._config,e)}};return X(De);})();
`)}}static findCollectionName(e){let t=null;if(!c.isNull(h.entityNames)&&(t=h.entityNames[e],c.isNull(t))){for(let a in h.entityNames)if(h.entityNames[a]===e)return e}return t}static processData(e,t){let a=null;if(e){if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array)return e;a=JSON.stringify(e,(n,r)=>{if(n.endsWith("@odata.bind")||n.endsWith("@odata.id")){if(typeof r=="string"&&!r.startsWith("$")){if(/\(\{[\w\d-]+\}\)/g.test(r)&&(r=r.replace(/(.+)\(\{([\w\d-]+)\}\)/g,"$1($2)")),t.useEntityNames){let l=/([\w_]+)(\([\d\w-]+\))$/,o=l.exec(r);if(o&&o.length>2){let u=h.findCollectionName(o[1]);c.isNull(u)||(r=r.replace(l,u+"$2"))}}r.startsWith(t.dataApi.url)||(n.endsWith("@odata.bind")?r.startsWith("/")||(r="/"+r):r=t.dataApi.url+r.replace(/^\//,""))}}else(n.startsWith("oData")||n.endsWith("_Formatted")||n.endsWith("_NavigationProperty")||n.endsWith("_LogicalName"))&&(r=void 0);return r}),a=a.replace(/[\u007F-\uFFFF]/g,function(n){return"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})}return a}static setStandardHeaders(e={}){return e.Accept||(e.Accept="application/json"),e["OData-MaxVersion"]||(e["OData-MaxVersion"]="4.0"),e["OData-Version"]||(e["OData-Version"]="4.0"),e["Content-Range"]?e["Content-Type"]="application/octet-stream":e["Content-Type"]||(e["Content-Type"]="application/json; charset=utf-8"),e}},y=h;y.entityNames=null;k();async function re(s){return(ie(),X(ae)).executeRequest(s)}var se=(s,e)=>{N[s]?N[s].push(e):N[s]=[e]},ke=(s,e)=>{P[s]?P[s].push(e):P[s]=[e]},L=s=>{delete N[s],P.hasOwnProperty(s)&&delete P[s]},oe=async(s,e)=>{try{let t=await R.sendRequest(s,e);return L(s.requestId),t}catch(t){throw L(s.requestId),t}finally{L(s.requestId)}},P={},N={},R=class{static async sendRequest(e,t){e.headers=e.headers||{},e.responseParameters=e.responseParameters||{},e.requestId=e.requestId||c.generateUUID(),se(e.requestId,e.responseParameters);let a=null,n=e.responseParameters?.convertedToBatch;if(e.path==="$batch"&&!n){let o=P[e.requestId];if(!o)throw i.batchIsEmpty();let u=y.convertToBatch(o,t,e);a=u.body,e.headers={...u.headers,...e.headers},delete P[e.requestId]}else a=n?e.data:y.processData(e.data,t),n||(e.headers=y.setStandardHeaders(e.headers));t.impersonate&&!e.headers.MSCRMCallerID&&(e.headers.MSCRMCallerID=t.impersonate),t.impersonateAAD&&!e.headers.CallerObjectId&&(e.headers.CallerObjectId=t.impersonateAAD);let r=null;if(t.onTokenRefresh&&(!e.headers||e.headers&&!e.headers.Authorization)&&(r=await t.onTokenRefresh(),!r))throw new Error("Token is empty. Request is aborted.");r&&(e.headers.Authorization="Bearer "+(r.hasOwnProperty("accessToken")?r.accessToken:r)),c.isRunningWithinPortals()&&(e.headers.__RequestVerificationToken=await window.shell.getTokenDeferred());let l=e.apiConfig?e.apiConfig.url:t.dataApi.url;return await re({method:e.method,uri:l+e.path,data:a,additionalHeaders:e.headers,responseParams:N,isAsync:e.async,timeout:e.timeout||t.timeout,proxy:t.proxy,requestId:e.requestId,abortSignal:e.signal})}static async _getCollectionNames(e,t){if(!c.isNull(y.entityNames))return y.findCollectionName(e)||e;let a=y.compose({method:"GET",collection:"EntityDefinitions",select:["EntitySetName","LogicalName"],noCache:!0,functionName:"retrieveMultiple"},t),n=await oe(a,t);y.entityNames={};for(let r=0;r<n.data.value.length;r++)y.entityNames[n.data.value[r].LogicalName]=n.data.value[r].EntitySetName;return y.findCollectionName(e)||e}static _isEntityNameException(e){return["$metadata","EntityDefinitions","RelationshipDefinitions","GlobalOptionSetDefinitions","ManagedPropertyDefinitions","query","suggest","autocomplete"].indexOf(e)>-1}static async _checkCollectionName(e,t){if(!e||R._isEntityNameException(e)||(e=e.toLowerCase(),!t.useEntityNames))return e;try{return await R._getCollectionNames(e,t)}catch(a){throw new Error("Unable to fetch Collection Names. Error: "+a.message)}}static async makeRequest(e,t){if(e.responseParameters=e.responseParameters||{},e.userHeaders=e.headers,delete e.headers,!e.isBatch){let a=await R._checkCollectionName(e.collection,t);if(e.collection=a,y.compose(e,t),e.responseParameters.convertedToBatch=!1,e.path.length>2e3){let n=y.convertToBatch([e],t);e.method="POST",e.path="$batch",e.data=n.body,e.headers={...n.headers,...e.userHeaders},e.responseParameters.convertedToBatch=!0}return oe(e,t)}y.compose(e,t),se(e.requestId,e.responseParameters),ke(e.requestId,e)}static _clearTestData(){y.entityNames=null,N={},P={}}static getCollectionName(e){return y.findCollectionName(e)}};var w=class{constructor(e){this._config=D.default();this._isBatch=!1;this._batchRequestId=null;this.setConfig=e=>D.merge(this._config,e);this._makeRequest=async e=>(e.isBatch=this._isBatch,this._batchRequestId&&(e.requestId=this._batchRequestId),R.makeRequest(e,this._config));this.create=async e=>{i.parameterCheck(e,"DynamicsWebApi.create","request");let t;return e.functionName?t=e:(t=c.copyRequest(e),t.functionName="create"),t.method="POST",(await this._makeRequest(t))?.data};this.retrieve=async e=>{i.parameterCheck(e,"DynamicsWebApi.retrieve","request");let t;return e.functionName?t=e:(t=c.copyRequest(e),t.functionName="retrieve"),t.method="GET",t.responseParameters={isRef:t.select?.length===1&&t.select[0].endsWith("/$ref")},(await this._makeRequest(t))?.data};this.update=async e=>{i.parameterCheck(e,"DynamicsWebApi.update","request");let t;e.functionName?t=e:(t=c.copyRequest(e),t.functionName="update"),t.method||(t.method=/EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/.test(t.collection||"")?"PUT":"PATCH"),t.responseParameters={valueIfEmpty:!0},t.ifmatch==null&&(t.ifmatch="*");let a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};this.updateSingleProperty=async e=>{i.parameterCheck(e,"DynamicsWebApi.updateSingleProperty","request"),i.parameterCheck(e.fieldValuePair,"DynamicsWebApi.updateSingleProperty","request.fieldValuePair");var t=Object.keys(e.fieldValuePair)[0],a=e.fieldValuePair[t];let n=c.copyRequest(e);return n.navigationProperty=t,n.data={value:a},n.functionName="updateSingleProperty",n.method="PUT",delete n.fieldValuePair,(await this._makeRequest(n))?.data};this.deleteRecord=async e=>{i.parameterCheck(e,"DynamicsWebApi.deleteRecord","request");let t;e.functionName?t=e:(t=c.copyRequest(e),t.functionName="deleteRecord"),t.method="DELETE",t.responseParameters={valueIfEmpty:!0};let a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};this.upsert=async e=>{i.parameterCheck(e,"DynamicsWebApi.upsert","request");let t=c.copyRequest(e);t.method="PATCH",t.functionName="upsert";let a=t.ifnonematch,n=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(r){if(a&&r.status===412)return null;if(n&&r.status===404)return null;throw r}};this._uploadFileChunk=async(e,t,a,n=0)=>{if(c.setFileChunk(e,t,a,n),await this._makeRequest(e),n+=a,n<=t.length)return this._uploadFileChunk(e,t,a,n)};this.uploadFile=async e=>{i.throwBatchIncompatible("DynamicsWebApi.uploadFile",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.uploadFile","request");let t=c.copyRequest(e,["data"]);t.method="PATCH",t.functionName="uploadFile",t.transferMode="chunked";let a=await this._makeRequest(t);return t.url=a?.data.location,delete t.transferMode,delete t.fieldName,delete t.fileName,this._uploadFileChunk(t,e.data,a?.data.chunkSize)};this._downloadFileChunk=async(e,t=0,a="")=>{e.range="bytes="+t+"-"+(t+c.downloadChunkSize-1),e.downloadSize="full";let n=await this._makeRequest(e);return e.url=n?.data.location,a+=n?.data.value,t+=c.downloadChunkSize,t<=n?.data.fileSize?this._downloadFileChunk(e,t,a):{fileName:n?.data.fileName,fileSize:n?.data.fileSize,data:c.convertToFileBuffer(a)}};this.downloadFile=e=>{i.throwBatchIncompatible("DynamicsWebApi.downloadFile",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.downloadFile","request");let t=c.copyRequest(e);return t.method="GET",t.functionName="downloadFile",t.responseParameters={parse:!0},this._downloadFileChunk(t)};this.retrieveMultiple=async(e,t)=>{i.parameterCheck(e,"DynamicsWebApi.retrieveMultiple","request");let a;return e.functionName?a=e:(a=c.copyRequest(e),a.functionName="retrieveMultiple"),a.method="GET",t&&(i.stringParameterCheck(t,"DynamicsWebApi.retrieveMultiple","nextPageLink"),a.url=t),(await this._makeRequest(a))?.data};this._retrieveAllRequest=async(e,t,a=[])=>{let n=await this.retrieveMultiple(e,t);a=a.concat(n.value);let r=n.oDataNextLink;if(r)return this._retrieveAllRequest(e,r,a);let l={value:a};return n.oDataDeltaLink&&(l["@odata.deltaLink"]=n.oDataDeltaLink,l.oDataDeltaLink=n.oDataDeltaLink),l};this.retrieveAll=e=>(i.throwBatchIncompatible("DynamicsWebApi.retrieveAll",this._isBatch),this._retrieveAllRequest(e));this.count=async e=>{i.parameterCheck(e,"DynamicsWebApi.count","request");let t=c.copyRequest(e);return t.method="GET",t.functionName="count",t.filter?.length?t.count=!0:t.navigationProperty="$count",t.responseParameters={toCount:t.count},(await this._makeRequest(t))?.data};this.countAll=async e=>{i.throwBatchIncompatible("DynamicsWebApi.countAll",this._isBatch),i.parameterCheck(e,"DynamicsWebApi.countAll","request");let t=await this._retrieveAllRequest(e);return t&&t.value?t.value.length:0};this.fetch=async e=>{i.parameterCheck(e,"DynamicsWebApi.fetch","request");let t=c.copyRequest(e);if(t.method="GET",t.functionName="fetch",i.stringParameterCheck(t.fetchXml,"DynamicsWebApi.fetch","request.fetchXml"),t.fetchXml&&!/^<fetch.+top=/.test(t.fetchXml)){let n="";/^<fetch.+page=/.test(t.fetchXml)||(t.pageNumber=t.pageNumber||1,i.numberParameterCheck(t.pageNumber,"DynamicsWebApi.fetch","request.pageNumber"),n=`$1 page="${t.pageNumber}"`),t.pagingCookie!=null&&(i.stringParameterCheck(t.pagingCookie,"DynamicsWebApi.fetch","request.pagingCookie"),n+=` paging-cookie="${t.pagingCookie}"`),n&&(t.fetchXml=t.fetchXml.replace(/^(<fetch)/,n))}return t.responseParameters={pageNumber:t.pageNumber},(await this._makeRequest(t))?.data};this.fetchAll=async e=>{i.parameterCheck(e,"DynamicsWebApi.fetchAll","request");let t=async(a,n=[])=>{let r=await this.fetch(a);return n=n.concat(r.value),r.PagingInfo?(a.pageNumber=r.PagingInfo.nextPage,a.pagingCookie=r.PagingInfo.cookie,t(a,n)):{value:n}};return i.throwBatchIncompatible("DynamicsWebApi.fetchAll",this._isBatch),t(e)};this.associate=async e=>{i.parameterCheck(e,"DynamicsWebApi.associate","request");let t=c.copyRequest(e);t.method="POST",t.functionName="associate",i.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associate","request.relatedcollection"),i.stringParameterCheck(e.relationshipName,"DynamicsWebApi.associate","request.relationshipName");let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associate","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associate","request.relatedKey");t.navigationProperty=e.relationshipName+"/$ref",t.key=a,t.data={"@odata.id":`${e.relatedCollection}(${n})`},await this._makeRequest(t)};this.disassociate=async e=>{i.parameterCheck(e,"DynamicsWebApi.disassociate","request");let t=c.copyRequest(e);t.method="DELETE",t.functionName="disassociate",i.stringParameterCheck(e.relationshipName,"DynamicsWebApi.disassociate","request.relationshipName");let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociate","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.disassociate","request.relatedId");t.key=a,t.navigationProperty=`${e.relationshipName}(${n})/$ref`,await this._makeRequest(t)};this.associateSingleValued=async e=>{i.parameterCheck(e,"DynamicsWebApi.associateSingleValued","request");let t=c.copyRequest(e);t.method="PUT",t.functionName="associateSingleValued";let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associateSingleValued","request.primaryKey"),n=i.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associateSingleValued","request.relatedKey");i.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.associateSingleValued","request.navigationProperty"),i.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associateSingleValued","request.relatedcollection"),t.navigationProperty+="/$ref",t.key=a,t.data={"@odata.id":`${e.relatedCollection}(${n})`},await this._makeRequest(t)};this.disassociateSingleValued=async e=>{i.parameterCheck(e,"DynamicsWebApi.disassociateSingleValued","request");let t=c.copyRequest(e);t.method="DELETE",t.functionName="disassociateSingleValued";let a=i.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociateSingleValued","request.primaryKey");i.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.disassociateSingleValued","request.navigationProperty"),t.navigationProperty+="/$ref",t.key=a,await this._makeRequest(t)};this.callFunction=async e=>{i.parameterCheck(e,"DynamicsWebApi.callFunction","request");let t=c.isObject(e),a=t?"request.functionName":"name",n=t?c.copyObject(e):{functionName:e};return i.stringParameterCheck(n.functionName,"DynamicsWebApi.callFunction",a),n.method="GET",n._additionalUrl=n.functionName+c.buildFunctionParameters(n.parameters),n._isUnboundRequest=!n.collection,n.functionName="callFunction",(await this._makeRequest(n))?.data};this.callAction=async e=>{i.parameterCheck(e,"DynamicsWebApi.callAction","request"),i.stringParameterCheck(e.actionName,"DynamicsWebApi.callAction","request.actionName");let t=c.copyRequest(e,["action"]);return t.method="POST",t.functionName="callAction",t._additionalUrl=e.actionName,t._isUnboundRequest=!t.collection,t.data=e.action,(await this._makeRequest(t))?.data};this.createEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.createEntity","request"),i.parameterCheck(e.data,"DynamicsWebApi.createEntity","request.data");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="createEntity",this.create(t)};this.updateEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.updateEntity","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateEntity","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateEntity","request.data.MetadataId");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.key=t.data.MetadataId,t.functionName="updateEntity",t.method="PUT",this.update(t)};this.retrieveEntity=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveEntity","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.retrieveEntity","request.key");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",this.retrieve(t)};this.retrieveEntities=e=>{let t=e?c.copyRequest(e):{};return t.collection="EntityDefinitions",t.functionName="retrieveEntities",this.retrieveMultiple(t)};this.createAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.createAttribute","request"),i.parameterCheck(e.data,"DynamicsWebApi.createAttribute","request.data"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.createAttribute","request.entityKey");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",t.navigationProperty="Attributes",t.key=e.entityKey,this.create(t)};this.updateAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.updateAttribute","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateAttribute","request.data"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.updateAttribute","request.entityKey"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateAttribute","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateAttribute","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.navigationPropertyKey=e.data.MetadataId,t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="updateAttribute",t.method="PUT",this.update(t)};this.retrieveAttributes=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttributes","request.entityKey"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttributes","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="retrieveAttributes",this.retrieveMultiple(t)};this.retrieveAttribute=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),i.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttribute","request.entityKey"),i.keyParameterCheck(e.attributeKey,"DynamicsWebApi.retrieveAttribute","request.attributeKey"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttribute","request.castType");let t=c.copyRequest(e);return t.collection="EntityDefinitions",t.navigationProperty="Attributes",t.navigationPropertyKey=e.attributeKey,t.metadataAttributeType=e.castType,t.key=e.entityKey,t.functionName="retrieveAttribute",this.retrieve(t)};this.createRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.createRelationship","request"),i.parameterCheck(e.data,"DynamicsWebApi.createRelationship","request.data");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="createRelationship",this.create(t)};this.updateRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.updateRelationship","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateRelationship","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateRelationship","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateRelationship","request.castType");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.key=e.data.MetadataId,t.navigationProperty=e.castType,t.functionName="updateRelationship",t.method="PUT",this.update(t)};this.deleteRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.deleteRelationship","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.deleteRelationship","request.key");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="deleteRelationship",this.deleteRecord(t)};this.retrieveRelationships=e=>{let t=e?c.copyRequest(e):{};return t.collection="RelationshipDefinitions",t.functionName="retrieveRelationships",e&&e.castType&&(i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationships","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveRelationship=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveRelationship","request"),i.keyParameterCheck(e.key,"DynamicsWebApi.retrieveRelationship","request.key"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationship","request.castType");let t=c.copyRequest(e);return t.collection="RelationshipDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveRelationship",this.retrieve(t)};this.createGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.createGlobalOptionSet","request"),i.parameterCheck(e.data,"DynamicsWebApi.createGlobalOptionSet","request.data");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="createGlobalOptionSet",this.create(t)};this.updateGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.updateGlobalOptionSet","request"),i.parameterCheck(e.data,"DynamicsWebApi.updateGlobalOptionSet","request.data"),i.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateGlobalOptionSet","request.data.MetadataId"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.updateGlobalOptionSet","request.castType");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.key=e.data.MetadataId,t.functionName="updateGlobalOptionSet",t.method="PUT",this.update(t)};this.deleteGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.deleteGlobalOptionSet","request");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="deleteGlobalOptionSet",this.deleteRecord(t)};this.retrieveGlobalOptionSet=e=>{i.parameterCheck(e,"DynamicsWebApi.retrieveGlobalOptionSet","request"),e.castType&&i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSet","request.castType");let t=c.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveGlobalOptionSet",this.retrieve(t)};this.retrieveGlobalOptionSets=e=>{let t=e?c.copyRequest(e):{};return t.collection="GlobalOptionSetDefinitions",t.functionName="retrieveGlobalOptionSets",e?.castType&&(i.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSets","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveCsdlMetadata=async e=>{let t=e?c.copyRequest(e):{};return t.collection="$metadata",t.functionName="retrieveCsdlMetadata",e?.addAnnotations&&(i.boolParameterCheck(e.addAnnotations,"DynamicsWebApi.retrieveCsdlMetadata","request.addAnnotations"),t.includeAnnotations="*"),(await this._makeRequest(t))?.data};this.search=async e=>{i.parameterCheck(e,"DynamicsWebApi.search","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return i.parameterCheck(n.query,"DynamicsWebApi.search","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.search",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.search",a,100),n.collection="query",n.functionName="search",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.suggest=async e=>{i.parameterCheck(e,"DynamicsWebApi.suggest","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return i.parameterCheck(n.query,"DynamicsWebApi.suggest","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.suggest",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.suggest",a,100),n.functionName=n.collection="suggest",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.autocomplete=async e=>{i.parameterCheck(e,"DynamicsWebApi.autocomplete","request");let t=c.isObject(e),a=t?"request.query.search":"term",n=t?c.copyObject(e):{query:{search:e}};return t&&i.parameterCheck(n.query,"DynamicsWebApi.autocomplete","request.query"),i.stringParameterCheck(n.query.search,"DynamicsWebApi.autocomplete",a),i.maxLengthStringParameterCheck(n.query.search,"DynamicsWebApi.autocomplete",a,100),n.functionName=n.collection="autocomplete",n.method="POST",n.data=n.query,n.apiConfig=this._config.searchApi,delete n.query,(await this._makeRequest(n))?.data};this.startBatch=()=>{this._isBatch=!0,this._batchRequestId=c.generateUUID()};this.executeBatch=async e=>{i.throwBatchNotStarted(this._isBatch);let t=e?c.copyRequest(e):{};return t.collection="$batch",t.method="POST",t.functionName="executeBatch",t.requestId=this._batchRequestId,this._batchRequestId=null,this._isBatch=!1,(await this._makeRequest(t))?.data};this.initializeInstance=e=>new w(e||this._config);this.Utility={getCollectionName:e=>R.getCollectionName(e)};D.merge(this._config,e)}};return X(De);})();
var DynamicsWebApi = _dynamicsWebApiExports.DynamicsWebApi
//# sourceMappingURL=dynamics-web-api.min.js.map
{
"name": "dynamics-web-api",
"version": "2.1.0",
"version": "2.1.1",
"description": "DynamicsWebApi is a Microsoft Dynamics CRM Web API helper library",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc