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.121 to 0.1.122

2

dist/data-sources.cjs.development.js

@@ -517,3 +517,3 @@ 'use strict';

}
var allKeys = Array.from(new Set([].concat(cache.keys(), fallback ? Object.keys(fallback) : []))).filter(function (key) {
var allKeys = Array.from(new Set([].concat(Array.from(cache.keys()), fallback ? Object.keys(fallback) : []))).filter(function (key) {
return typeof key === 'string';

@@ -520,0 +520,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=require("@plasmicapp/query"),r=e(require("react")),n=require("@plasmicapp/data-sources-context"),a=require("@plasmicapp/host"),o=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,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=Object.create((t&&t.prototype instanceof m?t:m).prototype),i=new T(n||[]);return a(o,"_invoke",{value:L(e,r,i)}),o}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",v="completed",y={};function m(){}function g(){}function w(){}var b={};f(b,i,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(j([])));P&&P!==r&&n.call(P,i)&&(b=P);var k=w.prototype=m.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,o,i,u){var c=p(e[a],e,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(f).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function L(t,r,n){var a=h;return function(o,i){if(a===d)throw new Error("Generator is already running");if(a===v){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var u=n.delegate;if(u){var c=O(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(a===h)throw a=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=d;var s=p(t,r,n);if("normal"===s.type){if(a=n.done?v:"suspendedYield",s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=v,n.method="throw",n.arg=s.arg)}}}function O(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,O(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=p(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var i=o.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 _(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 I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function j(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 a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return g.prototype=w,a(k,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:g,configurable:!0}),g.displayName=f(w,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,f(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},E(A.prototype),f(A.prototype,c,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new A(l(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(k),f(k,s,"Generator"),f(k,i,(function(){return this})),f(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=j,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(I),!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 a(n,a){return u.type="throw",u.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return a("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 a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.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),I(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 a=n.arg;I(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function c(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){c(o,n,a,i,u,"next",e)}function u(e){c(o,n,a,i,u,"throw",e)}i(void 0)}))}}function f(){return(f=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 l="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 a;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=y("__PLASMIC_EXECUTE_DATA_OP",d),e.next=3,t.wrapLoadingFetcher(a)(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,a,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(l),new Error(l);case 4:return a=y("__PLASMIC_DATA_HOST","https://data.plasmic.app"),c=a+"/api/v1/server-data/sources/"+t.sourceId+"/execute",e.next=8,o(c,{method:"POST",headers:f({"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 m(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 g(e,t){var r=void 0;return new Proxy({},{get:function(n,a){if("isPlasmicUndefinedDataProxy"===a)return!0;if(t){var o=e.fetchingPromise||(r||(r=t().finally((function(){r=void 0}))),r);throw o.plasmicType="PlasmicUndefinedDataError",o.message="Cannot read property "+String(a)+" - 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,o){var i,u=x(e),c=n.usePlasmicDataSourceContext(),s=!(null==a.useDataEnv||null==(i=a.useDataEnv())||!i.plasmicInternalEnableLoadingBoundary),l=t.usePlasmicDataConfig(),h=l.mutate,d=l.cache,v=!u,y=w(u),k=!u||w(u)?null:m(u,{paginate:null==o?void 0:o.paginate,userAuthToken:null==c?void 0:c.userAuthToken}),E=r.useMemo((function(){return{fetchingPromise:void 0}}),[k]),A=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==o?void 0:o.paginate});return E.fetchingPromise=t,k&&(P.set(k,t),t.then((function(){P.delete(k)}),(function(){P.delete(k)}))),t}}),[k,E]),L=w(u)?u:void 0,O=r.useMemo((function(){if(k||L)return function(){if(E.fetchingPromise)return E.fetchingPromise;if(L)return L;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(){A().then(e,t)}),1)}));return r.then((function(e){h(k,e)})).catch((function(e){var t,r=k?"$swr$"+k:"";d.set(r,f({},null!=(t=d.get(r))?t:{},{error:e}))})),r}}),[A,E,d,k,L]),_=t.useMutablePlasmicQueryData(k,A,{shouldRetryOnError:!1}),I=_.data,T=_.error,j=_.isLoading;return null!=E.fetchingPromise&&void 0!==I&&(E.fetchingPromise=void 0),r.useMemo((function(){var e=f({},null!=I?I:{},function(e){for(var t={},r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];for(var o=0,i=n;o<i.length;o++){var u=i[o];u in e&&(t[u]=e[u])}return t}(_,"isLoading","error"));return(null==o||!o.noUndefinedDataProxy)&&b>=18&&s&&(j||v||y)&&void 0===e.data&&void 0===e.schema&&void 0===e.error&&(e.data=g(E,O),e.schema=g(E,O)),e}),[v,y,I,T,j,null==o?void 0:o.noUndefinedDataProxy,s,E,O])}function E(e){return e.every((function(e){return"object"==typeof e&&!Array.isArray(e)}))}var A=function(){return""+Math.random()};Object.defineProperty(exports,"usePlasmicDataConfig",{enumerable:!0,get:function(){return t.usePlasmicDataConfig}}),exports.Fetcher=function(e){var t,n=e.children,a=e.name,o=e.pageIndex,i=e.pageSize,u=k(e.dataOp,f({},!!o&&!!i&&{paginate:{pageIndex:o,pageSize:i}})),c=r.useMemo((function(){var t;return f({},e.queries,((t={})[null!=a?a:"data"]=u,t))}),[e.queries,a,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,a=null!=(n=null==t?void 0:t.fields)?n:[],o=new Map(a.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[f({key:A()},r(void 0),e)];var t=o.get(e.fieldId);return t?[f({key:A()},r(t),e)]:[]})),c=a.filter((function(e){return!i.has(e.id)})).map((function(e){return f({key:A()},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=m,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,a=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],a="string"==typeof r?"string":"boolean"==typeof r?"boolean":"number"==typeof r?"number":"unknown";n[t]=n[t]&&n[t]!==a?"unknown":a}))})),{id:"inferred",fields:Object.entries(n).map((function(e){return{id:e[0],type:e[1],readOnly:!1}}))});if(a)return{data:r,schema:a}}}},exports.useDependencyAwareQuery=function(e){var t,n,a=e.$queries,o=e.setDollarQueries,i=e.name,u=e.pageIndex,c=e.pageSize,s=k(function(e){try{return e()}catch(e){return}}(e.getDataOp),f({},!!u&&!!c&&{paginate:{pageIndex:u,pageSize:c}})),l=null!=i?i:"data",p=(t=l,n=r.useRef(void 0),r.useEffect((function(){return n.current=t,function(){n.current=void 0}})),n.current);r.useEffect((function(){if(!(l in a)||a[l]!==s){var e,t=f({},a,((e={})[l]=s,e));p&&l!==p&&p in a&&delete t[p],o(t)}}),[l,p,s,a,o])},exports.usePlasmicDataMutationOp=function(e){var t=n.usePlasmicDataSourceContext(),a=null==t?void 0:t.userAuthToken,o=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,o();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:a||void 0,user:null==t?void 0:t.user}));case 15:case"end":return e.stop()}}),e)}))),[o,a])},exports.usePlasmicDataOp=k,exports.usePlasmicInvalidate=function(){var e=t.usePlasmicDataConfig(),r=e.cache,n=e.fallback,a=e.mutate;return function(){var e=s(u().mark((function e(t){var o,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==(o=function(){if(!t)return[];var e=Array.from(new Set([].concat(r.keys(),n?Object.keys(n):[]))).filter((function(e){return"string"==typeof e}));return t.includes("plasmic_refresh_all")?e:e.filter((function(e){return t.some((function(t){return e.includes(".$."+t+".$.")}))}))}()).length){e.next=4;break}return e.abrupt("return");case 4:return i=function(){var e=s(u().mark((function e(t){var r;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=globalThis.__PLASMIC_MUTATE_DATA_OP)){e.next=4;break}return e.next=4,r(t);case 4:return e.abrupt("return",a(t));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=7,Promise.all(o.map((function(e){return i(e)})));case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()};
"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"),a=require("@plasmicapp/host"),o=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,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=Object.create((t&&t.prototype instanceof m?t:m).prototype),i=new T(n||[]);return a(o,"_invoke",{value:L(e,r,i)}),o}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="executing",v="completed",y={};function m(){}function g(){}function w(){}var b={};f(b,i,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(j([])));P&&P!==r&&n.call(P,i)&&(b=P);var k=w.prototype=m.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,o,i,u){var c=p(e[a],e,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(f).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function L(t,r,n){var a=h;return function(o,i){if(a===d)throw new Error("Generator is already running");if(a===v){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var u=n.delegate;if(u){var c=O(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(a===h)throw a=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=d;var s=p(t,r,n);if("normal"===s.type){if(a=n.done?v:"suspendedYield",s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=v,n.method="throw",n.arg=s.arg)}}}function O(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,O(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=p(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var i=o.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 _(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 I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function j(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 a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return g.prototype=w,a(k,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:g,configurable:!0}),g.displayName=f(w,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,f(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},E(A.prototype),f(A.prototype,c,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new A(l(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(k),f(k,s,"Generator"),f(k,i,(function(){return this})),f(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=j,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(I),!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 a(n,a){return u.type="throw",u.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return a("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 a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.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),I(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 a=n.arg;I(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function c(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){c(o,n,a,i,u,"next",e)}function u(e){c(o,n,a,i,u,"throw",e)}i(void 0)}))}}function f(){return(f=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 l="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 a;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=y("__PLASMIC_EXECUTE_DATA_OP",d),e.next=3,t.wrapLoadingFetcher(a)(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,a,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(l),new Error(l);case 4:return a=y("__PLASMIC_DATA_HOST","https://data.plasmic.app"),c=a+"/api/v1/server-data/sources/"+t.sourceId+"/execute",e.next=8,o(c,{method:"POST",headers:f({"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 m(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 g(e,t){var r=void 0;return new Proxy({},{get:function(n,a){if("isPlasmicUndefinedDataProxy"===a)return!0;if(t){var o=e.fetchingPromise||(r||(r=t().finally((function(){r=void 0}))),r);throw o.plasmicType="PlasmicUndefinedDataError",o.message="Cannot read property "+String(a)+" - 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,o){var i,u=x(e),c=n.usePlasmicDataSourceContext(),s=!(null==a.useDataEnv||null==(i=a.useDataEnv())||!i.plasmicInternalEnableLoadingBoundary),l=t.usePlasmicDataConfig(),h=l.mutate,d=l.cache,v=!u,y=w(u),k=!u||w(u)?null:m(u,{paginate:null==o?void 0:o.paginate,userAuthToken:null==c?void 0:c.userAuthToken}),E=r.useMemo((function(){return{fetchingPromise:void 0}}),[k]),A=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==o?void 0:o.paginate});return E.fetchingPromise=t,k&&(P.set(k,t),t.then((function(){P.delete(k)}),(function(){P.delete(k)}))),t}}),[k,E]),L=w(u)?u:void 0,O=r.useMemo((function(){if(k||L)return function(){if(E.fetchingPromise)return E.fetchingPromise;if(L)return L;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(){A().then(e,t)}),1)}));return r.then((function(e){h(k,e)})).catch((function(e){var t,r=k?"$swr$"+k:"";d.set(r,f({},null!=(t=d.get(r))?t:{},{error:e}))})),r}}),[A,E,d,k,L]),_=t.useMutablePlasmicQueryData(k,A,{shouldRetryOnError:!1}),I=_.data,T=_.error,j=_.isLoading;return null!=E.fetchingPromise&&void 0!==I&&(E.fetchingPromise=void 0),r.useMemo((function(){var e=f({},null!=I?I:{},function(e){for(var t={},r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];for(var o=0,i=n;o<i.length;o++){var u=i[o];u in e&&(t[u]=e[u])}return t}(_,"isLoading","error"));return(null==o||!o.noUndefinedDataProxy)&&b>=18&&s&&(j||v||y)&&void 0===e.data&&void 0===e.schema&&void 0===e.error&&(e.data=g(E,O),e.schema=g(E,O)),e}),[v,y,I,T,j,null==o?void 0:o.noUndefinedDataProxy,s,E,O])}function E(e){return e.every((function(e){return"object"==typeof e&&!Array.isArray(e)}))}var A=function(){return""+Math.random()};Object.defineProperty(exports,"usePlasmicDataConfig",{enumerable:!0,get:function(){return t.usePlasmicDataConfig}}),exports.Fetcher=function(e){var t,n=e.children,a=e.name,o=e.pageIndex,i=e.pageSize,u=k(e.dataOp,f({},!!o&&!!i&&{paginate:{pageIndex:o,pageSize:i}})),c=r.useMemo((function(){var t;return f({},e.queries,((t={})[null!=a?a:"data"]=u,t))}),[e.queries,a,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,a=null!=(n=null==t?void 0:t.fields)?n:[],o=new Map(a.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[f({key:A()},r(void 0),e)];var t=o.get(e.fieldId);return t?[f({key:A()},r(t),e)]:[]})),c=a.filter((function(e){return!i.has(e.id)})).map((function(e){return f({key:A()},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=m,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,a=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],a="string"==typeof r?"string":"boolean"==typeof r?"boolean":"number"==typeof r?"number":"unknown";n[t]=n[t]&&n[t]!==a?"unknown":a}))})),{id:"inferred",fields:Object.entries(n).map((function(e){return{id:e[0],type:e[1],readOnly:!1}}))});if(a)return{data:r,schema:a}}}},exports.useDependencyAwareQuery=function(e){var t,n,a=e.$queries,o=e.setDollarQueries,i=e.name,u=e.pageIndex,c=e.pageSize,s=k(function(e){try{return e()}catch(e){return}}(e.getDataOp),f({},!!u&&!!c&&{paginate:{pageIndex:u,pageSize:c}})),l=null!=i?i:"data",p=(t=l,n=r.useRef(void 0),r.useEffect((function(){return n.current=t,function(){n.current=void 0}})),n.current);r.useEffect((function(){if(!(l in a)||a[l]!==s){var e,t=f({},a,((e={})[l]=s,e));p&&l!==p&&p in a&&delete t[p],o(t)}}),[l,p,s,a,o])},exports.usePlasmicDataMutationOp=function(e){var t=n.usePlasmicDataSourceContext(),a=null==t?void 0:t.userAuthToken,o=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,o();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:a||void 0,user:null==t?void 0:t.user}));case 15:case"end":return e.stop()}}),e)}))),[o,a])},exports.usePlasmicDataOp=k,exports.usePlasmicInvalidate=function(){var e=t.usePlasmicDataConfig(),r=e.cache,n=e.fallback,a=e.mutate;return function(){var e=s(u().mark((function e(t){var o,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==(o=function(){if(!t)return[];var e=Array.from(new Set([].concat(Array.from(r.keys()),n?Object.keys(n):[]))).filter((function(e){return"string"==typeof e}));return t.includes("plasmic_refresh_all")?e:e.filter((function(e){return t.some((function(t){return e.includes(".$."+t+".$.")}))}))}()).length){e.next=4;break}return e.abrupt("return");case 4:return i=function(){var e=s(u().mark((function e(t){var r;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=globalThis.__PLASMIC_MUTATE_DATA_OP)){e.next=4;break}return e.next=4,r(t);case 4:return e.abrupt("return",a(t));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=7,Promise.all(o.map((function(e){return i(e)})));case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()};
//# sourceMappingURL=data-sources.cjs.production.min.js.map

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

}
var allKeys = Array.from(new Set([].concat(cache.keys(), fallback ? Object.keys(fallback) : []))).filter(function (key) {
var allKeys = Array.from(new Set([].concat(Array.from(cache.keys()), fallback ? Object.keys(fallback) : []))).filter(function (key) {
return typeof key === 'string';

@@ -515,0 +515,0 @@ });

{
"version": "0.1.121",
"version": "0.1.122",
"license": "MIT",

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

},
"gitHead": "6c48262a5dd6aa343ae8bd05be361ba2349184b8"
"gitHead": "f5f3e09c3da6144db2fc7d18104c4bf070e65b44"
}

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