@plasmicapp/data-sources
Advanced tools
Comparing version 0.1.117 to 0.1.119
@@ -360,7 +360,9 @@ 'use strict'; | ||
var _executePlasmicDataOp2, _executePlasmicDataOp3; | ||
var DEFAULT_HOST = 'https://data.plasmic.app'; | ||
var UNAUTHORIZED_MESSAGE = 'You do not have permission to perform this operation. Login to get access or contact the app owner to get access.'; | ||
function executePlasmicDataOp(_x, _x2) { | ||
return (_executePlasmicDataOp2 = _executePlasmicDataOp2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(op, opts) { | ||
return _executePlasmicDataOp2.apply(this, arguments); | ||
} | ||
function _executePlasmicDataOp2() { | ||
_executePlasmicDataOp2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(op, opts) { | ||
var func, res; | ||
@@ -381,6 +383,10 @@ return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
}, _callee); | ||
}))).apply(this, arguments); | ||
})); | ||
return _executePlasmicDataOp2.apply(this, arguments); | ||
} | ||
function _executePlasmicDataOp(_x3, _x4) { | ||
return (_executePlasmicDataOp3 = _executePlasmicDataOp3 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(op, opts) { | ||
return _executePlasmicDataOp3.apply(this, arguments); | ||
} | ||
function _executePlasmicDataOp3() { | ||
_executePlasmicDataOp3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(op, opts) { | ||
var _op$userArgs; | ||
@@ -439,3 +445,4 @@ var host, url, resp, text; | ||
}, _callee2); | ||
}))).apply(this, arguments); | ||
})); | ||
return _executePlasmicDataOp3.apply(this, arguments); | ||
} | ||
@@ -567,5 +574,5 @@ function getConfig(key, defaultValue) { | ||
var enableLoadingBoundary = !!(ph.useDataEnv != null && (_ph$useDataEnv = ph.useDataEnv()) != null && _ph$useDataEnv[enableLoadingBoundaryKey]); | ||
var _usePlasmicDataConfig = query.usePlasmicDataConfig(), | ||
mutate = _usePlasmicDataConfig.mutate, | ||
cache = _usePlasmicDataConfig.cache; | ||
var _usePlasmicDataConfig2 = query.usePlasmicDataConfig(), | ||
mutate = _usePlasmicDataConfig2.mutate, | ||
cache = _usePlasmicDataConfig2.cache; | ||
// Cannot perform this operation | ||
@@ -705,10 +712,3 @@ var isNullDataOp = !resolvedDataOp; | ||
var res = query.useMutablePlasmicQueryData(key, fetcher, { | ||
shouldRetryOnError: false, | ||
// If revalidateIfStale is true, then if there's a cache entry with a key, | ||
// but no mounted hook with that key yet, and when the hook mounts with the key, | ||
// swr will revalidate. This may be reasonable behavior, but for us, this | ||
// happens all the time -- we prepopulate the cache with proxy-invoked fetch, | ||
// sometimes before swr had a chance to run the effect. So we turn off | ||
// revalidateIfStale here, and just let the user manage invalidation. | ||
revalidateIfStale: false | ||
shouldRetryOnError: false | ||
}); | ||
@@ -735,79 +735,81 @@ var data = res.data, | ||
var userToken = ctx == null ? void 0 : ctx.userAuthToken; | ||
var getRealDataOp = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
var _ref2; | ||
var getRealDataOp = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { | ||
var tryGetRealDataOp; | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
tryGetRealDataOp = function tryGetRealDataOp() { | ||
return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
tryGetRealDataOp = /*#__PURE__*/function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
var resolved; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
resolved = resolveDataOp(dataOp); | ||
if (resolved) { | ||
_context.next = 5; | ||
_context2.next = 5; | ||
break; | ||
} | ||
return _context.abrupt("return", null); | ||
return _context2.abrupt("return", null); | ||
case 5: | ||
if (!isPlasmicUndefinedDataErrorPromise(resolved)) { | ||
_context.next = 11; | ||
_context2.next = 11; | ||
break; | ||
} | ||
_context.next = 8; | ||
_context2.next = 8; | ||
return resolved; | ||
case 8: | ||
return _context.abrupt("return", tryGetRealDataOp()); | ||
return _context2.abrupt("return", tryGetRealDataOp()); | ||
case 11: | ||
return _context.abrupt("return", resolved); | ||
return _context2.abrupt("return", resolved); | ||
case 12: | ||
case "end": | ||
return _context.stop(); | ||
return _context2.stop(); | ||
} | ||
}, _callee); | ||
}))).apply(this, arguments); | ||
}; | ||
_context2.next = 3; | ||
}, _callee2); | ||
})); | ||
return function tryGetRealDataOp() { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}(); | ||
_context3.next = 3; | ||
return tryGetRealDataOp(); | ||
case 3: | ||
return _context2.abrupt("return", _context2.sent); | ||
return _context3.abrupt("return", _context3.sent); | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
}, _callee2); | ||
}, _callee3); | ||
})), [dataOp]); | ||
return React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { | ||
return React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { | ||
var _yield$getRealDataOp; | ||
var _ref4, sourceId, opId, userArgs; | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
var _ref5, sourceId, opId, userArgs; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context3.next = 2; | ||
_context4.next = 2; | ||
return getRealDataOp(); | ||
case 2: | ||
_context3.t0 = _yield$getRealDataOp = _context3.sent; | ||
if (!(_context3.t0 != null)) { | ||
_context3.next = 7; | ||
_context4.t0 = _yield$getRealDataOp = _context4.sent; | ||
if (!(_context4.t0 != null)) { | ||
_context4.next = 7; | ||
break; | ||
} | ||
_context3.t1 = _yield$getRealDataOp; | ||
_context3.next = 8; | ||
_context4.t1 = _yield$getRealDataOp; | ||
_context4.next = 8; | ||
break; | ||
case 7: | ||
_context3.t1 = {}; | ||
_context4.t1 = {}; | ||
case 8: | ||
_ref4 = _context3.t1; | ||
sourceId = _ref4.sourceId; | ||
opId = _ref4.opId; | ||
userArgs = _ref4.userArgs; | ||
_ref5 = _context4.t1; | ||
sourceId = _ref5.sourceId; | ||
opId = _ref5.opId; | ||
userArgs = _ref5.userArgs; | ||
if (!(!sourceId || !opId)) { | ||
_context3.next = 14; | ||
_context4.next = 14; | ||
break; | ||
} | ||
return _context3.abrupt("return", undefined); | ||
return _context4.abrupt("return", undefined); | ||
case 14: | ||
return _context3.abrupt("return", executePlasmicDataOp({ | ||
return _context4.abrupt("return", executePlasmicDataOp({ | ||
sourceId: sourceId, | ||
@@ -822,5 +824,5 @@ opId: opId, | ||
case "end": | ||
return _context3.stop(); | ||
return _context4.stop(); | ||
} | ||
}, _callee3); | ||
}, _callee4); | ||
})), [getRealDataOp, userToken]); | ||
@@ -827,0 +829,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t,r,n=require("@plasmicapp/query"),o=e(require("react")),a=require("@plasmicapp/data-sources-context"),i=require("@plasmicapp/host"),u=e(require("@plasmicapp/isomorphic-unfetch")),c=e(require("fast-stringify"));function s(){s=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=Object.create((t&&t.prototype instanceof g?t:g).prototype),i=new T(n||[]);return o(a,"_invoke",{value:O(e,r,i)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="executing",v="completed",y={};function g(){}function m(){}function w(){}var b={};l(b,i,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(_([])));P&&P!==r&&n.call(P,i)&&(b=P);var k=w.prototype=g.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function L(e,t){function r(o,a,i,u){var c=p(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function O(t,r,n){var o=h;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===v){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=A(u,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=p(t,r,n);if("normal"===s.type){if(o=n.done?v:"suspendedYield",s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function A(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function j(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function _(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=w,o(k,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=l(w,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,c,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},E(L.prototype),l(L.prototype,u,(function(){return this})),t.AsyncIterator=L,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new L(f(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(k),l(k,c,"Generator"),l(k,i,(function(){return this})),l(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=_,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(j),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return u.type="throw",u.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),j(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:_(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function l(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function f(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){l(a,n,o,i,u,"next",e)}function u(e){l(a,n,o,i,u,"throw",e)}i(void 0)}))}}function p(){return(p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var h="You do not have permission to perform this operation. Login to get access or contact the app owner to get access.";function d(e,r){return(t=t||f(s().mark((function e(t,r){var o;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=y("__PLASMIC_EXECUTE_DATA_OP",v),e.next=3,n.wrapLoadingFetcher(o)(t,r);case 3:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(e,t){return(r=r||f(s().mark((function e(t,r){var n,o,a,i;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.roleId){e.next=4;break}if(null!=r&&r.user&&r.user.roleIds.includes(t.roleId)){e.next=4;break}throw console.error(h),new Error(h);case 4:return o=y("__PLASMIC_DATA_HOST","https://data.plasmic.app"),a=o+"/api/v1/server-data/sources/"+t.sourceId+"/execute",e.next=8,u(a,{method:"POST",headers:p({"Content-Type":"application/json"},(null==r?void 0:r.userAuthToken)&&{"x-plasmic-data-user-auth-token":r.userAuthToken}),body:c({opId:t.opId,userArgs:null!=(n=t.userArgs)?n:{},paginate:null==r?void 0:r.paginate})});case 8:if(200===(i=e.sent).status){e.next=14;break}return e.next=12,i.text();case 12:throw new Error(e.sent);case 14:return e.next=16,i.json();case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(e,t){return"undefined"==typeof globalThis?t:null!=(r=globalThis[e])?r:t;var r}function g(e,t){var r=JSON.stringify({sourceId:e.sourceId,opId:e.opId,args:e.userArgs,userAuthToken:null==t?void 0:t.userAuthToken,paginate:null==t?void 0:t.paginate});return e.cacheKey?""+e.cacheKey+r:r}function m(e,t){return new Proxy({},{get:function(r,n){if("isPlasmicUndefinedDataProxy"===n)return!0;if(t){var o=e.fetchingPromise||t();throw o.plasmicType="PlasmicUndefinedDataError",o.message="Cannot read property "+String(n)+" - data is still loading",o}}})}function w(e){return!!e&&"object"==typeof e&&"PlasmicUndefinedDataError"===e.plasmicType}var b=+o.version.split(".")[0];function x(e){if("function"!=typeof e)return e;try{return e()}catch(e){return w(e)?e:null}}var P=new Map;function k(e,t){var r,u=x(e),c=a.usePlasmicDataSourceContext(),s=!(null==i.useDataEnv||null==(r=i.useDataEnv())||!r.plasmicInternalEnableLoadingBoundary),l=n.usePlasmicDataConfig(),f=l.mutate,h=l.cache,v=!u,y=w(u),k=!u||w(u)?null:g(u,{paginate:null==t?void 0:t.paginate,userAuthToken:null==c?void 0:c.userAuthToken}),E=o.useMemo((function(){return{fetchingPromise:void 0}}),[k]),L=o.useMemo((function(){return function(){if(!k)throw new Error("Fetcher should never be called without a proper key");if(E.fetchingPromise)return E.fetchingPromise;if(k&&P.has(k)){var e=P.get(k);return E.fetchingPromise=e,e}var r=d(u,{userAuthToken:(null==c?void 0:c.userAuthToken)||void 0,user:null==c?void 0:c.user,paginate:null==t?void 0:t.paginate});return E.fetchingPromise=r,k&&(P.set(k,r),r.then((function(){P.delete(k)}),(function(){P.delete(k)}))),r}}),[k,E]),O=w(u)?u:void 0,A=o.useMemo((function(){if(k||O)return function(){if(E.fetchingPromise)return E.fetchingPromise;if(O)return O;if(!k)throw new Error("Expected key to be non-null");var e=h.get(k);if(e)return Promise.resolve(e);var t=h.get("$swr$"+k);if(t)return Promise.reject(t.error);var r=new Promise((function(e,t){setTimeout((function(){L().then(e,t)}),1)}));return r.then((function(e){f(k,e)})).catch((function(e){var t,r=k?"$swr$"+k:"";h.set(r,p({},null!=(t=h.get(r))?t:{},{error:e}))})),r}}),[L,E,h,k,O]),I=n.useMutablePlasmicQueryData(k,L,{shouldRetryOnError:!1,revalidateIfStale:!1}),j=I.data,T=I.error,_=I.isLoading;return null!=E.fetchingPromise&&void 0!==j&&(E.fetchingPromise=void 0),o.useMemo((function(){var e=p({},null!=j?j:{},function(e){for(var t={},r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];for(var a=0,i=n;a<i.length;a++){var u=i[a];u in e&&(t[u]=e[u])}return t}(I,"isLoading","error"));return(null==t||!t.noUndefinedDataProxy)&&b>=18&&s&&(_||v||y)&&void 0===e.data&&void 0===e.schema&&void 0===e.error&&(e.data=m(E,A),e.schema=m(E,A)),e}),[v,y,j,T,_,null==t?void 0:t.noUndefinedDataProxy,s,E,A])}function E(e){return e.every((function(e){return"object"==typeof e&&!Array.isArray(e)}))}var L=function(){return""+Math.random()};Object.defineProperty(exports,"usePlasmicDataConfig",{enumerable:!0,get:function(){return n.usePlasmicDataConfig}}),exports.Fetcher=function(e){var t,r=e.children,n=e.name,a=e.pageIndex,i=e.pageSize,u=k(e.dataOp,p({},!!a&&!!i&&{paginate:{pageIndex:a,pageSize:i}})),c=o.useMemo((function(){var t;return p({},e.queries,((t={})[null!=n?n:"data"]=u,t))}),[e.queries,n,u]);return null!=(t=null==r?void 0:r(c))?t:null},exports.FetcherMeta={name:"plasmic-data-source-fetcher",displayName:"Data Fetcher",props:{dataOp:{type:"dataSourceOp",displayName:"Data"},name:{type:"string",displayName:"Variable name"},children:{type:"slot",renderPropParams:["$queries"]},pageSize:{type:"number",advanced:!0,displayName:"Page size",description:"Only fetch in batches of this size; for pagination"},pageIndex:{type:"number",advanced:!0,displayName:"Page index",description:"0-based index of the paginated page to fetch"}},importPath:"@plasmicapp/react-web/lib/data-sources",importName:"Fetcher",alwaysAutoName:!0,styleSections:!1},exports.deriveFieldConfigs=function(e,t,r){var n,o=null!=(n=null==t?void 0:t.fields)?n:[],a=new Map(o.map((function(e){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t}(e.id,e)}))),i=new Set(e.map((function(e){return e.fieldId})).filter((function(e){return null!=e}))),u=e.flatMap((function(e){if(!e.fieldId)return[p({key:L()},r(void 0),e)];var t=a.get(e.fieldId);return t?[p({key:L()},r(t),e)]:[]})),c=o.filter((function(e){return!i.has(e.id)})).map((function(e){return p({key:L()},r(e))}));return{mergedFields:[].concat(u,c),minimalFullLengthFields:[].concat(e,c.map((function(e){return{key:e.key,fieldId:e.fieldId}})))}},exports.executePlasmicDataOp=d,exports.makeCacheKey=g,exports.normalizeData=function(e){var t;if(e){var r=function(e){if(null!=e&&"object"==typeof e){if(Array.isArray(e))return E(e)?e:void 0;if(null!=e){if("data"in e&&"object"==typeof e.data)return Array.isArray(e.data)&&E(e.data)?e.data:null!=e.data?[e.data]:void 0;if(!("isLoading"in e)&&!("error"in e))return[e]}}}(e);if(r){var n,o=null!=(t=e.schema)?t:(n={},r.forEach((function(e){e&&"object"==typeof e&&Array.from(Object.entries(e)).forEach((function(e){var t=e[0],r=e[1],o="string"==typeof r?"string":"boolean"==typeof r?"boolean":"number"==typeof r?"number":"unknown";n[t]=n[t]&&n[t]!==o?"unknown":o}))})),{id:"inferred",fields:Object.entries(n).map((function(e){return{id:e[0],type:e[1],readOnly:!1}}))});if(o)return{data:r,schema:o}}}},exports.useDependencyAwareQuery=function(e){var t,r,n=e.$queries,a=e.setDollarQueries,i=e.name,u=e.pageIndex,c=e.pageSize,s=k(function(e){try{return e()}catch(e){return}}(e.getDataOp),p({},!!u&&!!c&&{paginate:{pageIndex:u,pageSize:c}})),l=null!=i?i:"data",f=(t=l,r=o.useRef(void 0),o.useEffect((function(){return r.current=t,function(){r.current=void 0}})),r.current);o.useEffect((function(){if(!(l in n)||n[l]!==s){var e,t=p({},n,((e={})[l]=s,e));f&&l!==f&&f in n&&delete t[f],a(t)}}),[l,f,s,n,a])},exports.usePlasmicDataMutationOp=function(e){var t=a.usePlasmicDataSourceContext(),r=null==t?void 0:t.userAuthToken,n=o.useCallback(f(s().mark((function t(){var r,n;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=function t(){return(r=r||f(s().mark((function r(){var n;return s().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=x(e)){r.next=5;break}return r.abrupt("return",null);case 5:if(!w(n)){r.next=11;break}return r.next=8,n;case 8:return r.abrupt("return",t());case 11:return r.abrupt("return",n);case 12:case"end":return r.stop()}}),r)})))).apply(this,arguments)},t.next=3,n();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),[e]);return o.useCallback(f(s().mark((function e(){var o,a,i,u,c;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n();case 2:if(e.t0=o=e.sent,null==e.t0){e.next=7;break}e.t1=o,e.next=8;break;case 7:e.t1={};case 8:if(u=(a=e.t1).opId,c=a.userArgs,(i=a.sourceId)&&u){e.next=14;break}return e.abrupt("return",void 0);case 14:return e.abrupt("return",d({sourceId:i,opId:u,userArgs:c},{userAuthToken:r||void 0,user:null==t?void 0:t.user}));case 15:case"end":return e.stop()}}),e)}))),[n,r])},exports.usePlasmicDataOp=k; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@plasmicapp/query"),r=e(require("react")),n=require("@plasmicapp/data-sources-context"),o=require("@plasmicapp/host"),a=e(require("@plasmicapp/isomorphic-unfetch")),i=e(require("fast-stringify"));function u(){u=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=Object.create((t&&t.prototype instanceof g?t:g).prototype),i=new T(n||[]);return o(a,"_invoke",{value:O(e,r,i)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="executing",v="completed",y={};function g(){}function m(){}function w(){}var b={};l(b,i,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(_([])));P&&P!==r&&n.call(P,i)&&(b=P);var k=w.prototype=g.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function L(e,t){function r(o,a,i,u){var c=p(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function O(t,r,n){var o=h;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===v){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=A(u,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=p(t,r,n);if("normal"===s.type){if(o=n.done?v:"suspendedYield",s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function A(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function j(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function _(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=w,o(k,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=l(w,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},E(L.prototype),l(L.prototype,c,(function(){return this})),t.AsyncIterator=L,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new L(f(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(k),l(k,s,"Generator"),l(k,i,(function(){return this})),l(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=_,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(j),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return u.type="throw",u.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),j(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:_(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function c(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){c(a,n,o,i,u,"next",e)}function u(e){c(a,n,o,i,u,"throw",e)}i(void 0)}))}}function l(){return(l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var f="You do not have permission to perform this operation. Login to get access or contact the app owner to get access.";function p(e,t){return h.apply(this,arguments)}function h(){return(h=s(u().mark((function e(r,n){var o;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=y("__PLASMIC_EXECUTE_DATA_OP",d),e.next=3,t.wrapLoadingFetcher(o)(r,n);case 3:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function d(e,t){return v.apply(this,arguments)}function v(){return(v=s(u().mark((function e(t,r){var n,o,c,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.roleId){e.next=4;break}if(null!=r&&r.user&&r.user.roleIds.includes(t.roleId)){e.next=4;break}throw console.error(f),new Error(f);case 4:return o=y("__PLASMIC_DATA_HOST","https://data.plasmic.app"),c=o+"/api/v1/server-data/sources/"+t.sourceId+"/execute",e.next=8,a(c,{method:"POST",headers:l({"Content-Type":"application/json"},(null==r?void 0:r.userAuthToken)&&{"x-plasmic-data-user-auth-token":r.userAuthToken}),body:i({opId:t.opId,userArgs:null!=(n=t.userArgs)?n:{},paginate:null==r?void 0:r.paginate})});case 8:if(200===(s=e.sent).status){e.next=14;break}return e.next=12,s.text();case 12:throw new Error(e.sent);case 14:return e.next=16,s.json();case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(e,t){return"undefined"==typeof globalThis?t:null!=(r=globalThis[e])?r:t;var r}function g(e,t){var r=JSON.stringify({sourceId:e.sourceId,opId:e.opId,args:e.userArgs,userAuthToken:null==t?void 0:t.userAuthToken,paginate:null==t?void 0:t.paginate});return e.cacheKey?""+e.cacheKey+r:r}function m(e,t){return new Proxy({},{get:function(r,n){if("isPlasmicUndefinedDataProxy"===n)return!0;if(t){var o=e.fetchingPromise||t();throw o.plasmicType="PlasmicUndefinedDataError",o.message="Cannot read property "+String(n)+" - data is still loading",o}}})}function w(e){return!!e&&"object"==typeof e&&"PlasmicUndefinedDataError"===e.plasmicType}var b=+r.version.split(".")[0];function x(e){if("function"!=typeof e)return e;try{return e()}catch(e){return w(e)?e:null}}var P=new Map;function k(e,a){var i,u=x(e),c=n.usePlasmicDataSourceContext(),s=!(null==o.useDataEnv||null==(i=o.useDataEnv())||!i.plasmicInternalEnableLoadingBoundary),f=t.usePlasmicDataConfig(),h=f.mutate,d=f.cache,v=!u,y=w(u),k=!u||w(u)?null:g(u,{paginate:null==a?void 0:a.paginate,userAuthToken:null==c?void 0:c.userAuthToken}),E=r.useMemo((function(){return{fetchingPromise:void 0}}),[k]),L=r.useMemo((function(){return function(){if(!k)throw new Error("Fetcher should never be called without a proper key");if(E.fetchingPromise)return E.fetchingPromise;if(k&&P.has(k)){var e=P.get(k);return E.fetchingPromise=e,e}var t=p(u,{userAuthToken:(null==c?void 0:c.userAuthToken)||void 0,user:null==c?void 0:c.user,paginate:null==a?void 0:a.paginate});return E.fetchingPromise=t,k&&(P.set(k,t),t.then((function(){P.delete(k)}),(function(){P.delete(k)}))),t}}),[k,E]),O=w(u)?u:void 0,A=r.useMemo((function(){if(k||O)return function(){if(E.fetchingPromise)return E.fetchingPromise;if(O)return O;if(!k)throw new Error("Expected key to be non-null");var e=d.get(k);if(e)return Promise.resolve(e);var t=d.get("$swr$"+k);if(t)return Promise.reject(t.error);var r=new Promise((function(e,t){setTimeout((function(){L().then(e,t)}),1)}));return r.then((function(e){h(k,e)})).catch((function(e){var t,r=k?"$swr$"+k:"";d.set(r,l({},null!=(t=d.get(r))?t:{},{error:e}))})),r}}),[L,E,d,k,O]),I=t.useMutablePlasmicQueryData(k,L,{shouldRetryOnError:!1}),j=I.data,T=I.error,_=I.isLoading;return null!=E.fetchingPromise&&void 0!==j&&(E.fetchingPromise=void 0),r.useMemo((function(){var e=l({},null!=j?j:{},function(e){for(var t={},r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];for(var a=0,i=n;a<i.length;a++){var u=i[a];u in e&&(t[u]=e[u])}return t}(I,"isLoading","error"));return(null==a||!a.noUndefinedDataProxy)&&b>=18&&s&&(_||v||y)&&void 0===e.data&&void 0===e.schema&&void 0===e.error&&(e.data=m(E,A),e.schema=m(E,A)),e}),[v,y,j,T,_,null==a?void 0:a.noUndefinedDataProxy,s,E,A])}function E(e){return e.every((function(e){return"object"==typeof e&&!Array.isArray(e)}))}var L=function(){return""+Math.random()};Object.defineProperty(exports,"usePlasmicDataConfig",{enumerable:!0,get:function(){return t.usePlasmicDataConfig}}),exports.Fetcher=function(e){var t,n=e.children,o=e.name,a=e.pageIndex,i=e.pageSize,u=k(e.dataOp,l({},!!a&&!!i&&{paginate:{pageIndex:a,pageSize:i}})),c=r.useMemo((function(){var t;return l({},e.queries,((t={})[null!=o?o:"data"]=u,t))}),[e.queries,o,u]);return null!=(t=null==n?void 0:n(c))?t:null},exports.FetcherMeta={name:"plasmic-data-source-fetcher",displayName:"Data Fetcher",props:{dataOp:{type:"dataSourceOp",displayName:"Data"},name:{type:"string",displayName:"Variable name"},children:{type:"slot",renderPropParams:["$queries"]},pageSize:{type:"number",advanced:!0,displayName:"Page size",description:"Only fetch in batches of this size; for pagination"},pageIndex:{type:"number",advanced:!0,displayName:"Page index",description:"0-based index of the paginated page to fetch"}},importPath:"@plasmicapp/react-web/lib/data-sources",importName:"Fetcher",alwaysAutoName:!0,styleSections:!1},exports.deriveFieldConfigs=function(e,t,r){var n,o=null!=(n=null==t?void 0:t.fields)?n:[],a=new Map(o.map((function(e){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t}(e.id,e)}))),i=new Set(e.map((function(e){return e.fieldId})).filter((function(e){return null!=e}))),u=e.flatMap((function(e){if(!e.fieldId)return[l({key:L()},r(void 0),e)];var t=a.get(e.fieldId);return t?[l({key:L()},r(t),e)]:[]})),c=o.filter((function(e){return!i.has(e.id)})).map((function(e){return l({key:L()},r(e))}));return{mergedFields:[].concat(u,c),minimalFullLengthFields:[].concat(e,c.map((function(e){return{key:e.key,fieldId:e.fieldId}})))}},exports.executePlasmicDataOp=p,exports.makeCacheKey=g,exports.normalizeData=function(e){var t;if(e){var r=function(e){if(null!=e&&"object"==typeof e){if(Array.isArray(e))return E(e)?e:void 0;if(null!=e){if("data"in e&&"object"==typeof e.data)return Array.isArray(e.data)&&E(e.data)?e.data:null!=e.data?[e.data]:void 0;if(!("isLoading"in e)&&!("error"in e))return[e]}}}(e);if(r){var n,o=null!=(t=e.schema)?t:(n={},r.forEach((function(e){e&&"object"==typeof e&&Array.from(Object.entries(e)).forEach((function(e){var t=e[0],r=e[1],o="string"==typeof r?"string":"boolean"==typeof r?"boolean":"number"==typeof r?"number":"unknown";n[t]=n[t]&&n[t]!==o?"unknown":o}))})),{id:"inferred",fields:Object.entries(n).map((function(e){return{id:e[0],type:e[1],readOnly:!1}}))});if(o)return{data:r,schema:o}}}},exports.useDependencyAwareQuery=function(e){var t,n,o=e.$queries,a=e.setDollarQueries,i=e.name,u=e.pageIndex,c=e.pageSize,s=k(function(e){try{return e()}catch(e){return}}(e.getDataOp),l({},!!u&&!!c&&{paginate:{pageIndex:u,pageSize:c}})),f=null!=i?i:"data",p=(t=f,n=r.useRef(void 0),r.useEffect((function(){return n.current=t,function(){n.current=void 0}})),n.current);r.useEffect((function(){if(!(f in o)||o[f]!==s){var e,t=l({},o,((e={})[f]=s,e));p&&f!==p&&p in o&&delete t[p],a(t)}}),[f,p,s,o,a])},exports.usePlasmicDataMutationOp=function(e){var t=n.usePlasmicDataSourceContext(),o=null==t?void 0:t.userAuthToken,a=r.useCallback(s(u().mark((function t(){var r;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=function(){var t=s(u().mark((function t(){var n;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=x(e)){t.next=5;break}return t.abrupt("return",null);case 5:if(!w(n)){t.next=11;break}return t.next=8,n;case 8:return t.abrupt("return",r());case 11:return t.abrupt("return",n);case 12:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),t.next=3,r();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),[e]);return r.useCallback(s(u().mark((function e(){var r,n,i,c,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a();case 2:if(e.t0=r=e.sent,null==e.t0){e.next=7;break}e.t1=r,e.next=8;break;case 7:e.t1={};case 8:if(c=(n=e.t1).opId,s=n.userArgs,(i=n.sourceId)&&c){e.next=14;break}return e.abrupt("return",void 0);case 14:return e.abrupt("return",p({sourceId:i,opId:c,userArgs:s},{userAuthToken:o||void 0,user:null==t?void 0:t.user}));case 15:case"end":return e.stop()}}),e)}))),[a,o])},exports.usePlasmicDataOp=k; | ||
//# sourceMappingURL=data-sources.cjs.production.min.js.map |
@@ -355,7 +355,9 @@ import { wrapLoadingFetcher, usePlasmicDataConfig, useMutablePlasmicQueryData } from '@plasmicapp/query'; | ||
var _executePlasmicDataOp2, _executePlasmicDataOp3; | ||
var DEFAULT_HOST = 'https://data.plasmic.app'; | ||
var UNAUTHORIZED_MESSAGE = 'You do not have permission to perform this operation. Login to get access or contact the app owner to get access.'; | ||
function executePlasmicDataOp(_x, _x2) { | ||
return (_executePlasmicDataOp2 = _executePlasmicDataOp2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(op, opts) { | ||
return _executePlasmicDataOp2.apply(this, arguments); | ||
} | ||
function _executePlasmicDataOp2() { | ||
_executePlasmicDataOp2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(op, opts) { | ||
var func, res; | ||
@@ -376,6 +378,10 @@ return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
}, _callee); | ||
}))).apply(this, arguments); | ||
})); | ||
return _executePlasmicDataOp2.apply(this, arguments); | ||
} | ||
function _executePlasmicDataOp(_x3, _x4) { | ||
return (_executePlasmicDataOp3 = _executePlasmicDataOp3 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(op, opts) { | ||
return _executePlasmicDataOp3.apply(this, arguments); | ||
} | ||
function _executePlasmicDataOp3() { | ||
_executePlasmicDataOp3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(op, opts) { | ||
var _op$userArgs; | ||
@@ -434,3 +440,4 @@ var host, url, resp, text; | ||
}, _callee2); | ||
}))).apply(this, arguments); | ||
})); | ||
return _executePlasmicDataOp3.apply(this, arguments); | ||
} | ||
@@ -562,5 +569,5 @@ function getConfig(key, defaultValue) { | ||
var enableLoadingBoundary = !!(useDataEnv != null && (_ph$useDataEnv = useDataEnv()) != null && _ph$useDataEnv[enableLoadingBoundaryKey]); | ||
var _usePlasmicDataConfig = usePlasmicDataConfig(), | ||
mutate = _usePlasmicDataConfig.mutate, | ||
cache = _usePlasmicDataConfig.cache; | ||
var _usePlasmicDataConfig2 = usePlasmicDataConfig(), | ||
mutate = _usePlasmicDataConfig2.mutate, | ||
cache = _usePlasmicDataConfig2.cache; | ||
// Cannot perform this operation | ||
@@ -700,10 +707,3 @@ var isNullDataOp = !resolvedDataOp; | ||
var res = useMutablePlasmicQueryData(key, fetcher, { | ||
shouldRetryOnError: false, | ||
// If revalidateIfStale is true, then if there's a cache entry with a key, | ||
// but no mounted hook with that key yet, and when the hook mounts with the key, | ||
// swr will revalidate. This may be reasonable behavior, but for us, this | ||
// happens all the time -- we prepopulate the cache with proxy-invoked fetch, | ||
// sometimes before swr had a chance to run the effect. So we turn off | ||
// revalidateIfStale here, and just let the user manage invalidation. | ||
revalidateIfStale: false | ||
shouldRetryOnError: false | ||
}); | ||
@@ -730,79 +730,81 @@ var data = res.data, | ||
var userToken = ctx == null ? void 0 : ctx.userAuthToken; | ||
var getRealDataOp = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
var _ref2; | ||
var getRealDataOp = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { | ||
var tryGetRealDataOp; | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
tryGetRealDataOp = function tryGetRealDataOp() { | ||
return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
tryGetRealDataOp = /*#__PURE__*/function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
var resolved; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
resolved = resolveDataOp(dataOp); | ||
if (resolved) { | ||
_context.next = 5; | ||
_context2.next = 5; | ||
break; | ||
} | ||
return _context.abrupt("return", null); | ||
return _context2.abrupt("return", null); | ||
case 5: | ||
if (!isPlasmicUndefinedDataErrorPromise(resolved)) { | ||
_context.next = 11; | ||
_context2.next = 11; | ||
break; | ||
} | ||
_context.next = 8; | ||
_context2.next = 8; | ||
return resolved; | ||
case 8: | ||
return _context.abrupt("return", tryGetRealDataOp()); | ||
return _context2.abrupt("return", tryGetRealDataOp()); | ||
case 11: | ||
return _context.abrupt("return", resolved); | ||
return _context2.abrupt("return", resolved); | ||
case 12: | ||
case "end": | ||
return _context.stop(); | ||
return _context2.stop(); | ||
} | ||
}, _callee); | ||
}))).apply(this, arguments); | ||
}; | ||
_context2.next = 3; | ||
}, _callee2); | ||
})); | ||
return function tryGetRealDataOp() { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}(); | ||
_context3.next = 3; | ||
return tryGetRealDataOp(); | ||
case 3: | ||
return _context2.abrupt("return", _context2.sent); | ||
return _context3.abrupt("return", _context3.sent); | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
}, _callee2); | ||
}, _callee3); | ||
})), [dataOp]); | ||
return React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { | ||
return React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { | ||
var _yield$getRealDataOp; | ||
var _ref4, sourceId, opId, userArgs; | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
var _ref5, sourceId, opId, userArgs; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
_context3.next = 2; | ||
_context4.next = 2; | ||
return getRealDataOp(); | ||
case 2: | ||
_context3.t0 = _yield$getRealDataOp = _context3.sent; | ||
if (!(_context3.t0 != null)) { | ||
_context3.next = 7; | ||
_context4.t0 = _yield$getRealDataOp = _context4.sent; | ||
if (!(_context4.t0 != null)) { | ||
_context4.next = 7; | ||
break; | ||
} | ||
_context3.t1 = _yield$getRealDataOp; | ||
_context3.next = 8; | ||
_context4.t1 = _yield$getRealDataOp; | ||
_context4.next = 8; | ||
break; | ||
case 7: | ||
_context3.t1 = {}; | ||
_context4.t1 = {}; | ||
case 8: | ||
_ref4 = _context3.t1; | ||
sourceId = _ref4.sourceId; | ||
opId = _ref4.opId; | ||
userArgs = _ref4.userArgs; | ||
_ref5 = _context4.t1; | ||
sourceId = _ref5.sourceId; | ||
opId = _ref5.opId; | ||
userArgs = _ref5.userArgs; | ||
if (!(!sourceId || !opId)) { | ||
_context3.next = 14; | ||
_context4.next = 14; | ||
break; | ||
} | ||
return _context3.abrupt("return", undefined); | ||
return _context4.abrupt("return", undefined); | ||
case 14: | ||
return _context3.abrupt("return", executePlasmicDataOp({ | ||
return _context4.abrupt("return", executePlasmicDataOp({ | ||
sourceId: sourceId, | ||
@@ -817,5 +819,5 @@ opId: opId, | ||
case "end": | ||
return _context3.stop(); | ||
return _context4.stop(); | ||
} | ||
}, _callee3); | ||
}, _callee4); | ||
})), [getRealDataOp, userToken]); | ||
@@ -822,0 +824,0 @@ } |
@@ -7,2 +7,3 @@ import { DataOp } from '../executor'; | ||
}): string; | ||
export declare function usePlasmicInvalidate(): (invalidatedKeys: string[] | null | undefined) => Promise<any[] | undefined>; | ||
declare type ResolvableDataOp = DataOp | undefined | null | (() => DataOp | undefined | null); | ||
@@ -9,0 +10,0 @@ export declare function usePlasmicDataOp<T extends SingleRowResult | ManyRowsResult, E = any>(dataOp: ResolvableDataOp, opts?: { |
{ | ||
"version": "0.1.117", | ||
"version": "0.1.119", | ||
"license": "MIT", | ||
@@ -60,6 +60,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@plasmicapp/data-sources-context": "0.1.11", | ||
"@plasmicapp/host": "1.0.166", | ||
"@plasmicapp/data-sources-context": "0.1.13", | ||
"@plasmicapp/host": "1.0.168", | ||
"@plasmicapp/isomorphic-unfetch": "1.0.3", | ||
"@plasmicapp/query": "0.1.68", | ||
"@plasmicapp/query": "0.1.70", | ||
"fast-stringify": "^2.0.0" | ||
@@ -70,3 +70,3 @@ }, | ||
}, | ||
"gitHead": "dbe6519e32e754c106a17535505bd1ae7cff082d" | ||
"gitHead": "388b5829f67de3782fe8afdad0d153b5c6d0aac0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
236774
2298
1
24
+ Added@plasmicapp/data-sources-context@0.1.13(transitive)
+ Added@plasmicapp/host@1.0.168(transitive)
+ Added@plasmicapp/query@0.1.70(transitive)
- Removed@plasmicapp/data-sources-context@0.1.11(transitive)
- Removed@plasmicapp/host@1.0.166(transitive)
- Removed@plasmicapp/query@0.1.68(transitive)
Updated@plasmicapp/host@1.0.168
Updated@plasmicapp/query@0.1.70