🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

dynamics-web-api

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamics-web-api - npm Package Compare versions

Comparing version
2.2.1
to
2.3.0
+13
-13
dist/dynamics-web-api.min.js

@@ -1,15 +0,15 @@

/*! dynamics-web-api v2.2.1 (c) 2025 Aleksandr Rogov. License: MIT */
"use strict";var _dynamicsWebApiExports=(()=>{var q=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var y=(n,e)=>()=>(n&&(e=n(n=0)),e);var ie=(n,e)=>{for(var t in e)q(n,t,{get:e[t],enumerable:!0})},qe=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of we(e))!Be.call(n,a)&&a!==t&&q(n,a,{get:()=>e[a],enumerable:!(i=$e(e,a))||i.enumerable});return n};var re=n=>qe(q({},"__esModule",{value:!0}),n);function se(){return window.crypto}var oe=y(()=>{"use strict"});function ce(n){return!!Me.exec(n)}function W(n){let e=Fe.exec(n);return e?e[1]:null}function O(n){if(!n)return null;let e=Ge.exec(n);return e?e[1]:null}function M(n){return n.replace(Xe,(e,t)=>t)}function le(n){return n.split(He).map((t,i)=>i%2===0?M(t):t).join("")}function pe(n){let e=Le.exec(n["@odata.id"]);return{id:e[2],collection:e[1],oDataContext:n["@odata.context"]}}function ue(n){let e=Ke.exec(n);if(!e)return null;let t=parseInt(e[2],10),i=ze(e[1]);return{page:t,sanitizedCookie:i}}function ze(n){let e={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return n.replace(Ve,t=>e[t])}function me(n){return n.replace(je,"")}function de(n){return n.replace(Qe,e=>`\\u${("0000"+e.charCodeAt(0).toString(16)).slice(-4)}`)}function F(n){return n.replace(Ye,"")}function Re(n){return Je.test(n??"")?"PUT":"PATCH"}var N,Me,Fe,Ge,Xe,Le,He,Ke,Ve,je,Qe,Ye,ye,G,fe,he,ge,$,X,Je,be,Ae,Ce,xe,g=y(()=>{"use strict";N="[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}",Me=new RegExp(N,"i"),Fe=new RegExp("^{?("+N+")}?$","i"),Ge=new RegExp("("+N+")\\)$","i"),Xe=new RegExp(`{(${N})}`,"g"),Le=new RegExp(`\\/(\\w+)\\((${N})`,"i");He=/(["'].*?["'])/;Ke=/pagingcookie="(<cookie page="(\d+)".+<\/cookie>)/,Ve=/[<>"']/g;je=/^\//;Qe=/[\u007F-\uFFFF]/g;Ye=/"/g;ye=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/,G=/HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/m,fe=/Content-Type: text\/plain/i,he=/OData-EntityId.+/i,ge=/\w+$/g,$=/\r?\n/,X=/(\w+)(\([\d\w-]+\))$/,Je=/EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;be=/^<fetch.+top=/,Ae=/^<fetch.+page=/,Ce=/^(<fetch)/,xe=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:Z|[-+]\d{2}:\d{2})$/});function et(n){return n==null?"":typeof n=="string"&&!n.startsWith("Microsoft.Dynamics.CRM")&&!ce(n)?`'${n}'`:typeof n=="object"?JSON.stringify(n):n.toString()}function tt(n){let e=Object.keys(n),t=[],i=[];return e.forEach((a,s)=>{let o=n[a];if(o==null)return;o=et(o);let c=s+1;t.push(`${a}=@p${c}`),i.push(`@p${c}=${W(o)||o}`)}),{key:`(${t.join(",")})`,queryParams:i}}function Pe(n,e){return n.hasOwnProperty(e)||n.hasOwnProperty(e.toLowerCase())}function S(n,e){return n[e]?n[e]:n[e.toLowerCase()]}var Ze,d,l,T=y(()=>{"use strict";oe();g();Ze=4194304;d=class d{static buildFunctionParameters(e){return e?tt(e):{key:"()"}}static getFetchXmlPagingCookie(e="",t=1){e=decodeURIComponent(decodeURIComponent(e));let i=ue(e);return{cookie:i?.sanitizedCookie||"",page:i?.page||t,nextPage:i?.page?i.page+1:t+1}}static isNull(e){return typeof e>"u"||e==null}static generateUUID(){return se().randomUUID()}static getXrmContext(){if(typeof GetGlobalContext<"u")return GetGlobalContext();if(typeof Xrm<"u"){if(!d.isNull(Xrm.Utility)&&!d.isNull(Xrm.Utility.getGlobalContext))return Xrm.Utility.getGlobalContext();if(!d.isNull(Xrm.Page)&&!d.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=d.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 i={};for(let a in e)e.hasOwnProperty(a)&&!t?.includes(a)&&(d.isObject(e[a])?i[a]=d.copyObject(e[a]):Array.isArray(e[a])?i[a]=e[a].slice():i[a]=e[a]);return i}static copyRequest(e,t=[]){t.includes("signal")||t.push("signal");let i=d.copyObject(e,t);return i.signal=e.signal,i}static setFileChunk(e,t,i,a){a=a||0;let s=a+i>t.length?t.length%i:i,o;o=new Uint8Array(s);for(let c=0;c<s;c++)o[c]=t[a+c];e.data=o,e.contentRange="bytes "+a+"-"+(a+s-1)+"/"+t.length}static convertToFileBuffer(e){let t=new Uint8Array(e.length);for(var i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}};d.downloadChunkSize=Ze;l=d});function f(n,e,t){throw new Error(t?`${n} requires a ${e} parameter to be of type ${t}.`:`${n} requires a ${e} parameter.`)}var r,x=y(()=>{"use strict";g();r=class n{static handleErrorResponse(e){throw new Error(`Error: ${e.status}: ${e.message}`)}static parameterCheck(e,t,i,a){(typeof e>"u"||e===null||e==="")&&f(t,i,a)}static stringParameterCheck(e,t,i){typeof e!="string"&&f(t,i,"String")}static maxLengthStringParameterCheck(e,t,i,a){if(e&&e.length>a)throw new Error(`${i} has a ${a} character limit.`)}static arrayParameterCheck(e,t,i){e.constructor!==Array&&f(t,i,"Array")}static stringOrArrayParameterCheck(e,t,i){e.constructor!==Array&&typeof e!="string"&&f(t,i,"String or Array")}static numberParameterCheck(e,t,i){if(typeof e!="number"){if(typeof e=="string"&&e&&!isNaN(parseInt(e)))return;f(t,i,"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 i=new Error;return Object.keys(e).forEach(a=>{i[a]=e[a]}),t&&Object.keys(t).forEach(a=>{i[a]=t[a]}),i}static boolParameterCheck(e,t,i){typeof e!="boolean"&&f(t,i,"Boolean")}static guidParameterCheck(e,t,i){let a=W(e);return a||f(t,i,"GUID String"),a}static keyParameterCheck(e,t,i){try{n.stringParameterCheck(e,t,i);let a=W(e);if(a)return a;let s=e.split(",");if(s.length)for(let o=0;o<s.length;o++)s[o]=s[o].trim().replace(/"/g,"'"),/^[\w\d\_]+\=(.+)$/i.exec(s[o])[0];return s.join(",")}catch{f(t,i,"String representing GUID or Alternate Key")}}static callbackParameterCheck(e,t,i){typeof e!="function"&&f(t,i,"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,_,B,b,ke=y(()=>{"use strict";B=class B{};B.Prefer=(_=class{static get(e){return`${B.Prefer.IncludeAnnotations}="${e}"`}},_.ReturnRepresentation="return=representation",_.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),_.IncludeAnnotations="odata.include-annotations",_);b=B});function Te(n,e){if(typeof e=="string"){let t=xe.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 Ee=y(()=>{"use strict";g()});function st(n){let e={position:0},t={},i,a,s;do{if(s=e.position,a=ot(n,e),!a)break;i=ye.exec(a),i!==null?t[i[1].toLowerCase()]=i[2]:e.position=s}while(a&&i);return t}function ot(n,e){return ct(n,e,$)}function ct(n,e,t){let i=e.position||0,a=n.slice(i),s=t.exec(a);if(!s)return null;let o=i+s.index;return e.position=o+s[0].length,n.substring(i,o)}function lt(n){let e=G.exec(n);return{httpStatusString:e[0],httpStatus:parseInt(e[1]),httpStatusMessage:e[2].trim()}}function pt(n){G.lastIndex=0;let e=ge.exec(n.trim());return e?.length?e[0]:void 0}function ut(n,e,t){let i=pt(n);return Y(i)}function mt(n,e,t){if(e?.[t]?.valueIfEmpty!==void 0)return e[t].valueIfEmpty;{let i=he.exec(n);return O(i?.[0])??void 0}}function dt(n,e,t){let{httpStatusString:i,httpStatus:a,httpStatusMessage:s}=lt(n),o=n.substring(n.indexOf("{"),n.lastIndexOf("}")+1);if(!o)return fe.test(n)?ut(n,e,t):mt(n,e,t);let c=Q(o,e,t);if(a<400)return c;let m=st(n.substring(n.indexOf(i)+i.length+1,n.indexOf("{")));return r.handleHttpError(c,{status:a,statusText:s,statusMessage:s,headers:m})}function j(n,e,t=0){let i=n.substring(0,n.search($)),a=n.split(i);a.shift(),a.pop();let s=[];for(let o of a){if(o.indexOf("--changesetresponse_")===-1){s.push(dt(o,e,t++));continue}o=o.trim();let c=o.substring(o.search($)+1).trim();s=s.concat(j(c,e,t++))}return s}var ve=y(()=>{"use strict";x();g();J()});function Z(n,e){let t=null;if(n.indexOf("@")!==-1){let i=n.split("@");switch(i[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 b.Prefer.Annotations.FormattedValue:t=i[0]+"_Formatted";break;case b.Prefer.Annotations.AssociatedNavigationProperty:t=i[0]+"_NavigationProperty";break;case b.Prefer.Annotations.LookupLogicalName:t=i[0]+"_LogicalName";break}}return[t,e]}function ee(n,e){if(e){if(e.isRef&&n["@odata.id"]!=null)return pe(n);if(e.toCount)return Z("@odata.count",n["@odata.count"])[1]||0}for(let i in n){if(n[i]!=null)if(Array.isArray(n[i]))for(var t=0;t<n[i].length;t++)n[i][t]=ee(n[i][t]);else typeof n[i]=="object"&&ee(n[i]);let a=Z(i,n[i]);if(a[0]&&(n[a[0]]=a[1]),i.indexOf("_x002e_")!==-1){let s=i.split("_x002e_");if(!n.hasOwnProperty(s[0]))n[s[0]]={_dwaType:"alias"};else if(typeof n[s[0]]!="object"||typeof n[s[0]]=="object"&&!n[s[0]].hasOwnProperty("_dwaType"))throw new Error("The alias name of the linked entity must be unique!");n[s[0]][s[1]]=n[i],a=Z(s[1],n[i]),a[0]&&(n[s[0]][a[0]]=a[1])}}return e&&e.hasOwnProperty("pageNumber")&&n["@"+b.Prefer.Annotations.FetchXmlPagingCookie]!=null&&(n.PagingInfo=l.getFetchXmlPagingCookie(n["@"+b.Prefer.Annotations.FetchXmlPagingCookie],e.pageNumber)),n}function yt(n){return window.atob(n)}function ft(n,e,t){let i=n;t?.hasOwnProperty("parse")&&(i=JSON.parse(i).value,i=yt(i));let a={value:i};e["x-ms-file-name"]&&(a.fileName=e["x-ms-file-name"]),e["x-ms-file-size"]&&(a.fileSize=parseInt(e["x-ms-file-size"]));let s=S(e,"Location");return s&&(a.location=s),a}function ht(n){return n.indexOf("--batchresponse_")>-1}function gt(n){return Pe(n,"Content-Disposition")}function Rt(n){return S(n,"Content-Type")?.startsWith("application/json")==!0}function bt(n,e){let t=j(n,e);return e?.[0].convertedToBatch?t[0]:t}function At(n,e,t){return ft(n,e,t[0])}function Q(n,e,t=0){return ee(JSON.parse(n,Te),e[t])}function Y(n){let e=Number(n);return isFinite(e)?e:n}function Ct(n,e){if(e?.[0]?.valueIfEmpty!==void 0)return e[0].valueIfEmpty;let t=S(n,"OData-EntityId");if(t)return O(t)??void 0;let i=S(n,"Location");if(i){let a={location:i};return n["x-ms-chunk-size"]&&(a.chunkSize=parseInt(n["x-ms-chunk-size"])),a}}function te(n,e,t){return n.length?ht(n)?bt(n,t):gt(e)?At(n,e,t):Rt(e)?Q(n,t):Y(n):Ct(e,t)}var J=y(()=>{"use strict";ke();T();Ee();g();ve()});function k(n){let e={};if(!n)return e;let t=n.split(`\r
`);for(let i=0,a=t.length;i<a;i++){let s=t[i],o=s.indexOf(": ");o>0&&(e[s.substring(0,o)]=s.substring(o+2))}return e}var Ne=y(()=>{"use strict"});var We={};ie(We,{XhrWrapper:()=>U,executeRequest:()=>xt});function xt(n){return new Promise((e,t)=>{Pt(n,e,t)})}function Pt(n,e,t){let i=n.data,a=n.headers,s=n.responseParams,o=n.abortSignal;if(o?.aborted){t(r.handleHttpError({name:"AbortError",code:20,message:"The user aborted a request."}));return}let c=new XMLHttpRequest;c.open(n.method,n.uri,n.isAsync||!1);for(let p in a)c.setRequestHeader(p,a[p]);c.onreadystatechange=function(){if(c.readyState===4)switch(o&&o.removeEventListener("abort",m),c.status){case 200:case 201:case 204:case 206:case 304:{let C=k(c.getAllResponseHeaders()),Oe={data:te(c.responseText,C,s[n.requestId]),headers:C,status:c.status};c=null,e(Oe);break}case 0:break;default:if(!c)break;let p,u;try{u=k(c.getAllResponseHeaders());let C=te(c.responseText,u,s[n.requestId]);if(Array.isArray(C)){t(C);break}p=C.error}catch{c.response.length>0?p={message:c.response}:p={message:"Unexpected Error"}}let h={status:c.status,statusText:c.statusText,headers:u};c=null,t(r.handleHttpError(p,h));break}},n.timeout&&(c.timeout=n.timeout),c.onerror=function(){let p=k(c.getAllResponseHeaders());t(r.handleHttpError({status:c.status,statusText:c.statusText,message:c.responseText||"Network Error",headers:p})),c=null},c.ontimeout=function(){let p=k(c.getAllResponseHeaders());t(r.handleHttpError({name:"TimeoutError",status:c.status,statusText:c.statusText,message:c.responseText||"Request Timed Out",headers:p})),c=null},c.onabort=function(){if(!c)return;let p=k(c.getAllResponseHeaders());t(r.handleHttpError({status:c.status,statusText:c.statusText,message:"Request aborted",headers:p})),c=null};let m=()=>{if(!c)return;let p=k(c.getAllResponseHeaders());t(r.handleHttpError({name:"AbortError",code:20,status:c.status,statusText:c.statusText,message:"The user aborted a request.",headers:p})),c.abort(),c=null};o&&o.addEventListener("abort",m),i?c.send(i):c.send(),U.afterSendEvent&&U.afterSendEvent()}var U,Se=y(()=>{"use strict";x();J();Ne();U=class{}});var Nt={};ie(Nt,{DynamicsWebApi:()=>ae});T();x();var nt=(n,e)=>l.isRunningWithinPortals()?new URL("_api",window.location.origin).toString()+"/":(n||(n=l.getClientUrl()),new URL(`api/${e.path}/v${e.version}`,n).toString()+"/"),L=(n,e,t)=>{let i=t[e];n?.version&&(r.stringParameterCheck(n.version,"DynamicsWebApi.setConfig",`config.${e}.version`),i.version=n.version),n?.path&&(r.stringParameterCheck(n.path,"DynamicsWebApi.setConfig",`config.${e}.path`),i.path=n.path),i.url=nt(t.serverUrl,i)},P=class{static merge(e,t){t?.serverUrl&&(r.stringParameterCheck(t.serverUrl,"DynamicsWebApi.setConfig","config.serverUrl"),e.serverUrl=t.serverUrl),L(t?.dataApi,"dataApi",e),L(t?.searchApi,"searchApi",e),t?.impersonate&&(e.impersonate=r.guidParameterCheck(t.impersonate,"DynamicsWebApi.setConfig","config.impersonate")),t?.impersonateAAD&&(e.impersonateAAD=r.guidParameterCheck(t.impersonateAAD,"DynamicsWebApi.setConfig","config.impersonateAAD")),t?.onTokenRefresh&&(r.callbackParameterCheck(t.onTokenRefresh,"DynamicsWebApi.setConfig","config.onTokenRefresh"),e.onTokenRefresh=t.onTokenRefresh),t?.includeAnnotations&&(r.stringParameterCheck(t.includeAnnotations,"DynamicsWebApi.setConfig","config.includeAnnotations"),e.includeAnnotations=t.includeAnnotations),t?.timeout&&(r.numberParameterCheck(t.timeout,"DynamicsWebApi.setConfig","config.timeout"),e.timeout=t.timeout),t?.maxPageSize&&(r.numberParameterCheck(t.maxPageSize,"DynamicsWebApi.setConfig","config.maxPageSize"),e.maxPageSize=t.maxPageSize),t?.returnRepresentation&&(r.boolParameterCheck(t.returnRepresentation,"DynamicsWebApi.setConfig","config.returnRepresentation"),e.returnRepresentation=t.returnRepresentation),t?.useEntityNames&&(r.boolParameterCheck(t.useEntityNames,"DynamicsWebApi.setConfig","config.useEntityNames"),e.useEntityNames=t.useEntityNames),t?.headers&&(e.headers=t.headers)}static default(){return{serverUrl:null,impersonate:null,impersonateAAD:null,onTokenRefresh:null,includeAnnotations:null,maxPageSize:null,returnRepresentation:null,proxy:null,dataApi:{path:"data",version:"9.2",url:""},searchApi:{path:"search",version:"1.0",url:""}}}};P.mergeApiConfigs=L;T();x();T();T();x();g();var R=null,H=n=>{R=n},w=(n,e)=>{if(n.path=n.path||"",n.functionName=n.functionName||"",n.url)r.stringParameterCheck(n.url,`DynamicsWebApi.${n.functionName}`,"request.url"),n.path=n.url.replace(e.dataApi.url,"");else if(!n._isUnboundRequest&&!n.contentId&&!n.collection&&r.parameterCheck(n.collection,`DynamicsWebApi.${n.functionName}`,"request.collection"),n.collection!=null&&(r.stringParameterCheck(n.collection,`DynamicsWebApi.${n.functionName}`,"request.collection"),n.path=n.collection,n.key&&(n.key=r.keyParameterCheck(n.key,`DynamicsWebApi.${n.functionName}`,"request.key"),n.path+=`(${n.key})`)),n.contentId&&(r.stringParameterCheck(n.contentId,`DynamicsWebApi.${n.functionName}`,"request.contentId"),n.contentId.startsWith("$")&&(n.path=n.path?`${n.contentId}/${n.path}`:n.contentId)),n.addPath&&(n.path&&(n.path+="/"),n.path+=n.addPath),n.path=De(n,e,n.path),n.fetchXml){r.stringParameterCheck(n.fetchXml,`DynamicsWebApi.${n.functionName}`,"request.fetchXml");let t=n.path.indexOf("?")===-1?"?":"&";n.path+=`${t}fetchXml=${encodeURIComponent(n.fetchXml)}`}return n.hasOwnProperty("async")&&n.async!=null?r.boolParameterCheck(n.async,`DynamicsWebApi.${n.functionName}`,"request.async"):n.async=!0,n.headers=at(n,e),n},De=(n,e,t="",i="&")=>{let a=[];if(n){if(n.navigationProperty){if(r.stringParameterCheck(n.navigationProperty,`DynamicsWebApi.${n.functionName}`,"request.navigationProperty"),t+="/"+n.navigationProperty,n.navigationPropertyKey){let s=r.keyParameterCheck(n.navigationPropertyKey,`DynamicsWebApi.${n.functionName}`,"request.navigationPropertyKey");t+="("+s+")"}n.navigationProperty==="Attributes"&&n.metadataAttributeType&&(r.stringParameterCheck(n.metadataAttributeType,`DynamicsWebApi.${n.functionName}`,"request.metadataAttributeType"),t+="/"+n.metadataAttributeType)}if(n.select?.length&&(r.arrayParameterCheck(n.select,`DynamicsWebApi.${n.functionName}`,"request.select"),n.functionName=="retrieve"&&n.select.length==1&&n.select[0].endsWith("/$ref")?t+="/"+n.select[0]:(n.select[0].startsWith("/")&&n.functionName=="retrieve"&&(n.navigationProperty==null?t+=n.select.shift():n.select.shift()),n.select.length&&a.push("$select="+n.select.join(",")))),n.filter){r.stringParameterCheck(n.filter,`DynamicsWebApi.${n.functionName}`,"request.filter");let s=le(n.filter);a.push("$filter="+encodeURIComponent(s))}if(n.fieldName&&(r.stringParameterCheck(n.fieldName,`DynamicsWebApi.${n.functionName}`,"request.fieldName"),n.property||(n.property=n.fieldName),delete n.fieldName),n.property&&(r.stringParameterCheck(n.property,`DynamicsWebApi.${n.functionName}`,"request.property"),t+="/"+n.property),n.savedQuery&&a.push("savedQuery="+r.guidParameterCheck(n.savedQuery,`DynamicsWebApi.${n.functionName}`,"request.savedQuery")),n.userQuery&&a.push("userQuery="+r.guidParameterCheck(n.userQuery,`DynamicsWebApi.${n.functionName}`,"request.userQuery")),n.apply&&(r.stringParameterCheck(n.apply,`DynamicsWebApi.${n.functionName}`,"request.apply"),a.push("$apply="+n.apply)),n.count&&(r.boolParameterCheck(n.count,`DynamicsWebApi.${n.functionName}`,"request.count"),a.push("$count="+n.count)),n.top&&n.top>0&&(r.numberParameterCheck(n.top,`DynamicsWebApi.${n.functionName}`,"request.top"),a.push("$top="+n.top)),n.orderBy!=null&&n.orderBy.length&&(r.arrayParameterCheck(n.orderBy,`DynamicsWebApi.${n.functionName}`,"request.orderBy"),a.push("$orderby="+n.orderBy.join(","))),n.partitionId&&(r.stringParameterCheck(n.partitionId,`DynamicsWebApi.${n.functionName}`,"request.partitionId"),a.push("partitionid='"+n.partitionId+"'")),n.downloadSize&&(r.stringParameterCheck(n.downloadSize,`DynamicsWebApi.${n.functionName}`,"request.downloadSize"),a.push("size="+n.downloadSize)),n.queryParams?.length&&(r.arrayParameterCheck(n.queryParams,`DynamicsWebApi.${n.functionName}`,"request.queryParams"),a.push(n.queryParams.join("&"))),n.fileName&&(r.stringParameterCheck(n.fileName,`DynamicsWebApi.${n.functionName}`,"request.fileName"),a.push("x-ms-file-name="+n.fileName)),n.data&&r.parameterCheck(n.data,`DynamicsWebApi.${n.functionName}`,"request.data"),n.isBatch&&r.boolParameterCheck(n.isBatch,`DynamicsWebApi.${n.functionName}`,"request.isBatch"),l.isNull(n.inChangeSet)||r.boolParameterCheck(n.inChangeSet,`DynamicsWebApi.${n.functionName}`,"request.inChangeSet"),n.isBatch&&l.isNull(n.inChangeSet)&&(n.inChangeSet=!0),n.timeout&&r.numberParameterCheck(n.timeout,`DynamicsWebApi.${n.functionName}`,"request.timeout"),n.expand?.length)if(r.stringOrArrayParameterCheck(n.expand,`DynamicsWebApi.${n.functionName}`,"request.expand"),typeof n.expand=="string")a.push("$expand="+n.expand);else{let s=[];for(let{property:o,...c}of n.expand){if(!o)continue;let m={functionName:`${n.functionName} $expand`,...c},p=De(m,e,"",";");p&&(p=`(${p.slice(1)})`),s.push(o+p)}s.length&&a.push("$expand="+s.join(","))}}return a.length?t+"?"+a.join(i):t},at=(n,e)=>{let t={...e.headers,...n.userHeaders},i=it(n,e);if(i.length&&(t.Prefer=i),n.collection==="$metadata"&&(t.Accept="application/xml"),n.transferMode&&(t["x-ms-transfer-mode"]=n.transferMode),n.ifmatch!=null&&n.ifnonematch!=null)throw new Error(`DynamicsWebApi.${n.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`);return n.ifmatch&&(r.stringParameterCheck(n.ifmatch,`DynamicsWebApi.${n.functionName}`,"request.ifmatch"),t["If-Match"]=n.ifmatch),n.ifnonematch&&(r.stringParameterCheck(n.ifnonematch,`DynamicsWebApi.${n.functionName}`,"request.ifnonematch"),t["If-None-Match"]=n.ifnonematch),n.impersonate&&(r.stringParameterCheck(n.impersonate,`DynamicsWebApi.${n.functionName}`,"request.impersonate"),t.MSCRMCallerID=r.guidParameterCheck(n.impersonate,`DynamicsWebApi.${n.functionName}`,"request.impersonate")),n.impersonateAAD&&(r.stringParameterCheck(n.impersonateAAD,`DynamicsWebApi.${n.functionName}`,"request.impersonateAAD"),t.CallerObjectId=r.guidParameterCheck(n.impersonateAAD,`DynamicsWebApi.${n.functionName}`,"request.impersonateAAD")),n.token&&(r.stringParameterCheck(n.token,`DynamicsWebApi.${n.functionName}`,"request.token"),t.Authorization="Bearer "+n.token),n.duplicateDetection&&(r.boolParameterCheck(n.duplicateDetection,`DynamicsWebApi.${n.functionName}`,"request.duplicateDetection"),t["MSCRM.SuppressDuplicateDetection"]="false"),n.bypassCustomPluginExecution&&(r.boolParameterCheck(n.bypassCustomPluginExecution,`DynamicsWebApi.${n.functionName}`,"request.bypassCustomPluginExecution"),t["MSCRM.BypassCustomPluginExecution"]="true"),n.noCache&&(r.boolParameterCheck(n.noCache,`DynamicsWebApi.${n.functionName}`,"request.noCache"),t["Cache-Control"]="no-cache"),n.mergeLabels&&(r.boolParameterCheck(n.mergeLabels,`DynamicsWebApi.${n.functionName}`,"request.mergeLabels"),t["MSCRM.MergeLabels"]="true"),n.contentId&&(r.stringParameterCheck(n.contentId,`DynamicsWebApi.${n.functionName}`,"request.contentId"),n.contentId.startsWith("$")||(t["Content-ID"]=n.contentId)),n.contentRange&&(r.stringParameterCheck(n.contentRange,`DynamicsWebApi.${n.functionName}`,"request.contentRange"),t["Content-Range"]=n.contentRange),n.range&&(r.stringParameterCheck(n.range,`DynamicsWebApi.${n.functionName}`,"request.range"),t.Range=n.range),t},it=(n,e)=>{let{returnRepresentation:t,includeAnnotations:i,maxPageSize:a,trackChanges:s,continueOnError:o}=n;n.prefer&&n.prefer.length&&(r.stringOrArrayParameterCheck(n.prefer,`DynamicsWebApi.${n.functionName}`,"request.prefer"),(typeof n.prefer=="string"?n.prefer.split(","):n.prefer).forEach(p=>{let u=p.trim();u==="return=representation"?t=!0:u.includes("odata.include-annotations=")?i=F(u.replace("odata.include-annotations=","")):u.startsWith("odata.maxpagesize=")?a=Number(F(u.replace("odata.maxpagesize=","")))||0:u.includes("odata.track-changes")?s=!0:u.includes("odata.continue-on-error")&&(o=!0)}));let c=[];return e&&(t==null&&(t=e.returnRepresentation),i=i??e.includeAnnotations,a=a??e.maxPageSize),t&&(r.boolParameterCheck(t,`DynamicsWebApi.${n.functionName}`,"request.returnRepresentation"),c.push("return=representation")),i&&(r.stringParameterCheck(i,`DynamicsWebApi.${n.functionName}`,"request.includeAnnotations"),c.push(`odata.include-annotations="${i}"`)),a&&a>0&&(r.numberParameterCheck(a,`DynamicsWebApi.${n.functionName}`,"request.maxPageSize"),c.push("odata.maxpagesize="+a)),s&&(r.boolParameterCheck(s,`DynamicsWebApi.${n.functionName}`,"request.trackChanges"),c.push("odata.track-changes")),o&&(r.boolParameterCheck(o,`DynamicsWebApi.${n.functionName}`,"request.continueOnError"),c.push("odata.continue-on-error")),c.join(",")},K=(n,e,t)=>{let i=`dwa_batch_${l.generateUUID()}`,a=[],s=null,o=1e5,c=(p,u)=>{for(let h in p)h==="Authorization"||h==="Content-ID"||u.push(`${h}: ${p[h]}`)};n.forEach(p=>{p.functionName="executeBatch",t?.inChangeSet===!1&&(p.inChangeSet=!1);let u=p.method==="GET"?!1:!!p.inChangeSet;if(!u&&s&&(a.push(`\r
--${s}--`),s=null,o=1e5),s||(a.push(`\r
--${i}`),u&&(s=`changeset_${l.generateUUID()}`,a.push("Content-Type: multipart/mixed;boundary="+s))),u&&a.push(`\r
--${s}`),a.push("Content-Type: application/http"),a.push("Content-Transfer-Encoding: binary"),u){let h=p.headers.hasOwnProperty("Content-ID")?p.headers["Content-ID"]:++o;a.push(`Content-ID: ${h}`)}p.path?.startsWith("$")?a.push(`\r
${p.method} ${p.path} HTTP/1.1`):a.push(`\r
${p.method} ${e.dataApi.url}${p.path} HTTP/1.1`),p.method==="GET"?a.push("Accept: application/json"):a.push("Content-Type: application/json"),p.headers&&c(p.headers,a),p.data&&a.push(`\r
${V(p.data,e)}`)}),s&&a.push(`\r
--${s}--`),a.push(`\r
--${i}--\r
`);let m=z(t?.userHeaders);return m["Content-Type"]=`multipart/mixed;boundary=${i}`,{headers:m,body:a.join(`\r
`)}},I=n=>{if(l.isNull(R))return null;let e=R[n];if(!e){for(let t in R)if(R[t]===n)return n}return e},V=(n,e)=>{if(!n)return null;if(n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array)return n;let t=s=>{let o=X.exec(s);if(o&&o.length>2){let c=I(o[1]);if(!l.isNull(c))return s.replace(X,`${c}$2`)}return s},i=(s,o)=>(o.startsWith(e.dataApi.url)||(s.endsWith("@odata.bind")?o.startsWith("/")||(o=`/${o}`):o=`${e.dataApi.url}${me(o)}`),o),a=JSON.stringify(n,(s,o)=>{if(s.endsWith("@odata.bind")||s.endsWith("@odata.id"))typeof o=="string"&&!o.startsWith("$")&&(o=M(o),e.useEntityNames&&(o=t(o)),o=i(s,o));else if(s.startsWith("oData")||s.endsWith("_Formatted")||s.endsWith("_NavigationProperty")||s.endsWith("_LogicalName"))return;return o});return de(a)},z=(n={})=>(n.Accept||(n.Accept="application/json"),n["OData-MaxVersion"]||(n["OData-MaxVersion"]="4.0"),n["OData-Version"]||(n["OData-Version"]="4.0"),n["Content-Range"]?n["Content-Type"]="application/octet-stream":n["Content-Type"]||(n["Content-Type"]="application/json; charset=utf-8"),n);x();async function Ie(n){return(Se(),re(We)).executeRequest(n)}var _e=(n,e)=>{E[n]?E[n].push(e):E[n]=[e]},Dt=(n,e)=>{A[n]?A[n].push(e):A[n]=[e]},ne=n=>{delete E[n],A.hasOwnProperty(n)&&delete A[n]},Ue=async(n,e)=>{try{let t=await v.sendRequest(n,e);return ne(n.requestId),t}catch(t){throw ne(n.requestId),t}finally{ne(n.requestId)}},A={},E={},kt=["$metadata","EntityDefinitions","RelationshipDefinitions","GlobalOptionSetDefinitions","ManagedPropertyDefinitions","query","suggest","autocomplete"],Tt=n=>kt.indexOf(n)>-1,Et=async(n,e)=>{if(!l.isNull(R))return I(n)||n;let t=w({method:"GET",collection:"EntityDefinitions",select:["EntitySetName","LogicalName"],noCache:!0,functionName:"retrieveMultiple"},e),i=await Ue(t,e);H({});for(let a=0;a<i.data.value.length;a++)R[i.data.value[a].LogicalName]=i.data.value[a].EntitySetName;return I(n)||n},vt=async(n,e)=>{if(!n||Tt(n)||(n=n.toLowerCase(),!e.useEntityNames))return n;try{return await Et(n,e)}catch(t){throw new Error("Unable to fetch Collection Names. Error: "+t.message)}},v=class{static async sendRequest(e,t){e.headers=e.headers||{},e.responseParameters=e.responseParameters||{},e.requestId=e.requestId||l.generateUUID(),_e(e.requestId,e.responseParameters);let i=null,a=e.responseParameters?.convertedToBatch;if(e.path==="$batch"&&!a){let c=A[e.requestId];if(!c)throw r.batchIsEmpty();let m=K(c,t,e);i=m.body,e.headers={...m.headers,...e.headers},delete A[e.requestId]}else i=a?e.data:V(e.data,t),a||(e.headers=z(e.headers));t.impersonate&&!e.headers.MSCRMCallerID&&(e.headers.MSCRMCallerID=t.impersonate),t.impersonateAAD&&!e.headers.CallerObjectId&&(e.headers.CallerObjectId=t.impersonateAAD);let s=null;if(t.onTokenRefresh&&(!e.headers||e.headers&&!e.headers.Authorization)&&(s=await t.onTokenRefresh(),!s))throw new Error("Token is empty. Request is aborted.");s&&(e.headers.Authorization="Bearer "+(s.hasOwnProperty("accessToken")?s.accessToken:s)),l.isRunningWithinPortals()&&(e.headers.__RequestVerificationToken=await window.shell.getTokenDeferred());let o=e.apiConfig?e.apiConfig.url:t.dataApi.url;return await Ie({method:e.method,uri:o.toString()+e.path,data:i,proxy:t.proxy,isAsync:e.async,headers:e.headers,requestId:e.requestId,abortSignal:e.signal,responseParams:E,timeout:e.timeout||t.timeout})}static async makeRequest(e,t){if(e.responseParameters=e.responseParameters||{},e.userHeaders=e.headers,delete e.headers,!e.isBatch){let i=await vt(e.collection,t);if(e.collection=i,w(e,t),e.responseParameters.convertedToBatch=!1,e.path.length>2e3){let a=K([e],t);e.headers.Authorization&&(a.headers.Authorization=e.headers.Authorization),e.method="POST",e.path="$batch",e.data=a.body,e.headers={...a.headers,...e.userHeaders},e.responseParameters.convertedToBatch=!0}return Ue(e,t)}w(e,t),_e(e.requestId,e.responseParameters),Dt(e.requestId,e)}static _clearTestData(){H(null),E={},A={}}static getCollectionName(e){return I(e)}};g();var ae=class n{constructor(e){this._config=P.default();this._isBatch=!1;this._batchRequestId=null;this.setConfig=e=>P.merge(this._config,e);this._makeRequest=async e=>(e.isBatch=this._isBatch,this._batchRequestId&&(e.requestId=this._batchRequestId),v.makeRequest(e,this._config));this.create=async e=>{r.parameterCheck(e,"DynamicsWebApi.create","request");let t;return e.functionName?t=e:(t=l.copyRequest(e),t.functionName="create"),t.method="POST",(await this._makeRequest(t))?.data};this.retrieve=async e=>{r.parameterCheck(e,"DynamicsWebApi.retrieve","request");let t;return e.functionName?t=e:(t=l.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=>{r.parameterCheck(e,"DynamicsWebApi.update","request");let t;e.functionName?t=e:(t=l.copyRequest(e),t.functionName="update"),t.method??(t.method=Re(t.collection)),t.responseParameters={valueIfEmpty:!0},t.ifmatch??(t.ifmatch="*");let i=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(a){if(i&&a.status===412)return!1;throw a}};this.updateSingleProperty=async e=>{r.parameterCheck(e,"DynamicsWebApi.updateSingleProperty","request"),r.parameterCheck(e.fieldValuePair,"DynamicsWebApi.updateSingleProperty","request.fieldValuePair");var t=Object.keys(e.fieldValuePair)[0],i=e.fieldValuePair[t];let a=l.copyRequest(e);return a.navigationProperty=t,a.data={value:i},a.functionName="updateSingleProperty",a.method="PUT",delete a.fieldValuePair,(await this._makeRequest(a))?.data};this.deleteRecord=async e=>{r.parameterCheck(e,"DynamicsWebApi.deleteRecord","request");let t;e.functionName?t=e:(t=l.copyRequest(e),t.functionName="deleteRecord"),t.method="DELETE",t.responseParameters={valueIfEmpty:!0};let i=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(a){if(i&&a.status===412)return!1;throw a}};this.upsert=async e=>{r.parameterCheck(e,"DynamicsWebApi.upsert","request");let t=l.copyRequest(e);t.method="PATCH",t.functionName="upsert";let i=t.ifnonematch,a=t.ifmatch;try{return(await this._makeRequest(t))?.data}catch(s){if(i&&s.status===412)return null;if(a&&s.status===404)return null;throw s}};this._uploadFileChunk=async(e,t,i,a=0)=>{if(l.setFileChunk(e,t,i,a),await this._makeRequest(e),a+=i,a<=t.length)return this._uploadFileChunk(e,t,i,a)};this.uploadFile=async e=>{r.throwBatchIncompatible("DynamicsWebApi.uploadFile",this._isBatch),r.parameterCheck(e,"DynamicsWebApi.uploadFile","request");let t=l.copyRequest(e,["data"]);t.method="PATCH",t.functionName="uploadFile",t.transferMode="chunked";let i=await this._makeRequest(t);return t.url=i?.data.location,delete t.transferMode,delete t.fieldName,delete t.property,delete t.fileName,this._uploadFileChunk(t,e.data,i?.data.chunkSize)};this._downloadFileChunk=async(e,t=0,i="")=>{e.range="bytes="+t+"-"+(t+l.downloadChunkSize-1),e.downloadSize="full";let a=await this._makeRequest(e);return e.url=a?.data.location,i+=a?.data.value,t+=l.downloadChunkSize,t<=a?.data.fileSize?this._downloadFileChunk(e,t,i):{fileName:a?.data.fileName,fileSize:a?.data.fileSize,data:l.convertToFileBuffer(i)}};this.downloadFile=e=>{r.throwBatchIncompatible("DynamicsWebApi.downloadFile",this._isBatch),r.parameterCheck(e,"DynamicsWebApi.downloadFile","request");let t=l.copyRequest(e);return t.method="GET",t.functionName="downloadFile",t.responseParameters={parse:!0},this._downloadFileChunk(t)};this.retrieveMultiple=async(e,t)=>{r.parameterCheck(e,"DynamicsWebApi.retrieveMultiple","request");let i;return e.functionName?i=e:(i=l.copyRequest(e),i.functionName="retrieveMultiple"),i.method="GET",t&&(r.stringParameterCheck(t,"DynamicsWebApi.retrieveMultiple","nextPageLink"),i.url=t),(await this._makeRequest(i))?.data};this._retrieveAllRequest=async(e,t,i=[])=>{let a=await this.retrieveMultiple(e,t);i=i.concat(a.value);let s=a.oDataNextLink;if(s)return this._retrieveAllRequest(e,s,i);let o={value:i};return a.oDataDeltaLink&&(o["@odata.deltaLink"]=a.oDataDeltaLink,o.oDataDeltaLink=a.oDataDeltaLink),o};this.retrieveAll=e=>(r.throwBatchIncompatible("DynamicsWebApi.retrieveAll",this._isBatch),this._retrieveAllRequest(e));this.count=async e=>{r.parameterCheck(e,"DynamicsWebApi.count","request");let t=l.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=>{r.throwBatchIncompatible("DynamicsWebApi.countAll",this._isBatch),r.parameterCheck(e,"DynamicsWebApi.countAll","request");let t=await this._retrieveAllRequest(e);return t&&t.value?t.value.length:0};this.fetch=async e=>{r.parameterCheck(e,"DynamicsWebApi.fetch","request");let t=l.copyRequest(e);if(t.method="GET",t.functionName="fetch",r.stringParameterCheck(t.fetchXml,"DynamicsWebApi.fetch","request.fetchXml"),t.fetchXml&&!be.test(t.fetchXml)){let a="";Ae.test(t.fetchXml)||(t.pageNumber=t.pageNumber||1,r.numberParameterCheck(t.pageNumber,"DynamicsWebApi.fetch","request.pageNumber"),a=`$1 page="${t.pageNumber}"`),t.pagingCookie!=null&&(r.stringParameterCheck(t.pagingCookie,"DynamicsWebApi.fetch","request.pagingCookie"),a+=` paging-cookie="${t.pagingCookie}"`),a&&(t.fetchXml=t.fetchXml.replace(Ce,a))}return t.responseParameters={pageNumber:t.pageNumber},(await this._makeRequest(t))?.data};this.fetchAll=async e=>{r.parameterCheck(e,"DynamicsWebApi.fetchAll","request");let t=async(i,a=[])=>{let s=await this.fetch(i);return a=a.concat(s.value),s.PagingInfo?(i.pageNumber=s.PagingInfo.nextPage,i.pagingCookie=s.PagingInfo.cookie,t(i,a)):{value:a}};return r.throwBatchIncompatible("DynamicsWebApi.fetchAll",this._isBatch),t(e)};this.associate=async e=>{r.parameterCheck(e,"DynamicsWebApi.associate","request");let t=l.copyRequest(e);t.method="POST",t.functionName="associate",r.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associate","request.relatedcollection"),r.stringParameterCheck(e.relationshipName,"DynamicsWebApi.associate","request.relationshipName");let i=r.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associate","request.primaryKey"),a=r.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associate","request.relatedKey");t.navigationProperty=e.relationshipName+"/$ref",t.key=i,t.data={"@odata.id":`${e.relatedCollection}(${a})`},await this._makeRequest(t)};this.disassociate=async e=>{r.parameterCheck(e,"DynamicsWebApi.disassociate","request");let t=l.copyRequest(e);t.method="DELETE",t.functionName="disassociate",r.stringParameterCheck(e.relationshipName,"DynamicsWebApi.disassociate","request.relationshipName");let i=r.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociate","request.primaryKey"),a=r.keyParameterCheck(e.relatedKey,"DynamicsWebApi.disassociate","request.relatedId");t.key=i,t.navigationProperty=`${e.relationshipName}(${a})/$ref`,await this._makeRequest(t)};this.associateSingleValued=async e=>{r.parameterCheck(e,"DynamicsWebApi.associateSingleValued","request");let t=l.copyRequest(e);t.method="PUT",t.functionName="associateSingleValued";let i=r.keyParameterCheck(e.primaryKey,"DynamicsWebApi.associateSingleValued","request.primaryKey"),a=r.keyParameterCheck(e.relatedKey,"DynamicsWebApi.associateSingleValued","request.relatedKey");r.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.associateSingleValued","request.navigationProperty"),r.stringParameterCheck(e.relatedCollection,"DynamicsWebApi.associateSingleValued","request.relatedcollection"),t.navigationProperty+="/$ref",t.key=i,t.data={"@odata.id":`${e.relatedCollection}(${a})`},await this._makeRequest(t)};this.disassociateSingleValued=async e=>{r.parameterCheck(e,"DynamicsWebApi.disassociateSingleValued","request");let t=l.copyRequest(e);t.method="DELETE",t.functionName="disassociateSingleValued";let i=r.keyParameterCheck(e.primaryKey,"DynamicsWebApi.disassociateSingleValued","request.primaryKey");r.stringParameterCheck(e.navigationProperty,"DynamicsWebApi.disassociateSingleValued","request.navigationProperty"),t.navigationProperty+="/$ref",t.key=i,await this._makeRequest(t)};this.callFunction=async e=>{r.parameterCheck(e,"DynamicsWebApi.callFunction","request");let t=p=>p.name||p.functionName,i=typeof e!="string",a=i?t(e):e,s=i?"request.name":"name",o=i?l.copyObject(e,["name"]):{functionName:a};r.stringParameterCheck(a,"DynamicsWebApi.callFunction",s);let c=l.buildFunctionParameters(o.parameters);return o.method="GET",o.addPath=a+c.key,o.queryParams=c.queryParams,o._isUnboundRequest=!o.collection,o.functionName="callFunction",(await this._makeRequest(o))?.data};this.callAction=async e=>{r.parameterCheck(e,"DynamicsWebApi.callAction","request"),r.stringParameterCheck(e.actionName,"DynamicsWebApi.callAction","request.actionName");let t=l.copyRequest(e,["action"]);return t.method="POST",t.functionName="callAction",t.addPath=e.actionName,t._isUnboundRequest=!t.collection,t.data=e.action,(await this._makeRequest(t))?.data};this.createEntity=e=>{r.parameterCheck(e,"DynamicsWebApi.createEntity","request"),r.parameterCheck(e.data,"DynamicsWebApi.createEntity","request.data");let t=l.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="createEntity",this.create(t)};this.updateEntity=e=>{r.parameterCheck(e,"DynamicsWebApi.updateEntity","request"),r.parameterCheck(e.data,"DynamicsWebApi.updateEntity","request.data"),r.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateEntity","request.data.MetadataId");let t=l.copyRequest(e);return t.collection="EntityDefinitions",t.key=t.data.MetadataId,t.functionName="updateEntity",t.method="PUT",this.update(t)};this.retrieveEntity=e=>{r.parameterCheck(e,"DynamicsWebApi.retrieveEntity","request"),r.keyParameterCheck(e.key,"DynamicsWebApi.retrieveEntity","request.key");let t=l.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",this.retrieve(t)};this.retrieveEntities=e=>{let t=e?l.copyRequest(e):{};return t.collection="EntityDefinitions",t.functionName="retrieveEntities",this.retrieveMultiple(t)};this.createAttribute=e=>{r.parameterCheck(e,"DynamicsWebApi.createAttribute","request"),r.parameterCheck(e.data,"DynamicsWebApi.createAttribute","request.data"),r.keyParameterCheck(e.entityKey,"DynamicsWebApi.createAttribute","request.entityKey");let t=l.copyRequest(e);return t.collection="EntityDefinitions",t.functionName="retrieveEntity",t.navigationProperty="Attributes",t.key=e.entityKey,this.create(t)};this.updateAttribute=e=>{r.parameterCheck(e,"DynamicsWebApi.updateAttribute","request"),r.parameterCheck(e.data,"DynamicsWebApi.updateAttribute","request.data"),r.keyParameterCheck(e.entityKey,"DynamicsWebApi.updateAttribute","request.entityKey"),r.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateAttribute","request.data.MetadataId"),e.castType&&r.stringParameterCheck(e.castType,"DynamicsWebApi.updateAttribute","request.castType");let t=l.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=>{r.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),r.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttributes","request.entityKey"),e.castType&&r.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttributes","request.castType");let t=l.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=>{r.parameterCheck(e,"DynamicsWebApi.retrieveAttributes","request"),r.keyParameterCheck(e.entityKey,"DynamicsWebApi.retrieveAttribute","request.entityKey"),r.keyParameterCheck(e.attributeKey,"DynamicsWebApi.retrieveAttribute","request.attributeKey"),e.castType&&r.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveAttribute","request.castType");let t=l.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=>{r.parameterCheck(e,"DynamicsWebApi.createRelationship","request"),r.parameterCheck(e.data,"DynamicsWebApi.createRelationship","request.data");let t=l.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="createRelationship",this.create(t)};this.updateRelationship=e=>{r.parameterCheck(e,"DynamicsWebApi.updateRelationship","request"),r.parameterCheck(e.data,"DynamicsWebApi.updateRelationship","request.data"),r.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateRelationship","request.data.MetadataId"),e.castType&&r.stringParameterCheck(e.castType,"DynamicsWebApi.updateRelationship","request.castType");let t=l.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=>{r.parameterCheck(e,"DynamicsWebApi.deleteRelationship","request"),r.keyParameterCheck(e.key,"DynamicsWebApi.deleteRelationship","request.key");let t=l.copyRequest(e);return t.collection="RelationshipDefinitions",t.functionName="deleteRelationship",this.deleteRecord(t)};this.retrieveRelationships=e=>{let t=e?l.copyRequest(e):{};return t.collection="RelationshipDefinitions",t.functionName="retrieveRelationships",e&&e.castType&&(r.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationships","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveRelationship=e=>{r.parameterCheck(e,"DynamicsWebApi.retrieveRelationship","request"),r.keyParameterCheck(e.key,"DynamicsWebApi.retrieveRelationship","request.key"),e.castType&&r.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveRelationship","request.castType");let t=l.copyRequest(e);return t.collection="RelationshipDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveRelationship",this.retrieve(t)};this.createGlobalOptionSet=e=>{r.parameterCheck(e,"DynamicsWebApi.createGlobalOptionSet","request"),r.parameterCheck(e.data,"DynamicsWebApi.createGlobalOptionSet","request.data");let t=l.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="createGlobalOptionSet",this.create(t)};this.updateGlobalOptionSet=e=>{r.parameterCheck(e,"DynamicsWebApi.updateGlobalOptionSet","request"),r.parameterCheck(e.data,"DynamicsWebApi.updateGlobalOptionSet","request.data"),r.guidParameterCheck(e.data.MetadataId,"DynamicsWebApi.updateGlobalOptionSet","request.data.MetadataId"),e.castType&&r.stringParameterCheck(e.castType,"DynamicsWebApi.updateGlobalOptionSet","request.castType");let t=l.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.key=e.data.MetadataId,t.functionName="updateGlobalOptionSet",t.method="PUT",this.update(t)};this.deleteGlobalOptionSet=e=>{r.parameterCheck(e,"DynamicsWebApi.deleteGlobalOptionSet","request");let t=l.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.functionName="deleteGlobalOptionSet",this.deleteRecord(t)};this.retrieveGlobalOptionSet=e=>{r.parameterCheck(e,"DynamicsWebApi.retrieveGlobalOptionSet","request"),e.castType&&r.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSet","request.castType");let t=l.copyRequest(e);return t.collection="GlobalOptionSetDefinitions",t.navigationProperty=e.castType,t.functionName="retrieveGlobalOptionSet",this.retrieve(t)};this.retrieveGlobalOptionSets=e=>{let t=e?l.copyRequest(e):{};return t.collection="GlobalOptionSetDefinitions",t.functionName="retrieveGlobalOptionSets",e?.castType&&(r.stringParameterCheck(e.castType,"DynamicsWebApi.retrieveGlobalOptionSets","request.castType"),t.navigationProperty=e.castType),this.retrieveMultiple(t)};this.retrieveCsdlMetadata=async e=>{let t=e?l.copyRequest(e):{};return t.collection="$metadata",t.functionName="retrieveCsdlMetadata",e?.addAnnotations&&(r.boolParameterCheck(e.addAnnotations,"DynamicsWebApi.retrieveCsdlMetadata","request.addAnnotations"),t.includeAnnotations="*"),(await this._makeRequest(t))?.data};this.search=async e=>{r.parameterCheck(e,"DynamicsWebApi.search","request");let t=l.isObject(e),i=t?"request.query.search":"term",a=t?l.copyObject(e):{query:{search:e}};return r.parameterCheck(a.query,"DynamicsWebApi.search","request.query"),r.stringParameterCheck(a.query.search,"DynamicsWebApi.search",i),r.maxLengthStringParameterCheck(a.query.search,"DynamicsWebApi.search",i,100),a.collection="query",a.functionName="search",a.method="POST",a.data=a.query,a.apiConfig=this._config.searchApi,delete a.query,(await this._makeRequest(a))?.data};this.suggest=async e=>{r.parameterCheck(e,"DynamicsWebApi.suggest","request");let t=l.isObject(e),i=t?"request.query.search":"term",a=t?l.copyObject(e):{query:{search:e}};return r.parameterCheck(a.query,"DynamicsWebApi.suggest","request.query"),r.stringParameterCheck(a.query.search,"DynamicsWebApi.suggest",i),r.maxLengthStringParameterCheck(a.query.search,"DynamicsWebApi.suggest",i,100),a.functionName=a.collection="suggest",a.method="POST",a.data=a.query,a.apiConfig=this._config.searchApi,delete a.query,(await this._makeRequest(a))?.data};this.autocomplete=async e=>{r.parameterCheck(e,"DynamicsWebApi.autocomplete","request");let t=l.isObject(e),i=t?"request.query.search":"term",a=t?l.copyObject(e):{query:{search:e}};return t&&r.parameterCheck(a.query,"DynamicsWebApi.autocomplete","request.query"),r.stringParameterCheck(a.query.search,"DynamicsWebApi.autocomplete",i),r.maxLengthStringParameterCheck(a.query.search,"DynamicsWebApi.autocomplete",i,100),a.functionName=a.collection="autocomplete",a.method="POST",a.data=a.query,a.apiConfig=this._config.searchApi,delete a.query,(await this._makeRequest(a))?.data};this.startBatch=()=>{this._isBatch=!0,this._batchRequestId=l.generateUUID()};this.executeBatch=async e=>{r.throwBatchNotStarted(this._isBatch);let t=e?l.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 n(e||this._config);this.Utility={getCollectionName:e=>v.getCollectionName(e)};P.merge(this._config,e)}};return re(Nt);})();
/*! dynamics-web-api v2.3.0 (c) 2025 Aleksandr Rogov. License: MIT */
"use strict";var _dynamicsWebApiExports=(()=>{var Ce=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Dn=Object.getOwnPropertyNames;var In=Object.prototype.hasOwnProperty;var Ke=e=>{throw TypeError(e)};var b=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ye=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},kn=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Dn(t))!In.call(e,n)&&n!==r&&Ce(e,n,{get:()=>t[n],enumerable:!(a=Pn(t,n))||a.enumerable});return e};var Je=e=>kn(Ce({},"__esModule",{value:!0}),e);var je=(e,t,r)=>t.has(e)||Ke("Cannot "+r);var m=(e,t,r)=>(je(e,t,"read from private field"),r?r.call(e):t.get(e)),B=(e,t,r)=>t.has(e)?Ke("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),L=(e,t,r,a)=>(je(e,t,"write to private field"),a?a.call(e,r):t.set(e,r),r);function Ze(){return window.crypto}var et=b(()=>{"use strict"});function tt(e){return!!Sn.exec(e)}function V(e){let t=On.exec(e);return t?t[1]:null}function Z(e){if(!e)return null;let t=Mn.exec(e);return t?t[1]:null}function Ae(e){return e.replace(Un,(t,r)=>r)}function rt(e){return e.split($n).map((r,a)=>a%2===0?Ae(r):r).join("")}function nt(e){let t=_n.exec(e["@odata.id"]);return{id:t[2],collection:t[1],oDataContext:e["@odata.context"]}}function ot(e){let t=wn.exec(e);if(!t)return null;let r=parseInt(t[2],10),a=Fn(t[1]);return{page:r,sanitizedCookie:a}}function Fn(e){let t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return e.replace(Bn,r=>t[r])}function at(e){return e.replace(qn,"")}function it(e){return e.replace(Hn,t=>`\\u${("0000"+t.charCodeAt(0).toString(16)).slice(-4)}`)}function Ee(e){return e.replace(Qn,"")}function mt(e){return Ln.test(e??"")?"PUT":"PATCH"}function Rt(e){return e.replace(Wn,"\\$&")}function gt(e){let t=Vn.exec(e);return t?t[1]:null}var W,Sn,On,Mn,Un,_n,$n,wn,Bn,qn,Hn,Qn,st,xe,pt,ct,lt,ee,be,Ln,ut,ft,dt,yt,Wn,Vn,h=b(()=>{"use strict";W="[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}",Sn=new RegExp(W,"i"),On=new RegExp("^{?("+W+")}?$","i"),Mn=new RegExp("("+W+")\\)$","i"),Un=new RegExp(`{(${W})}`,"g"),_n=new RegExp(`\\/(\\w+)\\((${W})`,"i");$n=/(["'].*?["'])/;wn=/pagingcookie="(<cookie page="(\d+)".+<\/cookie>)/,Bn=/[<>"']/g;qn=/^\//;Hn=/[\u007F-\uFFFF]/g;Qn=/"/g;st=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/,xe=/HTTP\/?\s*[\d.]*\s+(\d{3})\s+([\w\s]*)$/m,pt=/Content-Type: text\/plain/i,ct=/OData-EntityId.+/i,lt=/\w+$/g,ee=/\r?\n/,be=/(\w+)(\([\d\w-]+\))$/,Ln=/EntityDefinitions|RelationshipDefinitions|GlobalOptionSetDefinitions/;ut=/^<fetch.+top=/,ft=/^<fetch.+page=/,dt=/^(<fetch)/,yt=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:Z|[-+]\d{2}:\d{2})$/,Wn=/[+\-&|!(){}[\]^"~*?:\\\/]/g;Vn=/^odata\.callback;\s*url=["']?(.+?)["']?$/});function Gn(e){return e==null?"":typeof e=="string"&&!e.startsWith("Microsoft.Dynamics.CRM")&&!tt(e)?`'${e}'`:typeof e=="object"?JSON.stringify(e):e.toString()}function Xn(e){let t=Object.keys(e),r=[],a=[];return t.forEach((n,i)=>{let s=e[n];if(s==null)return;s=Gn(s);let p=i+1;r.push(`${n}=@p${p}`),a.push(`@p${p}=${V(s)||s}`)}),{key:`(${r.join(",")})`,queryParams:a}}function ht(e,t){return e.hasOwnProperty(t)||e.hasOwnProperty(t.toLowerCase())}function G(e,t){return e[t]?e[t]:e[t.toLowerCase()]}function Ct(e){return e?Xn(e):{key:"()"}}function At(e="",t=1){e=decodeURIComponent(decodeURIComponent(e));let r=ot(e);return{cookie:r?.sanitizedCookie||"",page:r?.page||t,nextPage:r?.page?r.page+1:t+1}}function R(e){return typeof e>"u"||e==null}function O(){return Ze().randomUUID()}function zn(){if(typeof GetGlobalContext<"u")return GetGlobalContext();if(typeof Xrm<"u"){if(!R(Xrm.Utility)&&!R(Xrm.Utility.getGlobalContext))return Xrm.Utility.getGlobalContext();if(!R(Xrm.Page)&&!R(Xrm.Page.context))return Xrm.Page.context}throw new Error("Xrm Context is not available. In most cases, it can be resolved by adding a reference to a ClientGlobalContext.js.aspx. Please refer to MSDN documentation for more details.")}function Et(){let t=zn().getClientUrl();return t.match(/\/$/)&&(t=t.substring(0,t.length-1)),t}function te(){return!!window.shell}function Kn(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&Object.prototype.toString.call(e)!=="[object Date]"}function T(e,t){let r={};for(let a in e)e.hasOwnProperty(a)&&!t?.includes(a)&&(Kn(e[a])?r[a]=T(e[a]):Array.isArray(e[a])?r[a]=e[a].slice():r[a]=e[a]);return r}function l(e,t=[]){t.includes("signal")||t.push("signal");let r=T(e,t);return r.signal=e.signal,r}function xt(e,t,r,a){a=a||0;let n=a+r>t.length?t.length%r:r,i;i=new Uint8Array(n);for(let s=0;s<n;s++)i[s]=t[a+s];e.data=i,e.contentRange="bytes "+a+"-"+(a+n-1)+"/"+t.length}function bt(e){let t=new Uint8Array(e.length);for(var r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var Te,d=b(()=>{"use strict";et();h();Te=4194304});function D(e,t,r){throw new Error(r?`${e} requires a ${t} parameter to be of type ${r}.`:`${e} requires a ${t} parameter.`)}var o,u=b(()=>{"use strict";h();o=class e{static handleErrorResponse(t){throw new Error(`Error: ${t.status}: ${t.message}`)}static parameterCheck(t,r,a,n){(typeof t>"u"||t===null||t==="")&&D(r,a,n)}static stringParameterCheck(t,r,a){typeof t!="string"&&D(r,a,"String")}static maxLengthStringParameterCheck(t,r,a,n){if(t&&t.length>n)throw new Error(`${a} has a ${n} character limit.`)}static arrayParameterCheck(t,r,a){t.constructor!==Array&&D(r,a,"Array")}static stringOrArrayParameterCheck(t,r,a){t.constructor!==Array&&typeof t!="string"&&D(r,a,"String or Array")}static numberParameterCheck(t,r,a){if(typeof t!="number"){if(typeof t=="string"&&t&&!isNaN(parseInt(t)))return;D(r,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(t,r){let a=new Error;return Object.keys(t).forEach(n=>{a[n]=t[n]}),r&&Object.keys(r).forEach(n=>{a[n]=r[n]}),a}static boolParameterCheck(t,r,a){typeof t!="boolean"&&D(r,a,"Boolean")}static guidParameterCheck(t,r,a){let n=V(t);return n||D(r,a,"GUID String"),n}static keyParameterCheck(t,r,a){try{e.stringParameterCheck(t,r,a);let n=V(t);if(n)return n;let i=t.split(",");if(i.length)for(let s=0;s<i.length;s++)i[s]=i[s].trim().replace(/"/g,"'"),/^[\w\d\_]+\=(.+)$/i.exec(i[s])[0];return i.join(",")}catch{D(r,a,"String representing GUID or Alternate Key")}}static callbackParameterCheck(t,r,a){typeof t!="function"&&D(r,a,"Function")}static throwBatchIncompatible(t,r){if(r)throw r=!1,new Error(t+" cannot be used in a BATCH request.")}static throwBatchNotStarted(t){if(!t)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 M,X,re,k,Nt=b(()=>{"use strict";re=class re{};re.Prefer=(X=class{static get(t){return`${re.Prefer.IncludeAnnotations}="${t}"`}},X.ReturnRepresentation="return=representation",X.Annotations=(M=class{},M.AssociatedNavigationProperty="Microsoft.Dynamics.CRM.associatednavigationproperty",M.LookupLogicalName="Microsoft.Dynamics.CRM.lookuplogicalname",M.All="*",M.FormattedValue="OData.Community.Display.V1.FormattedValue",M.FetchXmlPagingCookie="Microsoft.Dynamics.CRM.fetchxmlpagingcookie",M),X.IncludeAnnotations="odata.include-annotations",X);k=re});function S(e,t){if(typeof t=="string"){let r=yt.exec(t);if(r)return new Date(Date.UTC(+r[1],+r[2]-1,+r[3],+r[4],+r[5],+r[6]))}return t}var Ne=b(()=>{"use strict";h()});function to(e){let t={position:0},r={},a,n,i;do{if(i=t.position,n=ro(e,t),!n)break;a=st.exec(n),a!==null?r[a[1].toLowerCase()]=a[2]:t.position=i}while(n&&a);return r}function ro(e,t){return no(e,t,ee)}function no(e,t,r){let a=t.position||0,n=e.slice(a),i=r.exec(n);if(!i)return null;let s=a+i.index;return t.position=s+i[0].length,e.substring(a,s)}function oo(e){let t=xe.exec(e);return{httpStatusString:t[0],httpStatus:parseInt(t[1]),httpStatusMessage:t[2].trim()}}function ao(e){xe.lastIndex=0;let t=lt.exec(e.trim());return t?.length?t[0]:void 0}function io(e,t,r){let a=ao(e);return ke(a)}function so(e,t,r){if(t?.[r]?.valueIfEmpty!==void 0)return t[r].valueIfEmpty;{let a=ct.exec(e);return Z(a?.[0])??void 0}}function po(e,t,r){let{httpStatusString:a,httpStatus:n,httpStatusMessage:i}=oo(e),s=e.substring(e.indexOf("{"),e.lastIndexOf("}")+1);if(!s)return pt.test(e)?io(e,t,r):so(e,t,r);let p=Ie(s,t,r);if(n<400)return p;let E=to(e.substring(e.indexOf(a)+a.length+1,e.indexOf("{")));return o.handleHttpError(p,{status:n,statusText:i,statusMessage:i,headers:E})}function Pe(e,t,r=0){let a=e.substring(0,e.search(ee)),n=e.split(a);n.shift(),n.pop();let i=[];for(let s of n){if(s.indexOf("--changesetresponse_")===-1){i.push(po(s,t,r++));continue}s=s.trim();let p=s.substring(s.search(ee)+1).trim();i=i.concat(Pe(p,t,r++))}return i}var De=b(()=>{"use strict";u();h();ne()});function Se(e,t){let r=null;if(e.indexOf("@")!==-1){let a=e.split("@");switch(a[1]){case"odata.context":r="oDataContext";break;case"odata.count":r="oDataCount",t=t!=null?parseInt(t):0;break;case"odata.nextLink":r="oDataNextLink";break;case"odata.deltaLink":r="oDataDeltaLink";break;case k.Prefer.Annotations.FormattedValue:r=a[0]+"_Formatted";break;case k.Prefer.Annotations.AssociatedNavigationProperty:r=a[0]+"_NavigationProperty";break;case k.Prefer.Annotations.LookupLogicalName:r=a[0]+"_LogicalName";break}}return[r,t]}function Oe(e,t){if(t){if(t.isRef&&e["@odata.id"]!=null)return nt(e);if(t.toCount)return Se("@odata.count",e["@odata.count"])[1]||0}for(let a in e){if(e[a]!=null)if(Array.isArray(e[a]))for(var r=0;r<e[a].length;r++)e[a][r]=Oe(e[a][r]);else typeof e[a]=="object"&&Oe(e[a]);let n=Se(a,e[a]);if(n[0]&&(e[n[0]]=n[1]),a.indexOf("_x002e_")!==-1){let i=a.split("_x002e_");if(!e.hasOwnProperty(i[0]))e[i[0]]={_dwaType:"alias"};else if(typeof e[i[0]]!="object"||typeof e[i[0]]=="object"&&!e[i[0]].hasOwnProperty("_dwaType"))throw new Error("The alias name of the linked entity must be unique!");e[i[0]][i[1]]=e[a],n=Se(i[1],e[a]),n[0]&&(e[i[0]][n[0]]=n[1])}}return t&&t.hasOwnProperty("pageNumber")&&e["@"+k.Prefer.Annotations.FetchXmlPagingCookie]!=null&&(e.PagingInfo=At(e["@"+k.Prefer.Annotations.FetchXmlPagingCookie],t.pageNumber)),e}function co(e){return window.atob(e)}function lo(e,t,r){let a=e;r?.hasOwnProperty("parse")&&(a=JSON.parse(a).value,a=co(a));let n={value:a};t["x-ms-file-name"]&&(n.fileName=t["x-ms-file-name"]),t["x-ms-file-size"]&&(n.fileSize=parseInt(t["x-ms-file-size"]));let i=G(t,"Location");return i&&(n.location=i),n}function mo(e){return e.indexOf("--batchresponse_")>-1}function uo(e){return ht(e,"Content-Disposition")}function fo(e){return G(e,"Content-Type")?.startsWith("application/json")==!0}function yo(e,t){let r=Pe(e,t);return t?.[0].convertedToBatch?r[0]:r}function Ro(e,t,r){return lo(e,t,r[0])}function Ie(e,t,r=0){return Oe(JSON.parse(e,S),t[r])}function ke(e){let t=Number(e);return isFinite(t)?t:e}function go(e,t){if(t?.[0]?.valueIfEmpty!==void 0)return t[0].valueIfEmpty;let r=G(e,"OData-EntityId");if(r)return Z(r)??void 0;let a=G(e,"Location");if(a){let n={location:a};return e["x-ms-chunk-size"]&&(n.chunkSize=parseInt(e["x-ms-chunk-size"])),e["x-ms-dyn-backgroundoperationid"]&&(n.backgroundOperationId=e["x-ms-dyn-backgroundoperationid"]),n}}function Me(e,t,r){return e.length?mo(e)?yo(e,r):uo(t)?Ro(e,t,r):fo(t)?Ie(e,r):ke(e):go(t,r)}var ne=b(()=>{"use strict";Nt();d();Ne();h();De()});function U(e){let t={};if(!e)return t;let r=e.split(`\r
`);for(let a=0,n=r.length;a<n;a++){let i=r[a],s=i.indexOf(": ");s>0&&(t[i.substring(0,s)]=i.substring(s+2))}return t}var Ue=b(()=>{"use strict"});var Pt={};Ye(Pt,{XhrWrapper:()=>z,executeRequest:()=>ho});function ho(e){return new Promise((t,r)=>{Co(e,t,r)})}function Co(e,t,r){let a=e.data,n=e.headers,i=e.responseParams,s=e.abortSignal;if(s?.aborted){r(o.handleHttpError({name:"AbortError",code:20,message:"The user aborted a request."}));return}let p=new XMLHttpRequest;p.open(e.method,e.uri,e.isAsync||!1);for(let y in n)p.setRequestHeader(y,n[y]);p.onreadystatechange=function(){if(p.readyState===4){if(s&&s.removeEventListener("abort",E),!p||p.status===0)return;if(p.status>=200&&p.status<300||p.status===304){let y=U(p.getAllResponseHeaders()),x={data:Me(p.responseText,y,i[e.requestId]),headers:y,status:p.status};p=null,t(x)}else{let y,A;try{A=U(p.getAllResponseHeaders());let j=Me(p.responseText,A,i[e.requestId]);if(Array.isArray(j)){r(j);return}y=j.error}catch{p.response.length>0?y={message:p.response}:y={message:"Unexpected Error"}}let x={status:p.status,statusText:p.statusText,headers:A};p=null,r(o.handleHttpError(y,x))}}},e.timeout&&(p.timeout=e.timeout),p.onerror=function(){let y=U(p.getAllResponseHeaders());r(o.handleHttpError({status:p.status,statusText:p.statusText,message:p.responseText||"Network Error",headers:y})),p=null},p.ontimeout=function(){let y=U(p.getAllResponseHeaders());r(o.handleHttpError({name:"TimeoutError",status:p.status,statusText:p.statusText,message:p.responseText||"Request Timed Out",headers:y})),p=null},p.onabort=function(){if(!p)return;let y=U(p.getAllResponseHeaders());r(o.handleHttpError({status:p.status,statusText:p.statusText,message:"Request aborted",headers:y})),p=null};let E=()=>{if(!p)return;let y=U(p.getAllResponseHeaders());r(o.handleHttpError({name:"AbortError",code:20,status:p.status,statusText:p.statusText,message:"The user aborted a request.",headers:y})),p.abort(),p=null};s&&s.addEventListener("abort",E),a?p.send(a):p.send(),z.afterSendEvent&&z.afterSendEvent()}var z,Dt=b(()=>{"use strict";u();ne();Ue();z=class{}});var Jo={};Ye(Jo,{DynamicsWebApi:()=>Xe});d();u();var c="DynamicsWebApi";var g=`${c}.setConfig`,Yn=["dataApi","searchApi","serviceApi"],Jn=(e,t)=>{if(te())return new URL("_api",window.location.origin).toString()+"/";{e||(e=Et());let r="api";return t.path&&(r+=`/${t.path}`),t.version&&(r+=`/v${t.version}`),new URL(r,e).toString()+"/"}},jn=(e,t)=>{t&&(t.escapeSpecialCharacters!=null&&(o.boolParameterCheck(t.escapeSpecialCharacters,g,"config.searchApi.options.escapeSpecialCharacters"),e.escapeSpecialCharacters=t.escapeSpecialCharacters),t.enableResponseCompatibility!=null&&(o.boolParameterCheck(t.enableResponseCompatibility,g,"config.searchApi.options.enableResponseCompatibility"),e.enableSearchApiResponseCompatibility=t.enableResponseCompatibility))},Zn=(e,t,r)=>{let a=e[t],n=r?.[t];n?.version&&(o.stringParameterCheck(n.version,g,`config.${t}.version`),a.version=n.version),n?.path&&(o.stringParameterCheck(n.path,g,`config.${t}.path`),a.path=n.path),t==="searchApi"&&jn(a,n?.options),a.url=Jn(e.serverUrl,a)};function ve(e,t){t?.serverUrl&&(o.stringParameterCheck(t.serverUrl,g,"config.serverUrl"),e.serverUrl=t.serverUrl),Yn.forEach(r=>{Zn(e,r,t)}),t?.impersonate&&(e.impersonate=o.guidParameterCheck(t.impersonate,g,"config.impersonate")),t?.impersonateAAD&&(e.impersonateAAD=o.guidParameterCheck(t.impersonateAAD,g,"config.impersonateAAD")),t?.onTokenRefresh&&(o.callbackParameterCheck(t.onTokenRefresh,g,"config.onTokenRefresh"),e.onTokenRefresh=t.onTokenRefresh),t?.includeAnnotations&&(o.stringParameterCheck(t.includeAnnotations,g,"config.includeAnnotations"),e.includeAnnotations=t.includeAnnotations),t?.timeout&&(o.numberParameterCheck(t.timeout,g,"config.timeout"),e.timeout=t.timeout),t?.maxPageSize&&(o.numberParameterCheck(t.maxPageSize,g,"config.maxPageSize"),e.maxPageSize=t.maxPageSize),t?.returnRepresentation!=null&&(o.boolParameterCheck(t.returnRepresentation,g,"config.returnRepresentation"),e.returnRepresentation=t.returnRepresentation),t?.useEntityNames!=null&&(o.boolParameterCheck(t.useEntityNames,g,"config.useEntityNames"),e.useEntityNames=t.useEntityNames),t?.headers&&(e.headers=t.headers)}function Tt(){return{serverUrl:null,impersonate:null,impersonateAAD:null,onTokenRefresh:null,includeAnnotations:null,maxPageSize:null,returnRepresentation:null,proxy:null,dataApi:{path:"data",version:"9.2",url:""},searchApi:{path:"search",version:"1.0",url:""},serviceApi:{url:""}}}d();d();var I=null,vt=e=>{I=e},F=e=>{if(R(I))return null;let t=I[e];if(!t){for(let r in I)if(I[r]===e)return e}return t};async function It(e){return(Dt(),Je(Pt)).executeRequest(e)}u();u();h();d();var _e=(e,t,r="",a="&")=>{let n=[];if(e){if(e.navigationProperty){if(o.stringParameterCheck(e.navigationProperty,`DynamicsWebApi.${e.functionName}`,"request.navigationProperty"),r+="/"+e.navigationProperty,e.navigationPropertyKey){let i=o.keyParameterCheck(e.navigationPropertyKey,`DynamicsWebApi.${e.functionName}`,"request.navigationPropertyKey");r+="("+i+")"}e.navigationProperty==="Attributes"&&e.metadataAttributeType&&(o.stringParameterCheck(e.metadataAttributeType,`DynamicsWebApi.${e.functionName}`,"request.metadataAttributeType"),r+="/"+e.metadataAttributeType)}if(e.select?.length&&(o.arrayParameterCheck(e.select,`DynamicsWebApi.${e.functionName}`,"request.select"),e.functionName=="retrieve"&&e.select.length==1&&e.select[0].endsWith("/$ref")?r+="/"+e.select[0]:(e.select[0].startsWith("/")&&e.functionName=="retrieve"&&(e.navigationProperty==null?r+=e.select.shift():e.select.shift()),e.select.length&&n.push("$select="+e.select.join(",")))),e.filter){o.stringParameterCheck(e.filter,`DynamicsWebApi.${e.functionName}`,"request.filter");let i=rt(e.filter);n.push("$filter="+encodeURIComponent(i))}if(e.fieldName&&(o.stringParameterCheck(e.fieldName,`DynamicsWebApi.${e.functionName}`,"request.fieldName"),e.property||(e.property=e.fieldName),delete e.fieldName),e.property&&(o.stringParameterCheck(e.property,`DynamicsWebApi.${e.functionName}`,"request.property"),r+="/"+e.property),e.savedQuery&&n.push("savedQuery="+o.guidParameterCheck(e.savedQuery,`DynamicsWebApi.${e.functionName}`,"request.savedQuery")),e.userQuery&&n.push("userQuery="+o.guidParameterCheck(e.userQuery,`DynamicsWebApi.${e.functionName}`,"request.userQuery")),e.apply&&(o.stringParameterCheck(e.apply,`DynamicsWebApi.${e.functionName}`,"request.apply"),n.push("$apply="+e.apply)),e.count&&(o.boolParameterCheck(e.count,`DynamicsWebApi.${e.functionName}`,"request.count"),n.push("$count="+e.count)),e.top&&e.top>0&&(o.numberParameterCheck(e.top,`DynamicsWebApi.${e.functionName}`,"request.top"),n.push("$top="+e.top)),e.orderBy!=null&&e.orderBy.length&&(o.arrayParameterCheck(e.orderBy,`DynamicsWebApi.${e.functionName}`,"request.orderBy"),n.push("$orderby="+e.orderBy.join(","))),e.partitionId&&(o.stringParameterCheck(e.partitionId,`DynamicsWebApi.${e.functionName}`,"request.partitionId"),n.push("partitionid='"+e.partitionId+"'")),e.downloadSize&&(o.stringParameterCheck(e.downloadSize,`DynamicsWebApi.${e.functionName}`,"request.downloadSize"),n.push("size="+e.downloadSize)),e.tag&&(o.stringParameterCheck(e.tag,`DynamicsWebApi.${e.functionName}`,"request.tag"),n.push("tag="+encodeURIComponent(e.tag))),e.queryParams?.length&&(o.arrayParameterCheck(e.queryParams,`DynamicsWebApi.${e.functionName}`,"request.queryParams"),n.push(e.queryParams.join("&"))),e.fileName&&(o.stringParameterCheck(e.fileName,`DynamicsWebApi.${e.functionName}`,"request.fileName"),n.push("x-ms-file-name="+e.fileName)),e.data&&o.parameterCheck(e.data,`DynamicsWebApi.${e.functionName}`,"request.data"),e.isBatch&&o.boolParameterCheck(e.isBatch,`DynamicsWebApi.${e.functionName}`,"request.isBatch"),e.fetchXml&&(o.stringParameterCheck(e.fetchXml,`DynamicsWebApi.${e.functionName}`,"request.fetchXml"),n.push("fetchXml="+encodeURIComponent(e.fetchXml))),R(e.inChangeSet)||o.boolParameterCheck(e.inChangeSet,`DynamicsWebApi.${e.functionName}`,"request.inChangeSet"),e.isBatch&&R(e.inChangeSet)&&(e.inChangeSet=!0),e.timeout&&o.numberParameterCheck(e.timeout,`DynamicsWebApi.${e.functionName}`,"request.timeout"),e.expand?.length)if(o.stringOrArrayParameterCheck(e.expand,`DynamicsWebApi.${e.functionName}`,"request.expand"),typeof e.expand=="string")n.push("$expand="+e.expand);else{let i=[];for(let{property:s,...p}of e.expand){if(!s)continue;let E={functionName:`${e.functionName} $expand`,...p},y=_e(E,t,"",";");y&&(y=`(${y})`),i.push(s+y)}i.length&&n.push("$expand="+i.join(","))}}return n.length?(a==="&"&&(r+="?"),r+n.join(a)):r};u();u();h();var kt=(e,t)=>{let r=`DynamicsWebApi.${e.functionName}`,a={respondAsync:e.respondAsync,backgroundOperationCallbackUrl:e.backgroundOperationCallbackUrl??t?.backgroundOperationCallbackUrl,returnRepresentation:e.returnRepresentation??t?.returnRepresentation,includeAnnotations:e.includeAnnotations??t?.includeAnnotations,maxPageSize:e.maxPageSize??t?.maxPageSize,trackChanges:e.trackChanges,continueOnError:e.continueOnError},n=new Set;if(e.prefer?.length){o.stringOrArrayParameterCheck(e.prefer,r,"request.prefer");let i=typeof e.prefer=="string"?e.prefer.split(","):e.prefer;for(let s of i){let p=s.trim();p.includes("respond-async")?a.respondAsync=!0:p.startsWith("odata.callback")?a.backgroundOperationCallbackUrl=gt(p):p==="return=representation"?a.returnRepresentation=!0:p.includes("odata.include-annotations=")?a.includeAnnotations=Ee(p.replace("odata.include-annotations=","")):p.startsWith("odata.maxpagesize=")?a.maxPageSize=Number(Ee(p.replace("odata.maxpagesize=","")))||0:p.includes("odata.track-changes")?a.trackChanges=!0:p.includes("odata.continue-on-error")?a.continueOnError=!0:n.add(p)}}for(let i in a){let s=Ao[i];s&&a[i]&&(s.validator?.(a[i],r,`request.${i}`),s.condition(a[i],a)&&n.add(s.formatter(a[i],a)))}return Array.from(n).join(",")},Ao={respondAsync:{validator:o.boolParameterCheck,condition:e=>!!e,formatter:()=>"respond-async"},backgroundOperationCallbackUrl:{validator:o.stringParameterCheck,condition:(e,t)=>e&&t.respondAsync,formatter:e=>`odata.callback;url="${e}"`},returnRepresentation:{validator:o.boolParameterCheck,condition:e=>!!e,formatter:()=>"return=representation"},includeAnnotations:{validator:o.stringParameterCheck,condition:e=>!!e,formatter:e=>`odata.include-annotations="${e}"`},maxPageSize:{validator:(e,t)=>e>0?o.numberParameterCheck(e,t,"request.maxPageSize"):void 0,condition:e=>e>0,formatter:e=>`odata.maxpagesize=${e}`},trackChanges:{validator:o.boolParameterCheck,condition:e=>!!e,formatter:()=>"odata.track-changes"},continueOnError:{validator:o.boolParameterCheck,condition:e=>!!e,formatter:()=>"odata.continue-on-error"}};var St=(e,t)=>{let r={...t.headers,...e.userHeaders},a=kt(e,t);if(a.length&&(r.Prefer=a),e.collection==="$metadata"&&(r.Accept="application/xml"),e.transferMode&&(r["x-ms-transfer-mode"]=e.transferMode),e.ifmatch!=null&&e.ifnonematch!=null)throw new Error(`DynamicsWebApi.${e.functionName}. Either one of request.ifmatch or request.ifnonematch parameters should be used in a call, not both.`);return e.ifmatch&&(o.stringParameterCheck(e.ifmatch,`DynamicsWebApi.${e.functionName}`,"request.ifmatch"),r["If-Match"]=e.ifmatch),e.ifnonematch&&(o.stringParameterCheck(e.ifnonematch,`DynamicsWebApi.${e.functionName}`,"request.ifnonematch"),r["If-None-Match"]=e.ifnonematch),e.impersonate&&(o.stringParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate"),r.MSCRMCallerID=o.guidParameterCheck(e.impersonate,`DynamicsWebApi.${e.functionName}`,"request.impersonate")),e.impersonateAAD&&(o.stringParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD"),r.CallerObjectId=o.guidParameterCheck(e.impersonateAAD,`DynamicsWebApi.${e.functionName}`,"request.impersonateAAD")),e.token&&(o.stringParameterCheck(e.token,`DynamicsWebApi.${e.functionName}`,"request.token"),r.Authorization="Bearer "+e.token),e.duplicateDetection&&(o.boolParameterCheck(e.duplicateDetection,`DynamicsWebApi.${e.functionName}`,"request.duplicateDetection"),r["MSCRM.SuppressDuplicateDetection"]="false"),e.bypassCustomPluginExecution&&(o.boolParameterCheck(e.bypassCustomPluginExecution,`DynamicsWebApi.${e.functionName}`,"request.bypassCustomPluginExecution"),r["MSCRM.BypassCustomPluginExecution"]="true"),e.noCache&&(o.boolParameterCheck(e.noCache,`DynamicsWebApi.${e.functionName}`,"request.noCache"),r["Cache-Control"]="no-cache"),e.mergeLabels&&(o.boolParameterCheck(e.mergeLabels,`DynamicsWebApi.${e.functionName}`,"request.mergeLabels"),r["MSCRM.MergeLabels"]="true"),e.contentId&&(o.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")||(r["Content-ID"]=e.contentId)),e.contentRange&&(o.stringParameterCheck(e.contentRange,`DynamicsWebApi.${e.functionName}`,"request.contentRange"),r["Content-Range"]=e.contentRange),e.range&&(o.stringParameterCheck(e.range,`DynamicsWebApi.${e.functionName}`,"request.range"),r.Range=e.range),r};u();var oe=(e,t)=>(e.path="",e.functionName=e.functionName||"",e.url?(o.stringParameterCheck(e.url,`DynamicsWebApi.${e.functionName}`,"request.url"),e.path=e.url.replace(t.dataApi.url,"")):(!e._isUnboundRequest&&!e.contentId&&!e.collection&&o.parameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.contentId&&(o.stringParameterCheck(e.contentId,`DynamicsWebApi.${e.functionName}`,"request.contentId"),e.contentId.startsWith("$")&&(e.path=e.contentId)),e.collection!=null&&(o.stringParameterCheck(e.collection,`DynamicsWebApi.${e.functionName}`,"request.collection"),e.path+=e.path?`/${e.collection}`:e.collection,e.key&&(e.key=o.keyParameterCheck(e.key,`DynamicsWebApi.${e.functionName}`,"request.key"),e.path+=`(${e.key})`)),e.addPath&&(e.path&&(e.path+="/"),e.path+=e.addPath),e.path=_e(e,t,e.path)),e.hasOwnProperty("async")&&e.async!=null?o.boolParameterCheck(e.async,`DynamicsWebApi.${e.functionName}`,"request.async"):e.async=!0,e.headers=St(e,t),e);h();d();Ne();De();ne();Ue();var ae=(e,t)=>{if(!e)return null;if(e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array)return e;let r=i=>{let s=be.exec(i);if(s&&s.length>2){let p=F(s[1]);if(!R(p))return i.replace(be,`${p}$2`)}return i},a=(i,s)=>(s.startsWith(t.dataApi.url)||(i.endsWith("@odata.bind")?s.startsWith("/")||(s=`/${s}`):s=`${t.dataApi.url}${at(s)}`),s),n=JSON.stringify(e,(i,s)=>{if(i.endsWith("@odata.bind")||i.endsWith("@odata.id"))typeof s=="string"&&!s.startsWith("$")&&(s=Ae(s),t.useEntityNames&&(s=r(s)),s=a(i,s));else if(i.startsWith("oData")||i.endsWith("_Formatted")||i.endsWith("_NavigationProperty")||i.endsWith("_LogicalName"))return;return s});return it(n)};var ie=(e={})=>(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);d();var $e=(e,t,r)=>{let a=`dwa_batch_${O()}`,n=[],i=null,s=1e5,p=(y,A)=>{for(let x in y)x==="Authorization"||x==="Content-ID"||A.push(`${x}: ${y[x]}`)};e.forEach(y=>{y.functionName="executeBatch",r?.inChangeSet===!1&&(y.inChangeSet=!1);let A=y.method==="GET"?!1:!!y.inChangeSet;if(!A&&i&&(n.push(`\r
--${i}--`),i=null,s=1e5),i||(n.push(`\r
--${a}`),A&&(i=`changeset_${O()}`,n.push("Content-Type: multipart/mixed;boundary="+i))),A&&n.push(`\r
--${i}`),n.push("Content-Type: application/http"),n.push("Content-Transfer-Encoding: binary"),A){let x=y.headers.hasOwnProperty("Content-ID")?y.headers["Content-ID"]:++s;n.push(`Content-ID: ${x}`)}y.path?.startsWith("$")?n.push(`\r
${y.method} ${y.path} HTTP/1.1`):n.push(`\r
${y.method} ${t.dataApi.url}${y.path} HTTP/1.1`),y.method==="GET"?n.push("Accept: application/json"):n.push("Content-Type: application/json"),y.headers&&p(y.headers,n),y.data&&n.push(`\r
${ae(y.data,t)}`)}),i&&n.push(`\r
--${i}--`),n.push(`\r
--${a}--\r
`);let E=ie(r?.userHeaders);return E["Content-Type"]=`multipart/mixed;boundary=${a}`,{headers:E,body:n.join(`\r
`)}};var Ot=(e,t)=>{K[e]?K[e].push(t):K[e]=[t]},Eo=(e,t)=>{_[e]?_[e].push(t):_[e]=[t]},we=e=>{delete K[e],_.hasOwnProperty(e)&&delete _[e]},Mt=async(e,t)=>{try{let r=await No(e,t);return we(e.requestId),r}catch(r){throw we(e.requestId),r}finally{we(e.requestId)}},_={},K={},xo=["$metadata","EntityDefinitions","RelationshipDefinitions","GlobalOptionSetDefinitions","ManagedPropertyDefinitions","query","suggest","autocomplete"],bo=e=>xo.indexOf(e)>-1,To=async(e,t)=>{if(!R(I))return F(e)||e;let r=oe({method:"GET",collection:"EntityDefinitions",select:["EntitySetName","LogicalName"],noCache:!0,functionName:"retrieveMultiple"},t),a=await Mt(r,t);vt({});for(let n=0;n<a.data.value.length;n++)I[a.data.value[n].LogicalName]=a.data.value[n].EntitySetName;return F(e)||e},vo=async(e,t)=>{if(!e||bo(e)||(e=e.toLowerCase(),!t.useEntityNames))return e;try{return await To(e,t)}catch(r){throw new Error("Unable to fetch Collection Names. Error: "+r.message)}},No=async(e,t)=>{e.headers=e.headers||{},e.responseParameters=e.responseParameters||{},e.requestId=e.requestId||O(),Ot(e.requestId,e.responseParameters);let r=null,a=e.responseParameters?.convertedToBatch;if(e.path==="$batch"&&!a){let s=_[e.requestId];if(!s)throw o.batchIsEmpty();let p=$e(s,t,e);r=p.body,e.headers={...p.headers,...e.headers},delete _[e.requestId]}else r=a?e.data:ae(e.data,t),!a&&e.includeDefaultDataverseHeaders!==!1&&(e.headers=ie(e.headers));t.impersonate&&!e.headers.MSCRMCallerID&&(e.headers.MSCRMCallerID=t.impersonate),t.impersonateAAD&&!e.headers.CallerObjectId&&(e.headers.CallerObjectId=t.impersonateAAD);let n=null;if(t.onTokenRefresh&&(!e.headers||e.headers&&!e.headers.Authorization)&&(n=await t.onTokenRefresh(),!n))throw new Error("Token is empty. Request is aborted.");n&&(e.headers.Authorization="Bearer "+(n.hasOwnProperty("accessToken")?n.accessToken:n)),te()&&(e.headers.__RequestVerificationToken=await window.shell.getTokenDeferred());let i=e.apiConfig?e.apiConfig.url:t.dataApi.url;return await It({method:e.method,uri:i.toString()+e.path,data:r,proxy:t.proxy,isAsync:e.async,headers:e.headers,requestId:e.requestId,abortSignal:e.signal,responseParams:K,timeout:e.timeout||t.timeout})},Ut=async(e,t)=>{if(e.responseParameters=e.responseParameters||{},e.userHeaders=e.headers,delete e.headers,!e.isBatch){let r=await vo(e.collection,t);if(e.collection=r,oe(e,t),e.responseParameters.convertedToBatch=!1,e.path.length>2e3){let a=$e([e],t);e.headers.Authorization&&(a.headers.Authorization=e.headers.Authorization),e.method="POST",e.path="$batch",e.data=a.body,e.headers={...a.headers,...e.userHeaders},e.responseParameters.convertedToBatch=!0}return Mt(e,t)}oe(e,t),Ot(e.requestId,e.responseParameters),Eo(e.requestId,e)};var _t=e=>F(e);var $,q,w,se=class{constructor(t){B(this,$,Tt());B(this,q,!1);B(this,w,null);this.setConfig=t=>ve(m(this,$),t);this.makeRequest=t=>(t.isBatch=m(this,q),m(this,w)&&(t.requestId=m(this,w)),Ut(t,m(this,$)));ve(m(this,$),t)}get batchRequestId(){return m(this,w)}set batchRequestId(t){L(this,w,t)}get config(){return m(this,$)}get isBatch(){return m(this,q)}set isBatch(t){L(this,q,t)}};$=new WeakMap,q=new WeakMap,w=new WeakMap;u();d();var $t="associate",Y=`${c}.${$t}`,wt=async(e,t)=>{o.parameterCheck(e,Y,"request");let r=l(e);r.method="POST",r.functionName=$t,o.stringParameterCheck(e.relatedCollection,Y,"request.relatedcollection"),o.stringParameterCheck(e.relationshipName,Y,"request.relationshipName");let a=o.keyParameterCheck(e.primaryKey,Y,"request.primaryKey"),n=o.keyParameterCheck(e.relatedKey,Y,"request.relatedKey");r.navigationProperty=e.relationshipName+"/$ref",r.key=a,r.data={"@odata.id":`${e.relatedCollection}(${n})`},await t.makeRequest(r)};u();d();var Bt="associateSingleValued",J=`${c}.${Bt}`,Ft=async(e,t)=>{o.parameterCheck(e,J,"request");let r=l(e);r.method="PUT",r.functionName=Bt;let a=o.keyParameterCheck(e.primaryKey,J,"request.primaryKey"),n=o.keyParameterCheck(e.relatedKey,J,"request.relatedKey");o.stringParameterCheck(e.navigationProperty,J,"request.navigationProperty"),o.stringParameterCheck(e.relatedCollection,J,"request.relatedcollection"),r.navigationProperty+="/$ref",r.key=a,r.data={"@odata.id":`${e.relatedCollection}(${n})`},await t.makeRequest(r)};u();d();var Ht="callAction",qt=`${c}.${Ht}`,Qt=async(e,t)=>{o.parameterCheck(e,qt,"request"),o.stringParameterCheck(e.actionName,qt,"request.actionName");let r=l(e,["action"]);return r.method="POST",r.functionName=Ht,r.addPath=e.actionName,r._isUnboundRequest=!r.collection,r.data=e.action,(await t.makeRequest(r))?.data};u();d();var Wt="callFunction",Lt=`${c}.${Wt}`,Vt=async(e,t)=>{o.parameterCheck(e,Lt,"request");let r=y=>y.name||y.functionName,a=typeof e!="string",n=a?r(e):e,i=a?"request.name":"name",s=a?T(e,["name"]):{functionName:n};o.stringParameterCheck(n,Lt,i);let p=Ct(s.parameters);return s.method="GET",s.addPath=n+p.key,s.queryParams=p.queryParams,s._isUnboundRequest=!s.collection,s.functionName=Wt,(await t.makeRequest(s))?.data};u();d();var Gt="create",Po=`${c}.${Gt}`,v=async(e,t)=>{o.parameterCheck(e,Po,"request");let r;return e.functionName?r=e:(r=l(e),r.functionName=Gt),r.method="POST",(await t.makeRequest(r))?.data};u();d();var Xt="count",Do=`${c}.${Xt}`,zt=async(e,t)=>{o.parameterCheck(e,Do,"request");let r=l(e);return r.method="GET",r.functionName=Xt,r.filter?.length?r.count=!0:r.navigationProperty="$count",r.responseParameters={toCount:r.count},(await t.makeRequest(r))?.data};u();u();u();d();var Yt="retrieveMultiple",Kt=`${c}.${Yt}`,C=async(e,t,r)=>{o.parameterCheck(e,Kt,"request");let a;return e.functionName?a=e:(a=l(e),a.functionName=Yt),a.method="GET",r&&(o.stringParameterCheck(r,Kt,"nextPageLink"),a.url=r),(await t.makeRequest(a))?.data};var Io="retrieveAll",ko=`${c}.${Io}`,pe=async(e,t,r,a=[])=>{let n=await C(e,t,r);a=a.concat(n.value);let i=n.oDataNextLink;if(i)return pe(e,t,i,a);let s={value:a};return n.oDataDeltaLink&&(s["@odata.deltaLink"]=n.oDataDeltaLink,s.oDataDeltaLink=n.oDataDeltaLink),s},Be=(e,t)=>(o.throwBatchIncompatible(ko,t.isBatch),pe(e,t));var So="countAll",Jt=`${c}.${So}`,jt=async(e,t)=>(o.throwBatchIncompatible(Jt,t.isBatch),o.parameterCheck(e,Jt,"request"),(await pe(e,t)).value.length);u();d();var Zt="disassociate",ce=`${c}.${Zt}`,er=async(e,t)=>{o.parameterCheck(e,ce,"request");let r=l(e);r.method="DELETE",r.functionName=Zt,o.stringParameterCheck(e.relationshipName,ce,"request.relationshipName");let a=o.keyParameterCheck(e.primaryKey,ce,"request.primaryKey"),n=o.keyParameterCheck(e.relatedKey,ce,"request.relatedId");r.key=a,r.navigationProperty=`${e.relationshipName}(${n})/$ref`,await t.makeRequest(r)};u();d();var tr="disassociateSingleValued",Fe=`${c}.${tr}`,rr=async(e,t)=>{o.parameterCheck(e,Fe,"request");let r=l(e);r.method="DELETE",r.functionName=tr,o.stringParameterCheck(e.navigationProperty,Fe,"request.navigationProperty");let a=o.keyParameterCheck(e.primaryKey,Fe,"request.primaryKey");r.navigationProperty+="/$ref",r.key=a,await t.makeRequest(r)};u();d();var nr="retrieve",Oo=`${c}.${nr}`,N=async(e,t)=>{o.parameterCheck(e,Oo,"request");let r;return e.functionName?r=e:(r=l(e),r.functionName=nr),r.method="GET",r.responseParameters={isRef:r.select?.length===1&&r.select[0].endsWith("/$ref")},(await t.makeRequest(r))?.data};u();h();d();var or="fetch",le=`${c}.${or}`,me=async(e,t)=>{o.parameterCheck(e,le,"request");let r=l(e);if(r.method="GET",r.functionName=or,o.stringParameterCheck(r.fetchXml,le,"request.fetchXml"),r.fetchXml&&!ut.test(r.fetchXml)){let n="";ft.test(r.fetchXml)||(r.pageNumber=r.pageNumber||1,o.numberParameterCheck(r.pageNumber,le,"request.pageNumber"),n=`$1 page="${r.pageNumber}"`),r.pagingCookie!=null&&(o.stringParameterCheck(r.pagingCookie,le,"request.pagingCookie"),n+=` paging-cookie="${r.pagingCookie}"`),n&&(r.fetchXml=r.fetchXml.replace(dt,n))}return r.responseParameters={pageNumber:r.pageNumber},(await t.makeRequest(r))?.data};u();var Mo="fetchAll",ar=`${c}.${Mo}`,ir=async(e,t,r=[])=>{let a=await me(e,t);return r=r.concat(a.value),a.PagingInfo?(e.pageNumber=a.PagingInfo.nextPage,e.pagingCookie=a.PagingInfo.cookie,ir(e,t,r)):{value:r}},sr=async(e,t)=>(o.parameterCheck(e,ar,"request"),o.throwBatchIncompatible(ar,t.isBatch),ir(e,t));u();h();d();var pr="update",Uo=`${c}.${pr}`,P=async(e,t)=>{o.parameterCheck(e,Uo,"request");let r;e.functionName?r=e:(r=l(e),r.functionName=pr),r.method??(r.method=mt(r.collection)),r.responseParameters={valueIfEmpty:!0},r.ifmatch??(r.ifmatch="*");let a=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};u();d();var lr="updateSingleProperty",cr=`${c}.${lr}`,mr=async(e,t)=>{o.parameterCheck(e,cr,"request"),o.parameterCheck(e.fieldValuePair,cr,"request.fieldValuePair");var r=Object.keys(e.fieldValuePair)[0],a=e.fieldValuePair[r];let n=l(e);return n.navigationProperty=r,n.data={value:a},n.functionName=lr,n.method="PUT",delete n.fieldValuePair,(await t.makeRequest(n))?.data};u();d();var ur="upsert",_o=`${c}.${ur}`,fr=async(e,t)=>{o.parameterCheck(e,_o,"request");let r=l(e);r.method="PATCH",r.functionName=ur;let a=r.ifnonematch,n=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(i){if(a&&i.status===412)return null;if(n&&i.status===404)return null;throw i}};u();d();var dr="deleteRecord",$o=`${c}.${dr}`,H=async(e,t)=>{o.parameterCheck(e,$o,"request");let r;e.functionName?r=e:(r=l(e),r.functionName=dr),r.method="DELETE",r.responseParameters={valueIfEmpty:!0};let a=r.ifmatch;try{return(await t.makeRequest(r))?.data}catch(n){if(a&&n.status===412)return!1;throw n}};u();d();var Rr="uploadFile",yr=`${c}.${Rr}`,gr=async(e,t,r,a,n=0)=>{if(xt(e,r,a,n),await t.makeRequest(e),n+=a,n<=r.length)return gr(e,t,r,a,n)},hr=async(e,t)=>{o.throwBatchIncompatible(yr,t.isBatch),o.parameterCheck(e,yr,"request");let r=l(e,["data"]);r.method="PATCH",r.functionName=Rr,r.transferMode="chunked";let a=await t.makeRequest(r);return r.url=a?.data.location,delete r.transferMode,delete r.fieldName,delete r.property,delete r.fileName,gr(r,t,e.data,a?.data.chunkSize)};u();d();var Ar="downloadFile",Cr=`${c}.${Ar}`,Er=async(e,t,r=0,a="")=>{e.range="bytes="+r+"-"+(r+Te-1),e.downloadSize="full";let n=await t.makeRequest(e);return e.url=n?.data.location,a+=n?.data.value,r+=Te,r<=n?.data.fileSize?Er(e,t,r,a):{fileName:n?.data.fileName,fileSize:n?.data.fileSize,data:bt(a)}},xr=(e,t)=>{o.throwBatchIncompatible(Cr,t.isBatch),o.parameterCheck(e,Cr,"request");let r=l(e);return r.method="GET",r.functionName=Ar,r.responseParameters={parse:!0},Er(r,t)};d();u();var wo="executeBatch",Bo=`${c}.${wo}`;async function br(e,t){o.throwBatchNotStarted(t.isBatch);let r=e?l(e):{};return r.collection="$batch",r.method="POST",r.functionName=Bo,r.requestId=t.batchRequestId,t.batchRequestId=null,t.isBatch=!1,(await t.makeRequest(r))?.data}function Tr(e){e.isBatch=!0,e.batchRequestId=O()}u();d();var Nr="createEntity",vr=`${c}.${Nr}`,Pr=async(e,t)=>{o.parameterCheck(e,vr,"request"),o.parameterCheck(e.data,vr,"request.data");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Nr,v(r,t)};u();d();var Ir="updateEntity",Dr=`${c}.${Ir}`,kr=async(e,t)=>{o.parameterCheck(e,Dr,"request"),o.parameterCheck(e.data,Dr,"request.data");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Ir,r.key=r.data.MetadataId,r.method="PUT",await P(r,t)};u();d();var Fo="retrieveEntity",Sr=`${c}.${Fo}`,Or=async(e,t)=>{o.parameterCheck(e,Sr,"request"),o.keyParameterCheck(e.key,Sr,"request.key");let r=l(e);return r.collection="EntityDefinitions",r.functionName="retrieveEntity",await N(r,t)};d();var qo="retrieveEntities",Mr=(e,t)=>{let r=t?l(t):{};return r.collection="EntityDefinitions",r.functionName=qo,C(r,e)};d();u();var Ur="createAttribute",qe=`${c}.${Ur}`,_r=(e,t)=>{o.parameterCheck(e,qe,"request"),o.parameterCheck(e.data,qe,"request.data"),o.keyParameterCheck(e.entityKey,qe,"request.entityKey");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Ur,r.navigationProperty="Attributes",r.key=e.entityKey,v(r,t)};d();u();var $r="updateAttribute",ue=`${c}.${$r}`,wr=(e,t)=>{o.parameterCheck(e,ue,"request"),o.parameterCheck(e.data,ue,"request.data"),o.keyParameterCheck(e.entityKey,ue,"request.entityKey"),o.guidParameterCheck(e.data.MetadataId,ue,"request.data.MetadataId");let r=l(e);return r.collection="EntityDefinitions",r.functionName=$r,r.navigationProperty="Attributes",r.navigationPropertyKey=e.data.MetadataId,r.metadataAttributeType=e.castType,r.key=e.entityKey,r.method="PUT",P(r,t)};d();u();var Br="retrieveAttributes",He=`${c}.${Br}`,Fr=(e,t)=>{o.parameterCheck(e,He,"request"),o.keyParameterCheck(e.entityKey,He,"request.entityKey"),e.castType&&o.stringParameterCheck(e.castType,He,"request.castType");let r=l(e);return r.collection="EntityDefinitions",r.functionName=Br,r.navigationProperty="Attributes",r.key=e.entityKey,r.metadataAttributeType=e.castType,C(r,t)};d();u();var qr="retrieveAttributes",fe=`${c}.${qr}`,Hr=(e,t)=>{o.parameterCheck(e,fe,"request"),o.keyParameterCheck(e.entityKey,fe,"request.entityKey"),o.keyParameterCheck(e.attributeKey,fe,"request.attributeKey"),e.castType&&o.stringParameterCheck(e.castType,fe,"request.castType");let r=l(e);return r.collection="EntityDefinitions",r.navigationProperty="Attributes",r.navigationPropertyKey=e.attributeKey,r.metadataAttributeType=e.castType,r.key=e.entityKey,r.functionName=qr,N(r,t)};d();u();var Lr="createRelationship",Qr=`${c}.${Lr}`,Wr=(e,t)=>{o.parameterCheck(e,Qr,"request"),o.parameterCheck(e.data,Qr,"request.data");let r=l(e);return r.collection="RelationshipDefinitions",r.functionName=Lr,v(r,t)};d();u();var Vr="updateRelationship",de=`${c}.${Vr}`;function Gr(e,t){o.parameterCheck(e,de,"request"),o.parameterCheck(e.data,de,"request.data"),o.guidParameterCheck(e.data.MetadataId,de,"request.data.MetadataId"),e.castType&&o.stringParameterCheck(e.castType,de,"request.castType");let r=l(e);return r.collection="RelationshipDefinitions",r.key=e.data.MetadataId,r.navigationProperty=e.castType,r.functionName=Vr,r.method="PUT",P(r,t)}d();u();var zr="deleteRelationship",Xr=`${c}.${zr}`;async function Kr(e,t){o.parameterCheck(e,Xr,"request"),o.keyParameterCheck(e.key,Xr,"request.key");let r=l(e);return r.collection="RelationshipDefinitions",r.functionName=zr,H(r,t)}d();u();var Yr="retrieveRelationships",Ho=`DynamicsWebApi.${Yr}`;async function Jr(e,t){let r=e?l(e):{};return r.collection="RelationshipDefinitions",r.functionName=Yr,e&&e.castType&&(o.stringParameterCheck(e.castType,Ho,"request.castType"),r.navigationProperty=e.castType),C(r,t)}d();u();var jr="retrieveRelationship",Qe=`DynamicsWebApi.${jr}`;async function Zr(e,t){o.parameterCheck(e,Qe,"request"),o.keyParameterCheck(e.key,Qe,"request.key"),e.castType&&o.stringParameterCheck(e.castType,Qe,"request.castType");let r=l(e);return r.collection="RelationshipDefinitions",r.navigationProperty=e.castType,r.functionName=jr,N(r,t)}d();u();var tn="createGlobalOptionSet",en=`DynamicsWebApi.${tn}`;async function rn(e,t){o.parameterCheck(e,en,"request"),o.parameterCheck(e.data,en,"request.data");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.functionName=tn,v(r,t)}d();u();var nn="updateGlobalOptionSet",ye=`DynamicsWebApi.${nn}`;async function on(e,t){o.parameterCheck(e,ye,"request"),o.parameterCheck(e.data,ye,"request.data"),o.guidParameterCheck(e.data.MetadataId,ye,"request.data.MetadataId"),e.castType&&o.stringParameterCheck(e.castType,ye,"request.castType");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.key=e.data.MetadataId,r.functionName=nn,r.method="PUT",P(r,t)}d();u();var an="deleteGlobalOptionSet",Qo=`DynamicsWebApi.${an}`;async function sn(e,t){o.parameterCheck(e,Qo,"request");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.functionName=an,H(r,t)}d();u();var cn="retrieveGlobalOptionSet",pn=`DynamicsWebApi.${cn}`;async function ln(e,t){o.parameterCheck(e,pn,"request"),e.castType&&o.stringParameterCheck(e.castType,pn,"request.castType");let r=l(e);return r.collection="GlobalOptionSetDefinitions",r.navigationProperty=e.castType,r.functionName=cn,N(r,t)}d();u();var mn="retrieveGlobalOptionSets",Lo=`DynamicsWebApi.${mn}`;async function un(e,t){let r=e?l(e):{};return r.collection="GlobalOptionSetDefinitions",r.functionName=mn,e?.castType&&(o.stringParameterCheck(e.castType,Lo,"request.castType"),r.navigationProperty=e.castType),C(r,t)}d();u();var fn="retrieveCsdlMetadata",Wo=`DynamicsWebApi.${fn}`;async function dn(e,t){let r=e?l(e):{};return r.collection="$metadata",r.functionName=fn,e?.addAnnotations&&(o.boolParameterCheck(e.addAnnotations,Wo,"request.addAnnotations"),r.includeAnnotations="*"),(await t.makeRequest(r))?.data}d();u();h();function Q(e,t,r){if(!e)return e;switch(r?.escapeSpecialCharacters===!0&&(e.search=Rt(e.search)),e.entities?.length&&(e.entities=Vo(e.entities,r?.version)),t){case"query":Go(e,r?.version);break;default:Xo(e,r?.version);break}return e}function Vo(e,t="1.0"){if(!e)return e;if(typeof e=="string"){if(t!=="1.0")return e;try{e=JSON.parse(e)}catch{throw new Error("The 'query.entities' property must be a valid JSON string.")}if(!Array.isArray(e))throw new Error("The 'query.entities' property must be an array of strings or objects.")}let r=i=>typeof i=="string"?i:i.name,a=i=>typeof i=="string"?{name:i}:i,n=e.map(i=>t==="1.0"?r(i):a(i));return t!=="1.0"?JSON.stringify(n):n}function Go(e,t="1.0"){t==="1.0"?(n=>{if(n.count!=null&&(n.returnTotalRecordCount==null&&(n.returnTotalRecordCount=n.count),delete n.count),n.options){if(typeof n.options=="string")try{n.options=JSON.parse(n.options,zo)}catch{throw new Error("The 'query.options' property must be a valid JSON string.")}n.searchMode||(n.searchMode=n.options.searchMode),n.searchType||(n.searchType=n.options.queryType==="lucene"?"full":n.options.queryType),delete n.options}for(let i of Ko)if(n[i]&&typeof n[i]=="string")try{n[i]=JSON.parse(n[i])}catch{throw new Error(`The 'query.${i}' property must be a valid JSON string.`)}})(e):(n=>{n.returnTotalRecordCount!=null&&(n.count==null&&(n.count=n.returnTotalRecordCount),delete n.returnTotalRecordCount),(n.searchMode||n.searchType)&&(typeof n.options!="string"&&(n.options||(n.options={}),n.options.searchMode||(n.options.searchMode=n.searchMode),n.options.queryType||(n.options.queryType=n.searchType==="full"?"lucene":n.searchType)),delete n.searchMode,delete n.searchType),n.orderBy&&typeof n.orderBy!="string"&&(n.orderby=JSON.stringify(n.orderBy),delete n.orderBy),n.facets&&typeof n.facets!="string"&&(n.facets=JSON.stringify(n.facets)),n.options&&typeof n.options!="string"&&(n.options=JSON.stringify(yn(n.options)))})(e)}function Xo(e,t="1.0"){t==="1.0"?(n=>{if(n.fuzzy!=null&&(n.useFuzzy==null&&(n.useFuzzy=n.fuzzy),delete n.fuzzy),delete n.options,n.orderBy&&typeof n.orderBy=="string")try{n.orderBy=JSON.parse(n.orderBy)}catch{throw new Error("The 'query.orderBy' property must be a valid JSON string.")}})(e):(n=>{n.useFuzzy!=null&&(n.fuzzy==null&&(n.fuzzy=n.useFuzzy),delete n.useFuzzy),n.orderBy&&typeof n.orderBy!="string"&&(n.orderby=JSON.stringify(n.orderBy),delete n.orderBy),n.options&&typeof n.options!="string"&&(n.options=JSON.stringify(yn(n.options)))})(e)}function yn(e){let t={};for(let r in e)t[r.toLowerCase()]=e[r];return t}function zo(e,t){switch(e){case"searchmode":this.searchMode=t;break;case"querytype":this.queryType=t;break;default:return t}}var Ko=["orderBy","facets"];function Rn(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S),i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.facets=n.Facets,i.totalrecordcount=n.Count,i.querycontext=n.QueryContext),i},a=()=>{let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Count:e.totalrecordcount,Value:e.value,Facets:e.facets,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():a()}var Le="query",Re=`${c}.${Le}`;async function We(e,t){o.parameterCheck(e,Re,"request");let r=typeof e!="string",a=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};o.parameterCheck(n.query,Re,"request.query"),o.stringParameterCheck(n.query.search,Re,a),o.maxLengthStringParameterCheck(n.query.search,Re,a,100),n.collection="query",n.functionName=Le,n.method="POST",n.data=Q(n.query,Le,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return Rn(i.data,t.config.searchApi)}d();u();function gn(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S);t.enableSearchApiResponseCompatibility&&n.Value?.forEach(s=>{s.document=s.Document,s.text=s.Text});let i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.querycontext=n.QueryContext),i},a=()=>{t.enableSearchApiResponseCompatibility&&e.value?.forEach(i=>{i.Document=i.document,i.Text=i.text});let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Value:e.value,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():a()}var Ve="suggest",ge=`${c}.${Ve}`;async function hn(e,t){o.parameterCheck(e,ge,"request");let r=typeof e!="string",a=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};o.parameterCheck(n.query,ge,"request.query"),o.stringParameterCheck(n.query.search,ge,a),o.maxLengthStringParameterCheck(n.query.search,ge,a,100),n.functionName=n.collection=Ve,n.method="POST",n.data=Q(n.query,Ve,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return gn(i.data,t.config.searchApi)}d();u();function Cn(e,t){if(!e)return e;let r=()=>{let n=JSON.parse(e.response,S),i={...e,response:n};return t.enableSearchApiResponseCompatibility&&(i.value=n.Value,i.querycontext=n.QueryContext),i},a=()=>{let n={...e};return t.enableSearchApiResponseCompatibility&&(n.response={Value:e.value,QueryContext:e.querycontext,Error:null}),n};return t?.version==="2.0"?r():a()}var Ge="autocomplete",he=`${c}.${Ge}`;async function An(e,t){o.parameterCheck(e,he,"request");let r=typeof e!="string",a=r?"request.query.search":"term",n=r?T(e):{query:{search:e}};r&&o.parameterCheck(n.query,he,"request.query"),o.stringParameterCheck(n.query.search,he,a),o.maxLengthStringParameterCheck(n.query.search,he,a,100),n.functionName=n.collection=Ge,n.method="POST",n.data=Q(n.query,Ge,t.config.searchApi),n.apiConfig=t.config.searchApi,delete n.query;let i=await t.makeRequest(n);return Cn(i.data,t.config.searchApi)}u();var xn="getBackgroundOperationStatus",En=`${c}.${xn}`;async function bn(e,t){o.throwBatchIncompatible(En,t.isBatch),o.keyParameterCheck(e,En,"backgroundOperationId");let r={method:"GET",addPath:`backgroundoperation/${e}`,functionName:xn,apiConfig:t.config.serviceApi,includeDefaultDataverseHeaders:!1,headers:{"Content-Type":"application/json"},_isUnboundRequest:!0};return(await t.makeRequest(r))?.data}u();var vn="cancelBackgroundOperation",Tn=`${c}.${vn}`;async function Nn(e,t){o.throwBatchIncompatible(Tn,t.isBatch),o.keyParameterCheck(e,Tn,"backgroundOperationId");let r={method:"DELETE",addPath:`backgroundoperation/${e}`,functionName:vn,apiConfig:t.config.serviceApi,includeDefaultDataverseHeaders:!1,headers:{"Content-Type":"application/json"},_isUnboundRequest:!0};return(await t.makeRequest(r))?.data}var f,ze=class ze{constructor(t){B(this,f);this.setConfig=t=>m(this,f).setConfig(t);this.create=async t=>v(t,m(this,f));this.retrieve=async t=>N(t,m(this,f));this.update=async t=>P(t,m(this,f));this.updateSingleProperty=async t=>mr(t,m(this,f));this.deleteRecord=async t=>H(t,m(this,f));this.upsert=async t=>fr(t,m(this,f));this.uploadFile=async t=>hr(t,m(this,f));this.downloadFile=t=>xr(t,m(this,f));this.retrieveMultiple=async(t,r)=>C(t,m(this,f),r);this.retrieveAll=t=>Be(t,m(this,f));this.count=async t=>zt(t,m(this,f));this.countAll=async t=>jt(t,m(this,f));this.fetch=async t=>me(t,m(this,f));this.fetchAll=async t=>sr(t,m(this,f));this.associate=async t=>wt(t,m(this,f));this.disassociate=async t=>er(t,m(this,f));this.associateSingleValued=async t=>Ft(t,m(this,f));this.disassociateSingleValued=async t=>rr(t,m(this,f));this.callFunction=async t=>Vt(t,m(this,f));this.callAction=async t=>Qt(t,m(this,f));this.createEntity=t=>Pr(t,m(this,f));this.updateEntity=t=>kr(t,m(this,f));this.retrieveEntity=t=>Or(t,m(this,f));this.retrieveEntities=t=>Mr(m(this,f),t);this.createAttribute=t=>_r(t,m(this,f));this.updateAttribute=t=>wr(t,m(this,f));this.retrieveAttributes=t=>Fr(t,m(this,f));this.retrieveAttribute=t=>Hr(t,m(this,f));this.createRelationship=t=>Wr(t,m(this,f));this.updateRelationship=t=>Gr(t,m(this,f));this.deleteRelationship=t=>Kr(t,m(this,f));this.retrieveRelationships=t=>Jr(t,m(this,f));this.retrieveRelationship=t=>Zr(t,m(this,f));this.createGlobalOptionSet=t=>rn(t,m(this,f));this.updateGlobalOptionSet=t=>on(t,m(this,f));this.deleteGlobalOptionSet=t=>sn(t,m(this,f));this.retrieveGlobalOptionSet=t=>ln(t,m(this,f));this.retrieveGlobalOptionSets=t=>un(t,m(this,f));this.retrieveCsdlMetadata=async t=>dn(t,m(this,f));this.search=async t=>We(t,m(this,f));this.query=async t=>We(t,m(this,f));this.suggest=async t=>hn(t,m(this,f));this.autocomplete=async t=>An(t,m(this,f));this.getBackgroundOperationStatus=async t=>bn(t,m(this,f));this.cancelBackgroundOperation=async t=>Nn(t,m(this,f));this.startBatch=()=>Tr(m(this,f));this.executeBatch=async t=>br(t,m(this,f));this.initializeInstance=t=>new ze(t||m(this,f).config);this.Utility={getCollectionName:t=>_t(t)};L(this,f,new se(t))}};f=new WeakMap;var Xe=ze;return Je(Jo);})();
var DynamicsWebApi = _dynamicsWebApiExports.DynamicsWebApi
//# sourceMappingURL=dynamics-web-api.min.js.map
{
"name": "dynamics-web-api",
"version": "2.2.1",
"version": "2.3.0",
"description": "DynamicsWebApi is a Microsoft Dataverse Web API helper library",

@@ -42,3 +42,3 @@ "keywords": [

"devDependencies": {
"@types/chai": "^5.0.1",
"@types/chai": "^4.3.20",
"@types/mocha": "^10.0.10",

@@ -49,3 +49,3 @@ "@types/node": "^20.16.5",

"Base64": "^1.3.0",
"chai": "^5.1.2",
"chai": "^4.5.0",
"copyfiles": "^2.4.1",

@@ -59,6 +59,6 @@ "esbuild": "^0.25.0",

"nyc": "^17.1.0",
"prettier": "^3.5.0",
"prettier": "^3.5.1",
"rimraf": "^6.0.1",
"sinon": "^19.0.2",
"tsx": "^4.19.2",
"ts-node": "^10.9.2",
"typescript": "^5.7.3"

@@ -76,5 +76,7 @@ },

"test": "run-s test:*",
"coverage": "run-s coverage:clean test:build coverage:nyc",
"tsc": "tsc --noEmit",
"coverage": "run-s coverage:clean test:build coverage:nyc:*",
"coverage:clean": "rimraf coverage",
"coverage:nyc": "nyc npm run test:mocha && nyc report --reporter=lcov",
"coverage:nyc:test": "nyc mocha",
"coverage:nyc:report": "nyc report --reporter=lcov",
"clean": "rimraf dist lib coverage .nyc_output",

@@ -99,2 +101,2 @@ "off-build:ts": "node ./utils/build.mjs",

}
}
}

@@ -15,5 +15,5 @@ # DynamicsWebApi for Microsoft Dataverse Web API / Microsoft Power Pages / Microsoft Dynamics 365 (CRM)

- **Microsoft Dataverse Search API**. Access the full power of its Search, Suggestion and Autocomplete capabilities.
- **Microsoft Dataverse Search API**. Access the full power of its Search (Query), Suggestion and Autocomplete capabilities.
- **Batch Requests**. Convert all requests into a Batch operation with two lines of code.
- **Simplicity and Automation**. Such as automated paging, big file downloading/uploading in chunks of data, automated conversion of requests with long URLs into a Batch Request in the background and more!
- **Simplicity and Automation**. Automated paging, big file downloading/uploading in chunks of data, automated conversion of requests with long URLs into a Batch Request and more!
- **CRUD operations**. Including Fetch XML, Actions and Functions in Microsoft Dataverse Web API.

@@ -25,2 +25,3 @@ - **Table Definitions (Entity Metadata)**. Query and modify Table, Column, Choice (Option Set) and Relationship definitions.

- **Proxy Configuration** support.
- **Background Operations** support. `v2.3.0+`
- Works with **Microsoft Power Pages** (aka Microsoft Portal). `v2.1.0+`

@@ -32,3 +33,4 @@

**Please note!** "Dynamics 365" in this readme refers to Microsoft Dataverse (formerly known as Microsoft Common Data Service) / Microsoft Dynamics 365 Customer Engagement / Micorosft Dynamics CRM. **NOT** Microsoft Dynamics 365 Finance and Operations.
>[!NOTE]
> "Dynamics 365" in this readme refers to Microsoft Dataverse (formerly known as Microsoft Common Data Service) / Microsoft Dynamics 365 Customer Engagement / Micorosft Dynamics CRM. **NOT** Microsoft Dynamics 365 Finance and Operations.

@@ -67,3 +69,3 @@ ## Usage examples

```html
<script type="text/javascript" src="https://unpkg.com/dynamics-web-api@2.1.4/dist/dynamics-web-api.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/dynamics-web-api@2.3.0/dist/dynamics-web-api.min.js"></script>
```

@@ -70,0 +72,0 @@

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 too big to display

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