jsforce
Version:
Salesforce API Library for JavaScript
2 lines • 1.42 MB
JavaScript
/*! For license information please see jsforce.min.js.LICENSE.txt */
var jsforce;(()=>{var t={97268:(t,e,r)=>{"use strict";r.d(e,{A:()=>n});const n="3.10.7"},57492:(t,e,r)=>{"use strict";r.d(e,{A:()=>rt,y:()=>et});var n=r(54818),i=r.n(n),o=r(82173),s=r.n(o),a=r(68040),u=r.n(a),l=r(62675),c=r.n(l),h=r(25988),f=r.n(h),p=r(36678),d=r.n(p),m=r(13003),g=r.n(m),b=r(45658),y=r.n(b),v=r(74294),w=r.n(v),_=r(24839),M=r(14953),S=r(4449),A=r(4821),x=r(47686),E=r(80025),T=r(89213),k=(r(6764),r(71698),r(12888),r(52508),r(11190),r(94711),r(94644),r(67053),r(82067),r(23829),r(67873),r(56501),r(28566),r(14109)),C=r.n(k),R=r(23304),I=r.n(R),O=r(34748),P=r.n(O),L=r(80627),D=r.n(L),N=r(44124),F=r.n(N),j=r(37635),B=r.n(j),U=r(75770),q=r.n(U),V=r(3835),z=r.n(V),W=r(78205),H=r.n(W),G=r(64785),K=r(10631),$=r(69557);function Q(t,e){var r=s()(t);if(u()){var n=u()(t);e&&(n=c()(n).call(n,(function(e){return f()(t,e).enumerable}))),r.push.apply(r,n)}return r}function Z(t){for(var e=1;e<arguments.length;e++){var r,n,i=null!=arguments[e]?arguments[e]:{};e%2?d()(r=Q(Object(i),!0)).call(r,(function(e){(0,_.A)(t,e,i[e])})):g()?y()(t,g()(i)):d()(n=Q(Object(i))).call(n,(function(e){w()(t,e,f()(i,e))}))}return t}function X(t,e,r){return e=(0,x.A)(e),(0,A.A)(t,J()?i()(e,r||[],(0,x.A)(t).constructor):e.apply(t,r))}function J(){try{var t=!Boolean.prototype.valueOf.call(i()(Boolean,[],(function(){})))}catch(t){}return(J=function(){return!!t})()}function Y(){var t=function(){var t;if(window.location.hash){if((t=new(P())(window.location.hash.substring(1))).get("access_token"))return{success:!0,body:t}}else if(window.location.search&&(t=new(P())(window.location.search.substring(1))).get("error"))return{success:!1,body:t}}(),e=localStorage.getItem("jsforce_state");if(t&&e&&t.body.get("state")===e){localStorage.removeItem("jsforce_state");var r=e.split("."),n=(0,T.A)(r,2),i=n[0],o=n[1],s=new et(i);return t.success?(s._storeTokens(I()(t.body)),location.hash=""):s._storeError(t.body),"popup"===o&&window.close(),!0}}var tt=0,et=function(t){function e(t){var r;return(0,M.A)(this,e),(r=X(this,e))._prefix=t||"jsforce"+tt++,r}return(0,E.A)(e,t),(0,S.A)(e,[{key:"connection",get:function(){return this._connection||(this._connection=new K.A(this._config)),this._connection}},{key:"init",value:function(t){var e=this;if(!Y()){this._config=t;var r=this._getTokens();r&&(this.connection._establish(r),D()((function(){e.emit("connect",e.connection)}),10))}}},{key:"login",value:function(){var t,e,r,n=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=i.scope,s=i.size,a=new $.A(null!==(t=this._config)&&void 0!==t?t:{}),u=Math.random().toString(36).substring(2),l=[this._prefix,"popup",u].join(".");localStorage.setItem("jsforce_state",l);var c,h,f,p,d,m,g,b,y=a.getAuthorizationUrl(Z({response_type:"token",state:l},o?{scope:o}:{})),v=(c=y,h=null!==(e=null==s?void 0:s.width)&&void 0!==e?e:912,f=null!==(r=null==s?void 0:s.height)&&void 0!==r?r:513,g=screen.width/2-h/2,b=screen.height/2-f/2,window.open(c,void 0,C()(p=C()(d=C()(m="location=yes,toolbar=no,status=no,menubar=no,width=".concat(h,",height=")).call(m,f,",top=")).call(d,b,",left=")).call(p,g)));return new(F())((function(t,e){if(v){n._removeTokens();var r=B()((function(){try{if(!v||v.closed){clearInterval(r);var i=n._getTokens();if(i)n.connection._establish(i),n.emit("connect",n.connection),t({status:"connect"});else{var o=n._getError();o?e(new Error(o.error+": "+o.error_description)):t({status:"cancel"})}}}catch(t){}}),1e3)}else{var i=[n._prefix,"redirect",u].join(".");localStorage.setItem("jsforce_state",i);var s=a.getAuthorizationUrl(Z({response_type:"token",state:i},o?{scope:o}:{}));location.href=s}}))}},{key:"isLoggedIn",value:function(){return!!this.connection.accessToken}},{key:"logout",value:function(){this.connection.logout(),this._removeTokens(),this.emit("disconnect")}},{key:"_getTokens",value:function(){var t=new RegExp("(^|;\\s*)"+this._prefix+"_loggedin=true(;|$)");if(document.cookie.match(t)){var e=Number(localStorage.getItem(this._prefix+"_issued_at"));if(q()()<e+72e5){var r,n=localStorage.getItem(this._prefix+"_id");if(n){var i,o=z()(i=n.split("/")).call(i),s=(0,T.A)(o,2);r={id:s[0],organizationId:s[1],url:n}}return{accessToken:localStorage.getItem(this._prefix+"_access_token"),instanceUrl:localStorage.getItem(this._prefix+"_instance_url"),userInfo:r}}}return null}},{key:"_storeTokens",value:function(t){localStorage.setItem(this._prefix+"_access_token",t.access_token),localStorage.setItem(this._prefix+"_instance_url",t.instance_url),localStorage.setItem(this._prefix+"_issued_at",t.issued_at),localStorage.setItem(this._prefix+"_id",t.id),document.cookie=this._prefix+"_loggedin=true;"}},{key:"_removeTokens",value:function(){localStorage.removeItem(this._prefix+"_access_token"),localStorage.removeItem(this._prefix+"_instance_url"),localStorage.removeItem(this._prefix+"_issued_at"),localStorage.removeItem(this._prefix+"_id"),document.cookie=this._prefix+"_loggedin="}},{key:"_getError",value:function(){try{var t,e=JSON.parse(null!==(t=localStorage.getItem(this._prefix+"_error"))&&void 0!==t?t:"");return localStorage.removeItem(this._prefix+"_error"),e}catch(t){}}},{key:"_storeError",value:function(t){localStorage.setItem(this._prefix+"_error",H()(t))}}])}(G.EventEmitter);const rt=new et},90503:(t,e,r)=>{"use strict";r.d(e,{A:()=>j});var n=r(54818),i=r.n(n),o=r(14953),s=r(4449),a=r(4821),u=r(47686),l=r(80025),c=r(89423),h=r(62207),f=r(24839),p=r(41400),d=r.n(p),m=r(82173),g=r.n(m),b=r(68040),y=r.n(b),v=r(62675),w=r.n(v),_=r(25988),M=r.n(_),S=r(36678),A=r.n(S),x=r(13003),E=r.n(x),T=r(45658),k=r.n(T),C=r(74294),R=r.n(C),I=(r(6764),r(11190),r(10631)),O=["client"],P=["oauth2"];function L(t,e){var r=g()(t);if(y()){var n=y()(t);e&&(n=w()(n).call(n,(function(e){return M()(t,e).enumerable}))),r.push.apply(r,n)}return r}function D(t){for(var e=1;e<arguments.length;e++){var r,n,i=null!=arguments[e]?arguments[e]:{};e%2?A()(r=L(Object(i),!0)).call(r,(function(e){(0,f.A)(t,e,i[e])})):E()?k()(t,E()(i)):A()(n=L(Object(i))).call(n,(function(e){R()(t,e,M()(i,e))}))}return t}function N(t,e,r){return e=(0,u.A)(e),(0,a.A)(t,F()?i()(e,r||[],(0,u.A)(t).constructor):e.apply(t,r))}function F(){try{var t=!Boolean.prototype.valueOf.call(i()(Boolean,[],(function(){})))}catch(t){}return(F=function(){return!!t})()}const j=new(function(t){function e(){return(0,o.A)(this,e),N(this,e,arguments)}return(0,l.A)(e,t),(0,s.A)(e,[{key:"_saveConfig",value:function(){}}])}(function(){return(0,s.A)((function t(){(0,o.A)(this,t),(0,f.A)(this,"_registryConfig",{})}),[{key:"_saveConfig",value:function(){throw new Error("_saveConfig must be implemented in subclass")}},{key:"_getClients",value:function(){return this._registryConfig.clients||(this._registryConfig.clients={})}},{key:"_getConnections",value:function(){return this._registryConfig.connections||(this._registryConfig.connections={})}},{key:"getConnectionNames",value:(p=(0,h.A)(d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",g()(this._getConnections()));case 1:case"end":return t.stop()}}),t,this)}))),function(){return p.apply(this,arguments)})},{key:"getConnection",value:(l=(0,h.A)(d().mark((function t(e){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getConnectionConfig(e);case 2:return r=t.sent,t.abrupt("return",r?new I.A(r):null);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"getConnectionConfig",value:(u=(0,h.A)(d().mark((function t(e){var r,n,i,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e||(e=this._registryConfig.default),r=this._getConnections(),n=e?r[e]:void 0){t.next=5;break}return t.abrupt("return",null);case 5:if(i=n.client,o=(0,c.A)(n,O),!i){t.next=18;break}return t.t0=D,t.t1=D({},o),t.t2={},t.t3=D,t.t4={},t.next=14,this.getClientConfig(i);case 14:return t.t5=t.sent,t.t6=(0,t.t3)(t.t4,t.t5),t.t7={oauth2:t.t6},t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t7));case 18:return t.abrupt("return",o);case 19:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"saveConnectionConfig",value:(a=(0,h.A)(d().mark((function t(e,r){var n,i,o,s,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=this._getConnections(),i=r.oauth2,o=(0,c.A)(r,P),s=o,i&&((a=this._findClientName(i))&&(s=D(D({},s),{},{client:a})),delete r.oauth2),n[e]=s,this._saveConfig();case 6:case"end":return t.stop()}}),t,this)}))),function(t,e){return a.apply(this,arguments)})},{key:"_findClientName",value:function(t){for(var e=t.clientId,r=t.loginUrl,n=this._getClients(),i=0,o=g()(n);i<o.length;i++){var s=o[i],a=n[s];if(a.clientId===e&&(a.loginUrl||"https://login.salesforce.com")===r)return s}return null}},{key:"setDefaultConnection",value:(i=(0,h.A)(d().mark((function t(e){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._registryConfig.default=e,this._saveConfig();case 2:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"removeConnectionConfig",value:(n=(0,h.A)(d().mark((function t(e){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:delete this._getConnections()[e],this._saveConfig();case 3:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"getClientConfig",value:(r=(0,h.A)(d().mark((function t(e){var r,n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getClients(),n=r[e],t.abrupt("return",n&&D({},n));case 3:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"getClientNames",value:(e=(0,h.A)(d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",g()(this._getClients()));case 1:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"registerClientConfig",value:(t=(0,h.A)(d().mark((function t(e,r){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._getClients()[e]=r,this._saveConfig();case 3:case"end":return t.stop()}}),t,this)}))),function(e,r){return t.apply(this,arguments)})}]);var t,e,r,n,i,a,u,l,p}()))},20638:(t,e,r)=>{"use strict";r.d(e,{A:()=>O});var n=r(54818),i=r.n(n),o=r(62207),s=r(28331),a=r(14953),u=r(4449),l=r(4821),c=r(47686),h=r(80025),f=r(24839),p=r(41400),d=r.n(p),m=(r(6764),r(71698),r(14109)),g=r.n(m),b=r(44499),y=r.n(b),v=r(78205),w=r.n(v),_=r(82173),M=r.n(_),S=r(67977),A=r.n(S),x=r(44124),E=r.n(x),T=r(64785);function k(t,e,r){return e=(0,c.A)(e),(0,l.A)(t,C()?i()(e,r||[],(0,c.A)(t).constructor):e.apply(t,r))}function C(){try{var t=!Boolean.prototype.valueOf.call(i()(Boolean,[],(function(){})))}catch(t){}return(C=function(){return!!t})()}var R=function(t){function e(){var t,r;(0,a.A)(this,e);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return r=k(this,e,g()(t=[]).call(t,i)),(0,f.A)(r,"_fetching",!1),(0,f.A)(r,"_value",void 0),r}return(0,h.A)(e,t),(0,u.A)(e,[{key:"get",value:function(t){if(t){var e=t;this.once("value",(function(t){return e(t)})),void 0!==this._value&&this.emit("value",this._value)}return this._value}},{key:"set",value:function(t){this._value=t,this.emit("value",this._value)}},{key:"clear",value:function(){this._fetching=!1,this._value=void 0}}])}(T.EventEmitter);function I(t,e,r){return"string"==typeof t.key?t.key:"function"==typeof t.key?t.key.apply(e,r):function(t,e){var r,n;return g()(r="".concat(t||"","(")).call(r,y()(n=(0,s.A)(e)).call(n,(function(t){return w()(t)})).join(","),")")}(t.namespace,r)}const O=function(){return(0,u.A)((function t(){(0,a.A)(this,t),(0,f.A)(this,"_entries",{})}),[{key:"get",value:function(t){if(this._entries[t])return this._entries[t];var e=new R;return this._entries[t]=e,e}},{key:"clear",value:function(t){for(var e=0,r=M()(this._entries);e<r.length;e++){var n=r[e];t&&!A()(n).call(n,t)||this._entries[n].clear()}}},{key:"createCachedFunction",value:function(t,e){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strategy:"NOCACHE"},i=n.strategy,s=function(){for(var s=arguments.length,a=new Array(s),u=0;u<s;u++)a[u]=arguments[u];var l,c=I(n,e,a),h=r.get(c),f=function(){var n=(0,o.A)(d().mark((function n(){var i;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return h._fetching=!0,n.prev=1,n.next=4,t.apply(e||r,a);case 4:return i=n.sent,h.set({error:void 0,result:i}),n.abrupt("return",i);case 9:throw n.prev=9,n.t0=n.catch(1),h.set({error:n.t0,result:void 0}),n.t0;case 13:case"end":return n.stop()}}),n,null,[[1,9]])})));return function(){return n.apply(this,arguments)}}();switch(i){case"IMMEDIATE":if(!(l=h.get()))throw new Error("Function call result is not cached yet.");if(l.error)throw l.error;return l.result;case"HIT":return(0,o.A)(d().mark((function t(){return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(h._fetching){t.next=3;break}return t.next=3,f();case 3:return t.abrupt("return",new(E())((function(t,e){h.get((function(r){var n=r.error,i=r.result;n?e(n):t(i)}))})));case 4:case"end":return t.stop()}}),t)})))();default:return f()}};return s.clear=function(){for(var t=arguments.length,i=new Array(t),o=0;o<t;o++)i[o]=arguments[o];var s=I(n,e,i);r.clear(s)},s}}])}()},10631:(t,e,r)=>{"use strict";r.d(e,{N:()=>te,A:()=>ee});var n=r(54818),i=r.n(n),o=r(82173),s=r.n(o),a=r(68040),u=r.n(a),l=r(62675),c=r.n(l),h=r(25988),f=r.n(h),p=r(13003),d=r.n(p),m=r(45658),g=r.n(m),b=r(74294),y=r.n(b),v=r(71223),w=r.n(v),_=r(20153),M=r.n(_),S=r(97106),A=r.n(S),x=r(84381),E=r.n(x),T=r(13040),k=r(28331),C=r(89423),R=r(14953),I=r(4449),O=r(4821),P=r(47686),L=r(80025),D=r(24839),N=r(62207),F=r(89213),j=r(41400),B=r.n(j),U=r(67977),q=r.n(U),V=r(34047),z=r.n(V),W=r(14109),H=r.n(W),G=r(44124),K=r.n(G),$=r(32886),Q=r.n($),Z=r(78205),X=r.n(Z),J=r(75403),Y=r.n(J),tt=r(44499),et=r.n(tt),rt=r(36678),nt=r.n(rt),it=r(26321),ot=r.n(it),st=r(38336),at=r.n(st),ut=(r(6764),r(71698),r(16374),r(11190),r(12888),r(52508),r(94711),r(82067),r(37230),r(67873),r(56501),r(3484),r(64785)),lt=r(25650),ct=r(73258),ht=r(74833),ft=r(69557),pt=r(20638),dt=r(32439),mt=r(75770),gt=r.n(mt),bt=function(){return(0,I.A)((function t(e,r){(0,R.A)(this,t),(0,D.A)(this,"_lastRefreshedAt",void 0),(0,D.A)(this,"_refreshPromise",void 0),this._conn=e,this._logger=e._logLevel?t._logger.createInstance(e._logLevel):t._logger,this._refreshFn=r}),[{key:"refresh",value:(e=(0,N.A)(B().mark((function t(e){var r=this;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(this._lastRefreshedAt&&this._lastRefreshedAt>e)){t.next=2;break}return t.abrupt("return");case 2:if(!this._refreshPromise){t.next=6;break}return t.next=5,this._refreshPromise;case 5:return t.abrupt("return");case 6:return t.prev=6,this._logger.info("<refresh token>"),this._refreshPromise=new(K())((function(t,e){r._refreshFn(r._conn,(function(n,i,o){n?e(n):(r._logger.debug("Connection refresh completed."),r._conn.accessToken=i,r._conn.emit("refresh",i,o),t())}))})),t.next=11,this._refreshPromise;case 11:this._logger.info("<refresh complete>"),t.next=17;break;case 14:throw t.prev=14,t.t0=t.catch(6),new Error("Unable to refresh session due to: ".concat(t.t0.message));case 17:return t.prev=17,this._refreshPromise=void 0,this._lastRefreshedAt=gt()(),t.finish(17);case 21:case"end":return t.stop()}}),t,this,[[6,14,17,21]])}))),function(t){return e.apply(this,arguments)})},{key:"isRefreshing",value:function(){return!!this._refreshPromise}},{key:"waitRefresh",value:(t=(0,N.A)(B().mark((function t(){return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._refreshPromise);case 1:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})}]);var t,e}();(0,D.A)(bt,"_logger",(0,ht.tZ)("session-refresh-delegate"));const yt=bt;var vt=r(65571),wt=r(50458),_t=r(18778);function Mt(t,e){var r=s()(t);if(u()){var n=u()(t);e&&(n=c()(n).call(n,(function(e){return f()(t,e).enumerable}))),r.push.apply(r,n)}return r}var St=function(){return(0,I.A)((function t(e){(0,R.A)(this,t),this._conn=e}),[{key:"list",value:(t=(0,N.A)(B().mark((function t(){var e;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._conn.request("/process/rules");case 2:return e=t.sent,t.abrupt("return",e.rules);case 4:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"trigger",value:function(t){var e=Y()(t)?t:[t];return this._conn.request({method:"POST",url:"/process/rules/",body:X()({contextIds:e}),headers:{"content-type":"application/json"}})}}]);var t}(),At=function(){return(0,I.A)((function t(e){(0,R.A)(this,t),this._conn=e}),[{key:"list",value:(t=(0,N.A)(B().mark((function t(){var e;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._conn.request("/process/approvals");case 2:return e=t.sent,t.abrupt("return",e.approvals);case 4:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"request",value:function(t){var e=et()(t).call(t,(function(t){return"_request"in t?t._request:t}));return this._conn.request({method:"POST",url:"/process/approvals",headers:{"content-type":"application/json"},body:X()({requests:e})})}},{key:"_createRequest",value:function(t,e,r){return new xt(this,function(t){for(var e=1;e<arguments.length;e++){var r,n,i=null!=arguments[e]?arguments[e]:{};e%2?nt()(r=Mt(Object(i),!0)).call(r,(function(e){(0,D.A)(t,e,i[e])})):d()?g()(t,d()(i)):nt()(n=Mt(Object(i))).call(n,(function(e){y()(t,e,f()(i,e))}))}return t}({actionType:t,contextId:e,comments:r},arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}))}},{key:"submit",value:function(t,e,r){return this._createRequest("Submit",t,e,r)}},{key:"approve",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._createRequest("Approve",t,e,r)}},{key:"reject",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._createRequest("Reject",t,e,r)}}]);var t}(),xt=function(){return(0,I.A)((function t(e,r){(0,R.A)(this,t),this._process=e,this._request=r}),[{key:"then",value:function(t,e){this._promise||(this._promise=this._process.request([this]).then((function(t){return t[0]}))),this._promise.then(t,e)}}])}();const Et=(0,I.A)((function t(e){(0,R.A)(this,t),this.rule=new St(e),this.approval=new At(e)}));var Tt=r(8819),kt=r(72964),Ct=r.n(kt),Rt=r(32313).Buffer,It=["Id","type","attributes"],Ot=["Id","type","attributes"],Pt=["Id","type","attributes"],Lt=["Id","type","attributes"];function Dt(t){var e=function(t,e){if("object"!=(0,T.A)(t)||!t)return t;var r=t[E()];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=(0,T.A)(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==(0,T.A)(e)?e:e+""}function Nt(t,e){var r=void 0!==M()&&A()(t)||t["@@iterator"];if(!r){if(Y()(t)||(r=function(t,e){if(t){var r;if("string"==typeof t)return Ft(t,e);var n=z()(r={}.toString.call(t)).call(r,8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?w()(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ft(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function jt(t,e){var r=s()(t);if(u()){var n=u()(t);e&&(n=c()(n).call(n,(function(e){return f()(t,e).enumerable}))),r.push.apply(r,n)}return r}function Bt(t){for(var e=1;e<arguments.length;e++){var r,n,i=null!=arguments[e]?arguments[e]:{};e%2?nt()(r=jt(Object(i),!0)).call(r,(function(e){(0,D.A)(t,e,i[e])})):d()?g()(t,d()(i)):nt()(n=jt(Object(i))).call(n,(function(e){y()(t,e,f()(i,e))}))}return t}function Ut(t,e,r){return e=(0,P.A)(e),(0,O.A)(t,qt()?i()(e,r||[],(0,P.A)(t).constructor):e.apply(t,r))}function qt(){try{var t=!Boolean.prototype.valueOf.call(i()(Boolean,[],(function(){})))}catch(t){}return(qt=function(){return!!t})()}var Vt="https://login.salesforce.com",zt="",Wt="50.0",Ht=10;function Gt(t){return String(t||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Kt(t){var e,r=z()(e=t.split("/")).call(e,-2),n=(0,F.A)(r,2),i=n[0];return{id:n[1],organizationId:i,url:t}}function $t(t,e){return Qt.apply(this,arguments)}function Qt(){return(Qt=(0,N.A)(B().mark((function t(e,r){var n,i;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,e.refreshToken){t.next=3;break}throw new Error("No refresh token found in the connection");case 3:return t.next=5,e.oauth2.refreshToken(e.refreshToken);case 5:n=t.sent,i=Kt(n.id),e._establish({instanceUrl:n.instance_url,accessToken:n.access_token,userInfo:i}),r(void 0,n.access_token,n),t.next=18;break;case 11:if(t.prev=11,t.t0=t.catch(0),!(t.t0 instanceof Error)){t.next=17;break}r(t.t0),t.next=18;break;case 17:throw t.t0;case 18:case"end":return t.stop()}}),t,null,[[0,11]])})))).apply(this,arguments)}function Zt(t,e){return function(){var r=(0,N.A)(B().mark((function r(n,i){return B().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,n.login(t,e);case 3:if(n.accessToken){r.next=5;break}throw new Error("Access token not found after login");case 5:i(null,n.accessToken),r.next=15;break;case 8:if(r.prev=8,r.t0=r.catch(0),!(r.t0 instanceof Error)){r.next=14;break}i(r.t0),r.next=15;break;case 14:throw r.t0;case 15:case"end":return r.stop()}}),r,null,[[0,8]])})));return function(t,e){return r.apply(this,arguments)}}()}function Xt(t){return{success:!1,errors:[t]}}function Jt(t){var e;throw new Error(H()(e="API module '".concat(t,"' is not loaded, load 'jsforce/api/")).call(e,t,"' explicitly"))}var Yt=200,te=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,R.A)(this,e),t=Ut(this,e),(0,D.A)(t,"limitInfo",{}),(0,D.A)(t,"sobjects",{}),(0,D.A)(t,"insert",t.create),(0,D.A)(t,"delete",t.destroy),(0,D.A)(t,"del",t.destroy),(0,D.A)(t,"process",new Et(t));var n=r.loginUrl,i=r.instanceUrl,o=r.version,s=r.oauth2,a=r.maxRequest,u=r.logLevel,l=r.proxyUrl,c=r.httpProxy;if(t.loginUrl=n||Vt,t.instanceUrl=i||zt,t.isLightningInstance())throw new Error("lightning URLs are not valid as instance URLs");t.version=o||Wt,t.oauth2=s instanceof ft.A?s:new ft.A(Bt({loginUrl:t.loginUrl,proxyUrl:l,httpProxy:c},s));var h=r.refreshFn;!h&&t.oauth2.clientId&&(h=$t),h&&(t._refreshDelegate=new yt(t,h)),t._maxRequest=a||Ht,t._logger=u?e._logger.createInstance(u):e._logger,t._logLevel=u,t._transport=l?new ct._4(l):c?new ct.AX(c):new ct.Ay,t._callOptions=r.callOptions,t.cache=new pt.A;var f=function(t){return t?"describe.".concat(t):"describe"},p=e.prototype.describe;t.describe=t.cache.createCachedFunction(p,t,{key:f,strategy:"NOCACHE"}),t.describe$=t.cache.createCachedFunction(p,t,{key:f,strategy:"HIT"}),t.describe$$=t.cache.createCachedFunction(p,t,{key:f,strategy:"IMMEDIATE"}),t.describeSObject=t.describe,t.describeSObject$=t.describe$,t.describeSObject$$=t.describe$$;var d=e.prototype.describeGlobal;t.describeGlobal=t.cache.createCachedFunction(d,t,{key:"describeGlobal",strategy:"NOCACHE"}),t.describeGlobal$=t.cache.createCachedFunction(d,t,{key:"describeGlobal",strategy:"HIT"}),t.describeGlobal$$=t.cache.createCachedFunction(d,t,{key:"describeGlobal",strategy:"IMMEDIATE"});var m=r.accessToken,g=r.refreshToken,b=r.sessionId,y=r.serverUrl,v=r.signedRequest;return t._establish({accessToken:m,refreshToken:g,instanceUrl:i,sessionId:b,serverUrl:y,signedRequest:v}),lt.A.emit("connection:new",t),t}return(0,L.A)(e,t),(0,I.A)(e,[{key:"analytics",get:function(){return Jt("analytics")}},{key:"apex",get:function(){return Jt("apex")}},{key:"bulk",get:function(){return Jt("bulk")}},{key:"bulk2",get:function(){return Jt("bulk2")}},{key:"chatter",get:function(){return Jt("chatter")}},{key:"metadata",get:function(){return Jt("metadata")}},{key:"soap",get:function(){return Jt("soap")}},{key:"streaming",get:function(){return Jt("streaming")}},{key:"tooling",get:function(){return Jt("tooling")}},{key:"_establish",value:function(t){var e,r=t.accessToken,n=t.refreshToken,i=t.instanceUrl,o=t.sessionId,s=t.serverUrl,a=t.signedRequest,u=t.userInfo;if(this.instanceUrl=s?z()(e=s.split("/")).call(e,0,3).join("/"):i||this.instanceUrl,this.accessToken=o||r||this.accessToken,this.refreshToken=n||this.refreshToken,this.refreshToken&&!this._refreshDelegate)throw new Error("Refresh token is specified without oauth2 client information or refresh function");var l=a&&function(t){if("string"==typeof t){if(q()(t).call(t,"{"))return JSON.parse(t);var e=t.split(".").pop();if(!e)throw new Error("Invalid signed request");var r=Rt.from(e,"base64").toString("utf-8");return JSON.parse(r)}return t}(a);l&&(this.accessToken=l.client.oauthToken,ct.m5.supported&&(this._transport=new ct.m5(l))),this.userInfo=u||this.userInfo,this._sessionType=o?"soap":"oauth2",this._resetInstance()}},{key:"_clearSession",value:function(){this.accessToken=null,this.refreshToken=null,this.instanceUrl=zt,this.userInfo=null,this._sessionType=null}},{key:"_resetInstance",value:function(){var t=this;this.limitInfo={},this.sobjects={},this.cache.clear(),this.cache.get("describeGlobal").removeAllListeners("value"),this.cache.get("describeGlobal").on("value",(function(e){var r=e.result;if(r){var n,i=Nt(r.sobjects);try{for(i.s();!(n=i.n()).done;){var o=n.value;t.sobject(o.name)}}catch(t){i.e(t)}finally{i.f()}}}))}},{key:"authorize",value:(Z=(0,N.A)(B().mark((function t(e){var r,n,i,o,s=arguments;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:{},t.next=3,this.oauth2.requestToken(e,n);case 3:return i=t.sent,o=Kt(i.id),this._establish({instanceUrl:i.instance_url,accessToken:i.access_token,refreshToken:i.refresh_token,userInfo:o}),this._logger.debug(H()(r="<login> completed. user id = ".concat(o.id,", org id = ")).call(r,o.organizationId)),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t,this)}))),function(t){return Z.apply(this,arguments)})},{key:"login",value:($=(0,N.A)(B().mark((function t(e,r){var n;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._refreshDelegate=new yt(this,Zt(e,r)),null===(n=this.oauth2)||void 0===n||!n.clientId||!this.oauth2.clientSecret){t.next=3;break}return t.abrupt("return",this.loginByOAuth2(e,r));case 3:return t.abrupt("return",this.loginBySoap(e,r));case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return $.apply(this,arguments)})},{key:"loginByOAuth2",value:(G=(0,N.A)(B().mark((function t(e,r){var n,i,o;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.oauth2.authenticate(e,r);case 2:return i=t.sent,o=Kt(i.id),this._establish({instanceUrl:i.instance_url,accessToken:i.access_token,userInfo:o}),this._logger.info(H()(n="<login> completed. user id = ".concat(o.id,", org id = ")).call(n,o.organizationId)),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return G.apply(this,arguments)})},{key:"loginBySoap",value:(W=(0,N.A)(B().mark((function t(e,r){var n,i,o,s,a,u,l,c,h,f,p,d,m;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._logger.warn("DEPRECATION WARNING: The SOAP login() API will be retired in Summer '27 (API version 65.0). Please use OAuth 2.0 Username-Password Flow instead. For more information, see https://help.salesforce.com/s/articleView?id=release-notes.rn_api_upcoming_retirement_258rn.htm&release=258&type=5"),e&&r){t.next=3;break}return t.abrupt("return",K().reject(new Error("no username password given")));case 3:return o=['<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/">',"<se:Header/>","<se:Body>",'<login xmlns="urn:partner.soap.sforce.com">',"<username>".concat(Gt(e),"</username>"),"<password>".concat(Gt(r),"</password>"),"</login>","</se:Body>","</se:Envelope>"].join(""),s=[this.loginUrl,"services/Soap/u",this.version].join("/"),t.next=7,this._transport.httpRequest({method:"POST",url:s,body:o,headers:{"Content-Type":"text/xml",SOAPAction:'""'}});case 7:if(!((a=t.sent).statusCode>=400)){t.next=12;break}throw u=a.body.match(/<faultstring>([^<]+)<\/faultstring>/),l=u&&u[1],new Error(l||a.body);case 12:if(!a.body.match(/<passwordExpired>true<\/passwordExpired>/g)){t.next=14;break}throw new Error("Unable to login because the used password has expired.");case 14:if(this._logger.debug("SOAP response = ".concat(a.body)),u=a.body.match(/<serverUrl>([^<]+)<\/serverUrl>/),c=u&&u[1],u=a.body.match(/<sessionId>([^<]+)<\/sessionId>/),h=u&&u[1],u=a.body.match(/<userId>([^<]+)<\/userId>/),f=u&&u[1],u=a.body.match(/<organizationId>([^<]+)<\/organizationId>/),p=u&&u[1],c&&h&&f&&p){t.next=25;break}throw new Error("could not extract session information from login response");case 25:return d=[this.loginUrl,"id",p,f].join("/"),m={id:f,organizationId:p,url:d},this._establish({serverUrl:z()(n=c.split("/")).call(n,0,3).join("/"),sessionId:h,userInfo:m}),this._logger.info(H()(i="<login> completed. user id = ".concat(f,", org id = ")).call(i,p)),t.abrupt("return",m);case 30:case"end":return t.stop()}}),t,this)}))),function(t,e){return W.apply(this,arguments)})},{key:"logout",value:(V=(0,N.A)(B().mark((function t(e){return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._refreshDelegate=void 0,"oauth2"!==this._sessionType){t.next=3;break}return t.abrupt("return",this.logoutByOAuth2(e));case 3:return t.abrupt("return",this.logoutBySoap(e));case 4:case"end":return t.stop()}}),t,this)}))),function(t){return V.apply(this,arguments)})},{key:"logoutByOAuth2",value:(U=(0,N.A)(B().mark((function t(e){var r;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=e?this.refreshToken:this.accessToken)){t.next=4;break}return t.next=4,this.oauth2.revokeToken(r);case 4:this._clearSession(),this._resetInstance();case 6:case"end":return t.stop()}}),t,this)}))),function(t){return U.apply(this,arguments)})},{key:"logoutBySoap",value:(j=(0,N.A)(B().mark((function t(e){var r,n,i,o,s;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=['<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/">',"<se:Header>",'<SessionHeader xmlns="urn:partner.soap.sforce.com">',"<sessionId>".concat(Gt(e?this.refreshToken:this.accessToken),"</sessionId>"),"</SessionHeader>","</se:Header>","<se:Body>",'<logout xmlns="urn:partner.soap.sforce.com"/>',"</se:Body>","</se:Envelope>"].join(""),t.next=3,this._transport.httpRequest({method:"POST",url:[this.instanceUrl,"services/Soap/u",this.version].join("/"),body:n,headers:{"Content-Type":"text/xml",SOAPAction:'""'}});case 3:if(i=t.sent,this._logger.debug(H()(r="SOAP statusCode = ".concat(i.statusCode,", response = ")).call(r,i.body)),!(i.statusCode>=400)){t.next=9;break}throw o=i.body.match(/<faultstring>([^<]+)<\/faultstring>/),s=o&&o[1],new Error(s||i.body);case 9:this._clearSession(),this._resetInstance();case 11:case"end":return t.stop()}}),t,this)}))),function(t){return j.apply(this,arguments)})},{key:"request",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"==typeof t?{method:"GET",url:t}:t;n=Bt(Bt({},n),{},{url:this._normalizeUrl(n.url)});var i=new dt.Ay(this,r);return i.on("response",(function(t){if(t.headers&&t.headers["sforce-limit-info"]){var r=t.headers["sforce-limit-info"].match(/api-usage=(\d+)\/(\d+)/);r&&(e.limitInfo={apiUsage:{used:Q()(r[1],10),limit:Q()(r[2],10)}})}})),i.request(n)}},{key:"requestGet",value:function(t,e){var r={method:"GET",url:t};return this.request(r,e)}},{key:"requestPost",value:function(t,e,r){var n={method:"POST",url:t,body:X()(e),headers:{"content-type":"application/json"}};return this.request(n,r)}},{key:"requestPut",value:function(t,e,r){var n={method:"PUT",url:t,body:X()(e),headers:{"content-type":"application/json"}};return this.request(n,r)}},{key:"requestPatch",value:function(t,e,r){var n={method:"PATCH",url:t,body:X()(e),headers:{"content-type":"application/json"}};return this.request(n,r)}},{key:"requestDelete",value:function(t,e){var r={method:"DELETE",url:t};return this.request(r,e)}},{key:"_baseUrl",value:function(){return[this.instanceUrl,"services/data","v".concat(this.version)].join("/")}},{key:"_normalizeUrl",value:function(t){return q()(t).call(t,"/")?q()(t).call(t,this.instanceUrl+"/services/")?t:q()(t).call(t,"/services/")?this.instanceUrl+t:this._baseUrl()+t:t}},{key:"query",value:function(t,e){return new vt.Ay(this,t,e)}},{key:"search",value:function(t){var e=this._baseUrl()+"/search?q="+encodeURIComponent(t);return this.request(e)}},{key:"queryMore",value:function(t,e){return new vt.Ay(this,{locator:t},e)}},{key:"_ensureVersion",value:function(t){var e=this.version.split(".");return Q()(e[0],10)>=t}},{key:"_supports",value:function(t){return"sobject-collection"===t&&this._ensureVersion(42)}},{key:"retrieve",value:(P=(0,N.A)(B().mark((function t(e,r){var n,i=arguments;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:{},t.abrupt("return",Y()(r)?this._ensureVersion(42)?this._retrieveMany(e,r,n):this._retrieveParallel(e,r,n):this._retrieveSingle(e,r,n));case 2:case"end":return t.stop()}}),t,this)}))),function(t,e){return P.apply(this,arguments)})},{key:"_retrieveSingle",value:(O=(0,N.A)(B().mark((function t(e,r,n){var i,o,s;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}throw new Error("Invalid record ID. Specify valid record ID value");case 2:return i=[this._baseUrl(),"sobjects",e,r].join("/"),o=n.fields,s=n.headers,o&&(i+="?fields=".concat(o.join(","))),t.abrupt("return",this.request({method:"GET",url:i,headers:s}));case 6:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return O.apply(this,arguments)})},{key:"_retrieveParallel",value:(T=(0,N.A)(B().mark((function t(e,r,n){var i=this;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r.length>this._maxRequest)){t.next=2;break}throw new Error("Exceeded max limit of concurrent call");case 2:return t.abrupt("return",K().all(et()(r).call(r,(function(t){return i._retrieveSingle(e,t,n).catch((function(t){if(n.allOrNone||"NOT_FOUND"!==t.errorCode)throw t;return null}))}))));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return T.apply(this,arguments)})},{key:"_retrieveMany",value:(E=(0,N.A)(B().mark((function t(e,r,n){var i,o,s;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==r.length){t.next=2;break}return t.abrupt("return",[]);case 2:if(o=[this._baseUrl(),"composite","sobjects",e].join("/"),t.t0=n.fields,t.t0){t.next=10;break}return t.t1=et(),t.next=8,this.describe$(e);case 8:t.t2=i=t.sent.fields,t.t0=(0,t.t1)(t.t2).call(i,(function(t){return t.name}));case 10:return s=t.t0,t.abrupt("return",this.request({method:"POST",url:o,body:X()({ids:r,fields:s}),headers:Bt(Bt({},n.headers||{}),{},{"content-type":"application/json"})}));case 12:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return E.apply(this,arguments)})},{key:"create",value:(x=(0,N.A)(B().mark((function t(e,r){var n,i,o=arguments;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:{},!Y()(r)){t.next=14;break}if(!this._ensureVersion(42)){t.next=8;break}return t.next=5,this._createMany(e,r,n);case 5:t.t1=t.sent,t.next=11;break;case 8:return t.next=10,this._createParallel(e,r,n);case 10:t.t1=t.sent;case 11:t.t0=t.t1,t.next=17;break;case 14:return t.next=16,this._createSingle(e,r,n);case 16:t.t0=t.sent;case 17:return i=t.t0,t.abrupt("return",i);case 19:case"end":return t.stop()}}),t,this)}))),function(t,e){return x.apply(this,arguments)})},{key:"_createSingle",value:(A=(0,N.A)(B().mark((function t(e,r,n){var i,o,s,a,u,l,c,h,f;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r.Id,i=r.type,o=r.attributes,s=(0,C.A)(r,It),a=e||(null==o?void 0:o.type)||i){t.next=4;break}throw new Error("No SObject Type defined in record");case 4:return u=[this._baseUrl(),"sobjects",a].join("/"),null!=n&&n.multipartFileFields?(f=new(Ct()),nt()(h=ot()(n.multipartFileFields)).call(h,(function(t){var e=(0,F.A)(t,2),r=e[0],n=e[1];f.append(r,Rt.from(s[r],"base64"),n),delete s[r]})),f.append(e,X()(s),{contentType:"application/json"}),l=f.getHeaders()["content-type"],c=f):(l="application/json",c=X()(s)),t.abrupt("return",this.request({method:"POST",url:u,body:c,headers:Bt(Bt({},n.headers||{}),{},{"content-type":l})}));case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return A.apply(this,arguments)})},{key:"_createParallel",value:(S=(0,N.A)(B().mark((function t(e,r,n){var i=this;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r.length>this._maxRequest)){t.next=2;break}throw new Error("Exceeded max limit of concurrent call");case 2:return t.abrupt("return",K().all(et()(r).call(r,(function(t){return i._createSingle(e,t,n).catch((function(t){if(n.allOrNone||!t.errorCode)throw t;return Xt(t)}))}))));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return S.apply(this,arguments)})},{key:"_createMany",value:(M=(0,N.A)(B().mark((function t(e,r,n){var i,o,s;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==r.length){t.next=2;break}return t.abrupt("return",K().resolve([]));case 2:if(!(r.length>Yt&&n.allowRecursive)){t.next=16;break}return t.t0=H()(i=[]),t.t1=i,t.t2=k.A,t.next=8,this._createMany(e,z()(r).call(r,0,Yt),n);case 8:return t.t3=t.sent,t.t4=(0,t.t2)(t.t3),t.t5=k.A,t.next=13,this._createMany(e,z()(r).call(r,Yt),n);case 13:return t.t6=t.sent,t.t7=(0,t.t5)(t.t6),t.abrupt("return",t.t0.call.call(t.t0,t.t1,t.t4,t.t7));case 16:return o=et()(r).call(r,(function(t){t.Id;var r=t.type,n=t.attributes,i=(0,C.A)(t,Ot),o=e||(null==n?void 0:n.type)||r;if(!o)throw new Error("No SObject Type defined in record");return Bt({attributes:{type:o}},i)})),s=[this._baseUrl(),"composite","sobjects"].join("/"),t.abrupt("return",this.request({method:"POST",url:s,body:X()({allOrNone:n.allOrNone||!1,records:o}),headers:Bt(Bt({},n.headers||{}),{},{"content-type":"application/json"})}));case 19:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return M.apply(this,arguments)})},{key:"update",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Y()(e)?this._ensureVersion(42)?this._updateMany(t,e,r):this._updateParallel(t,e,r):this._updateSingle(t,e,r)}},{key:"_updateSingle",value:(_=(0,N.A)(B().mark((function t(e,r,n){var i,o,s,a,u,l;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=r.Id,o=r.type,s=r.attributes,a=(0,C.A)(r,Pt),i){t.next=3;break}throw new Error("Record id is not found in record.");case 3:if(u=e||(null==s?void 0:s.type)||o){t.next=6;break}throw new Error("No SObject Type defined in record");case 6:return l=[this._baseUrl(),"sobjects",u,i].join("/"),t.abrupt("return",this.request({method:"PATCH",url:l,body:X()(a),headers:Bt(Bt({},n.headers||{}),{},{"content-type":"application/json"})},{noContentResponse:{id:i,success:!0,errors:[]}}));case 8:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return _.apply(this,arguments)})},{key:"_updateParallel",value:(w=(0,N.A)(B().mark((function t(e,r,n){var i=this;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r.length>this._maxRequest)){t.next=2;break}throw new Error("Exceeded max limit of concurrent call");case 2:return t.abrupt("return",K().all(et()(r).call(r,(function(t){return i._updateSingle(e,t,n).catch((function(t){if(n.allOrNone||!t.errorCode)throw t;return Xt(t)}))}))));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return w.apply(this,arguments)})},{key:"_updateMany",value:(v=(0,N.A)(B().mark((function t(e,r,n){var i,o,s;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==r.length){t.next=2;break}return t.abrupt("return",[]);case 2:if(!(r.length>Yt&&n.allowRecursive)){t.next=16;break}return t.t0=H()(i=[]),t.t1=i,t.t2=k.A,t.next=8,this._updateMany(e,z()(r).call(r,0,Yt),n);case 8:return t.t3=t.sent,t.t4=(0,t.t2)(t.t3),t.t5=k.A,t.next=13,this._updateMany(e,z()(r).call(r,Yt),n);case 13:return t.t6=t.sent,t.t7=(0,t.t5)(t.t6),t.abrupt("return",t.t0.call.call(t.t0,t.t1,t.t4,t.t7));case 16:return o=et()(r).call(r,(function(t){var r=t.Id,n=t.type,i=t.attributes,o=(0,C.A)(t,Lt);if(!r)throw new Error("Record id is not found in record.");var s=e||(null==i?void 0:i.type)||n;if(!s)throw new Error("No SObject Type defined in record");return Bt({id:r,attributes:{type:s}},o)})),s=[this._baseUrl(),"composite","sobjects"].join("/"),t.abrupt("return",this.request({method:"PATCH",url:s,body:X()({allOrNone:n.allOrNone||!1,records:o}),headers:Bt(Bt({},n.headers||{}),{},{"content-type":"application/json"})}));case 19:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return v.apply(this,arguments)})},{key:"upsert",value:(y=(0,N.A)(B().mark((function t(e,r,n){var i,o=arguments;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=o.length>3&&void 0!==o[3]?o[3]:{},t.abrupt("return",Y()(r)&&this._ensureVersion(46)?this._upsertMany(e,r,n,i):this._upsertParallel(e,r,n,i));case 2:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return y.apply(this,arguments)})},{key:"_upsertMany",value:(b=(0,N.A)(B().mark((function t(e,r,n){var i,o,s,a,u=arguments;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=u.length>3&&void 0!==u[3]?u[3]:{},0!==r.length){t.next=3;break}return t.abrupt("return",[]);case 3:if(!(r.length>Yt&&i.allowRecursive)){t.next=17;break}return t.t0=H()(o=[]),t.t1=o,t.t2=k.A,t.next=9,this._upsertMany(e,z()(r).call(r,0,Yt),n,i);case 9:return t.t3=t.sent,t.t4=(0,t.t2)(t.t3),t.t5=k.A,t.next=14,this._upsertMany(e,z()(r).call(r,Yt),n,i);case 14:return t.t6=t.sent,t.t7=(0,t.t5)(t.t6),t.abrupt("return",t.t0.call.call(t.t0,t.t1,t.t4,t.t7));case 17:return s=et()(r).call(r,(function(t){var r,i=t[n],o=t.type,s=t.attributes,a=(0,C.A)(t,et()(r=[n,"type","attributes"]).call(r,Dt)),u=o||(null==s?void 0:s.type)||e;if(!i)throw new Error("External ID is not found in record.");if(!u)throw new Error("No SObject Type defined in record");return Bt((0,D.A)((0,D.A)({},n,i),"attributes",{type:u}),a)})),a=[this._baseUrl(),"composite","sobjects",e,n].join("/"),t.abrupt("return",this.request({method:"PATCH",url:a,body:X()({allOrNone:i.allOrNone||!1,records:s}),headers:Bt(Bt({},i.headers||{}),{},{"content-type":"application/json"})}));case 20:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return b.apply(this,arguments)})},{key:"_upsertParallel",value:(g=(0,N.A)(B().mark((function t(e,r,n){var i,o,s,a,u=this,l=arguments;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=l.length>3&&void 0!==l[3]?l[3]:{},o=Y()(r),!((s=Y()(r)?r:[r]).length>this._maxRequest)){t.next=5;break}throw new Error("Exceeded max limit of concurrent call");case 5:return t.next=7,K().all(et()(s).call(s,(function(t){var r,s=t[n],a=(t.type,t.attributes,(0,C.A)(t,et()(r=[n,"type","attributes"]).call(r,Dt))),l=[u._baseUrl(),"sobjects",e,n,s].join("/");return u.request({method:"PATCH",url:l,body:X()(a),headers:Bt(Bt({},i.headers||{}),{},{"content-type":"application/json"})},{noContentResponse:{success:!0,errors:[]}}).catch((function(t){if(!o||i.allOrNone||!t.errorCode)throw t;return Xt(t)}))})));case 7:return a=t.sent,t.abrupt("return",o?a:a[0]);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return g.apply(this,arguments)})},{key:"destroy",value:(m=(0,N.A)(B().mark((function t(e,r){var n,i=arguments;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:{},t.abrupt("return",Y()(r)?this._ensureVersion(42)?this._destroyMany(e,r,n):this._destroyParallel(e,r,n):this._destroySingle(e,r,n));case 2:case"end":return t.stop()}}),t,this)}))),function(t,e){return m.apply(this,arguments)})},{key:"_destroySingle",value:(d=(0,N.A)(B().mark((function t(e,r,n){var i;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=[this._baseUrl(),"sobjects",e,r].join("/"),t.abrupt("return",this.request({method:"DELETE",url:i,headers:n.headers||{}},{noContentResponse:{id:r,success:!0,errors:[]}}));case 2:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return d.apply(this,arguments)})},{key:"_destroyParallel",value:(p=(0,N.A)(B().mark((function t(e,r,n){var i=this;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r.length>this._maxRequest)){t.next=2;break}throw new Error("Exceeded max limit of concurrent call");case 2:return t.abrupt("return",K().all(et()(r).call(r,(function(t){return i._destroySingle(e,t,n).catch((function(t){if(n.allOrNone||!t.errorCode)throw t;return Xt(t)}))}))));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return p.apply(this,arguments)})},{key:"_destroyMany",value:(f=(0,N.A)(B().mark((function t(e,r,n){var i,o;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==r.length){t.next=2;break}return t.abrupt("return",[]);case 2:if(!(r.length>Yt&&n.allowRecursive)){t.next=16;break}return t.t0=H()(i=[]),t.t1=i,t.t2=k.A,t.next=8,this._destroyMany(e,z()(r).call(r,0,Yt),n);case 8:return t.t3=t.sent,t.t4=(0,t.t2)(t.t3),t.t5=k.A,t.next=13,this._destroyMany(e,z()(r).call(r,Yt),n);case 13:return t.t6=t.sent,t.t7=(0,t.t5)(t.t6),t.abrupt("return",t.t0.call.call(t.t0,t.t1,t.t4,t.t7));case 16:return o=[this._baseUrl(),"composite","sobjects?ids="].join("/")+r.join(","),n.allOrNone&&(o+="&allOrNone=true"),t.abrupt("return",this.request({method:"DELETE",url:o,headers:n.headers||{}}));case 19:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return f.apply(this,arguments)})},{key:"describe",value:(h=(0,N.A)(B().mark((function t(e){var r,n;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[this._baseUrl(),"sobjects",e,"describe"].join("/"),t.next=3,this.request(r);case 3:return n=t.sent,t.abrupt("return",n);case 5:case"end":return t.stop()}}),t,this)}))),function(t){return h.apply(this,arguments)})},{key:"describeGlobal",value:(c=(0,N.A)(B().mark((function t(){var e,r;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e="".concat(this._baseUrl(),"/sobjects"),t.next=3,this.request(e);case 3:return r=t.sent,t.abrupt("return",r);case 5:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"sobject",value:function(t){var e=this.sobjects[t]||new wt.A(this,t);return this.sobjects[t]=e,e}},{key:"identity",value:(l=(0,N.A)(B().mark((function t(){var e,r,n,i,o,s=arguments;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>0&&void 0!==s[0]?s[0]:{},n=null===(e=this.userInfo)||void 0===e?void 0:e.url){t.next=7;break}return t.next=5,this.request({method:"GET",url:this._baseUrl(),headers:r.headers});case 5:i=t.sent,n=i.identity;case 7:return n+="?format=json",this.accessToken&&(n+="&oauth_token=".concat(encodeURIComponent(this.accessToken))),t.next=11,this.request({method:"GET",url:n});case 11:return o=t.sent,this.userInfo={id:o.user_id,organizationId:o.organization_id,url:o.id},t.abrupt("return",o);case 14:case"end":return t.stop()}}),t,this)}))),function(){return l.apply(this,arguments)})},{key:"recent",value:(u=(0,N.A)(B().mark((function t(e,r){var n,i,o;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("number"==typeof e&&(r=e,e=void 0),!e){t.next=8;break}return n=[this._baseUrl(),"sobjects",e].join("/"),t.next=5,this.request(n);case 5:return i=t.sent,o=i.recentItems,t.abrupt("return",r?z()(o).call(o,0,r):o);case 8:return n="".concat(this._baseUrl(),"/recent"),r&&(n+="?limit=".concat(r)),t.abrupt("return",this.request(n));case 11:case"end":return t.stop()}}),t,this)}))),function(t,e){return u.apply(this,arguments)})},{key:"updated",value:(a=(0,N.A)(B().mark((function t(e,r,n){var i,o;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=[this._baseUrl(),"sobjects",e,"updated"].join("/"),"string"==typeof r&&(r=new Date(r)),r=(0,Tt.Y)(r),i+="?start=".concat(encodeURIComponent(r)),"string"==typeof n&&(n=new Date(n)),n=(0,Tt.Y)(n),i+="&end=".concat(encodeURIComponent(n)),t.next=9,this.request(i);case 9:return o=t.sent,t.abrupt("return",o);case 11:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return a.apply(this,arguments)})},{key:"deleted",value:(s=(0,N.A)(B().mark((function t(e,r,n){var i,o;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=[this._baseUrl(),"sobjects",e,"deleted"].join("/"),"string"==typeof r&&(r=new Date(r)),r=(0,Tt.Y)(r),i+="?start=".concat(encodeURIComponent(r)),"string"==typeof n&&(n=new Date(n)),n=(0,Tt.Y)(n),i+="&end=".concat(encodeURIComponent(n)),t.next=9,this.request(i);case 9:return o=t.sent,t.abrupt("return",o);case 11:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return s.apply(this,arguments)})},{key:"tabs",value:(o=(0,N.A)(B().mark((function t(){var e,r;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[this._baseUrl(),"tabs"].join("/"),t.next=3,this.request(e);case 3:return r=t.sent,t.abrupt("return",r);case 5:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"limits",value:(i=(0,N.A)(B().mark((function t(){var e,r;return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=[this._baseUrl(),"limits"].join("/"),t.next=3,this.request(e);case 3:return r=t.sent,t.abrupt("return",r);case 5:case"end":return t.stop()}}),