Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@plasmicapp/data-sources

Package Overview
Dependencies
Maintainers
1
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plasmicapp/data-sources - npm Package Compare versions

Comparing version 0.1.119 to 0.1.120

20

dist/data-sources.cjs.development.js

@@ -504,2 +504,3 @@ 'use strict';

function mkUndefinedDataProxy(promiseRef, fetchAndUpdateCache) {
var fetchAndUpdatePromise = undefined;
return new Proxy({}, {

@@ -518,2 +519,19 @@ get: function get(_target, prop) {

}
var doFetchAndUpdate = function doFetchAndUpdate() {
// We hold onto the promise last returned by fetchAndUpdateCache()
// and keep reusing it until it is resolved. The reason is that the
// Promise thrown here will be used as a dependency for memoized
// fetchAndUpdateCache, which is a dependency on the memoized returned value
// from usePlasmicDataOp(). If we have a fetch that's taking a long time,
// we want to make sure that our memoized returned value is stable,
// so that we don't keep calling setDollarQueries() (otherwise, for each
// render, we find an unstable result, and call setDollarQueries(),
// resulting in an infinite loop while fetch is happening).
if (!fetchAndUpdatePromise) {
fetchAndUpdatePromise = fetchAndUpdateCache()["finally"](function () {
fetchAndUpdatePromise = undefined;
});
}
return fetchAndUpdatePromise;
};
var promise =

@@ -523,3 +541,3 @@ // existing fetch

// No existing fetch, so kick off a fetch
fetchAndUpdateCache();
doFetchAndUpdate();
promise.plasmicType = 'PlasmicUndefinedDataError';

@@ -526,0 +544,0 @@ promise.message = "Cannot read property " + String(prop) + " - data is still loading";

2

dist/data-sources.cjs.production.min.js

@@ -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=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;
"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){var r=void 0;return new Proxy({},{get:function(n,o){if("isPlasmicUndefinedDataProxy"===o)return!0;if(t){var a=e.fetchingPromise||(r||(r=t().finally((function(){r=void 0}))),r);throw a.plasmicType="PlasmicUndefinedDataError",a.message="Cannot read property "+String(o)+" - data is still loading",a}}})}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

@@ -499,2 +499,3 @@ import { wrapLoadingFetcher, usePlasmicDataConfig, useMutablePlasmicQueryData } from '@plasmicapp/query';

function mkUndefinedDataProxy(promiseRef, fetchAndUpdateCache) {
var fetchAndUpdatePromise = undefined;
return new Proxy({}, {

@@ -513,2 +514,19 @@ get: function get(_target, prop) {

}
var doFetchAndUpdate = function doFetchAndUpdate() {
// We hold onto the promise last returned by fetchAndUpdateCache()
// and keep reusing it until it is resolved. The reason is that the
// Promise thrown here will be used as a dependency for memoized
// fetchAndUpdateCache, which is a dependency on the memoized returned value
// from usePlasmicDataOp(). If we have a fetch that's taking a long time,
// we want to make sure that our memoized returned value is stable,
// so that we don't keep calling setDollarQueries() (otherwise, for each
// render, we find an unstable result, and call setDollarQueries(),
// resulting in an infinite loop while fetch is happening).
if (!fetchAndUpdatePromise) {
fetchAndUpdatePromise = fetchAndUpdateCache()["finally"](function () {
fetchAndUpdatePromise = undefined;
});
}
return fetchAndUpdatePromise;
};
var promise =

@@ -518,3 +536,3 @@ // existing fetch

// No existing fetch, so kick off a fetch
fetchAndUpdateCache();
doFetchAndUpdate();
promise.plasmicType = 'PlasmicUndefinedDataError';

@@ -521,0 +539,0 @@ promise.message = "Cannot read property " + String(prop) + " - data is still loading";

{
"version": "0.1.119",
"version": "0.1.120",
"license": "MIT",

@@ -69,3 +69,3 @@ "main": "dist/index.js",

},
"gitHead": "388b5829f67de3782fe8afdad0d153b5c6d0aac0"
"gitHead": "ed9053ca054f0345d29664c855003fc063aef81c"
}

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc