@plasmicapp/data-sources
Advanced tools
Comparing version 0.1.64 to 0.1.65
@@ -11,2 +11,3 @@ 'use strict'; | ||
var fetch = _interopDefault(require('@plasmicapp/isomorphic-unfetch')); | ||
var stringify = _interopDefault(require('fast-stringify')); | ||
@@ -775,3 +776,3 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
}), | ||
body: JSON.stringify({ | ||
body: stringify({ | ||
opId: op.opId, | ||
@@ -778,0 +779,0 @@ userArgs: (_op$userArgs = op.userArgs) != null ? _op$userArgs : {}, |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@plasmicapp/query"),r=t(require("react")),n=require("@plasmicapp/data-sources-context"),o=t(require("@plasmicapp/isomorphic-unfetch"));function a(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){a(i,n,o,u,c,"next",t)}function c(t){a(i,n,o,u,c,"throw",t)}u(void 0)}))}}function u(){return(u=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function c(t,e){return t(e={exports:{}},e.exports),e.exports}var s=c((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new O(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var u=w(i,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function p(){}function f(){}function h(){}var d={};u(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=h.prototype=p.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,u){var c=s(t[o],t,a);if("throw"!==c.type){var l=c.arg,p=l.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,i,u)}),(function(t){n("throw",t,i,u)})):e.resolve(p).then((function(t){l.value=t,i(l)}),(function(t){return n("throw",t,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:P}}function P(){return{value:void 0,done:!0}}return f.prototype=h,u(g,"constructor",h),u(h,"constructor",f),f.displayName=u(h,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,i,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(x.prototype),u(x.prototype,a,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new x(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(g),u(g,i,"Generator"),u(g,o,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}})),l="You do not have permission to perform this operation. Login to get access or contact the app owner to get access.";function p(t,e){return f.apply(this,arguments)}function f(){return(f=i(s.mark((function t(r,n){var o;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=v("__PLASMIC_EXECUTE_DATA_OP",h),t.next=3,e.wrapLoadingFetcher(o)(r,n);case 3:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function h(t,e){return d.apply(this,arguments)}function d(){return(d=i(s.mark((function t(e,r){var n,a,i,c;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.roleId){t.next=4;break}if(null!=r&&r.user&&r.user.roleIds.includes(e.roleId)){t.next=4;break}throw console.error(l),new Error(l);case 4:return a=v("__PLASMIC_DATA_HOST","https://data.plasmic.app"),i=a+"/api/v1/server-data/sources/"+e.sourceId+"/execute",t.next=8,o(i,{method:"POST",headers:u({"Content-Type":"application/json"},(null==r?void 0:r.userAuthToken)&&{"x-plasmic-data-user-auth-token":r.userAuthToken}),body:JSON.stringify({opId:e.opId,userArgs:null!=(n=e.userArgs)?n:{},paginate:null==r?void 0:r.paginate})});case 8:if(200===(c=t.sent).status){t.next=14;break}return t.next=12,c.text();case 12:throw new Error(t.sent);case 14:return t.next=16,c.json();case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function v(t,e){return"undefined"==typeof globalThis?e:null!=(r=globalThis[t])?r:e;var r}function y(t,o){var a=n.usePlasmicDataSourceContext(),c=e.useMutablePlasmicQueryData((function(){if(!t)return null;var e=JSON.stringify({sourceId:t.sourceId,opId:t.opId,args:t.userArgs,userAuthToken:null==a?void 0:a.userAuthToken,paginate:null==o?void 0:o.paginate});return t.cacheKey?""+t.cacheKey+e:e}),i(s.mark((function e(){return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,p(t,{userAuthToken:(null==a?void 0:a.userAuthToken)||void 0,user:null==a?void 0:a.user,paginate:null==o?void 0:o.paginate});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))),l=c.data;return r.useMemo((function(){return u({},null!=l?l:{},function(t){for(var e={},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 t&&(e[u]=t[u])}return e}(c,"isLoading","error"))}),[l,c.error,c.isLoading])}Object.defineProperty(exports,"usePlasmicDataConfig",{enumerable:!0,get:function(){return e.usePlasmicDataConfig}}),exports.Fetcher=function(t){var e,n=t.children,o=t.name,a=t.pageIndex,i=t.pageSize,c=y(t.dataOp,u({},!!a&&!!i&&{paginate:{pageIndex:a,pageSize:i}})),s=r.useMemo((function(){var e;return u({},t.queries,((e={})[null!=o?o:"data"]=c,e))}),[t.queries,o,c]);return null!=(e=null==n?void 0:n(s))?e: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.executePlasmicDataOp=p,exports.useDependencyAwareQuery=function(t){var e,n,o=t.$queries,a=t.setDollarQueries,i=t.name,c=t.pageIndex,s=t.pageSize,l=y(function(t){try{return t()}catch(t){return}}(t.getDataOp),u({},!!c&&!!s&&{paginate:{pageIndex:c,pageSize:s}})),p=null!=i?i:"data",f=(e=p,n=r.useRef(void 0),r.useEffect((function(){return n.current=e,function(){n.current=void 0}})),n.current);r.useEffect((function(){if(!(p in o)||o[p]!==l){var t,e=u({},o,((t={})[p]=l,t));f&&p!==f&&f in o&&delete e[f],a(e)}}),[p,f,l,o,a])},exports.usePlasmicDataMutationOp=function(t,e){var o=null!=t?t:{},a=o.sourceId,u=o.opId,c=o.userArgs,l=n.usePlasmicDataSourceContext(),f=null==l?void 0:l.userAuthToken;return r.useCallback(i(s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a&&u){t.next=2;break}return t.abrupt("return",void 0);case 2:return t.abrupt("return",p({sourceId:a,opId:u,userArgs:c},{userAuthToken:f||void 0,user:null==l?void 0:l.user}));case 3:case"end":return t.stop()}}),t)}))),[a,u,c,f])},exports.usePlasmicDataOp=y; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@plasmicapp/query"),r=t(require("react")),n=require("@plasmicapp/data-sources-context"),o=t(require("@plasmicapp/isomorphic-unfetch")),a=t(require("fast-stringify"));function i(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function u(t){i(a,n,o,u,c,"next",t)}function c(t){i(a,n,o,u,c,"throw",t)}u(void 0)}))}}function c(){return(c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function s(t,e){return t(e={exports:{}},e.exports),e.exports}var l=s((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new O(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var u=w(i,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function p(){}function f(){}function h(){}var d={};u(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=h.prototype=p.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,u){var c=s(t[o],t,a);if("throw"!==c.type){var l=c.arg,p=l.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,i,u)}),(function(t){n("throw",t,i,u)})):e.resolve(p).then((function(t){l.value=t,i(l)}),(function(t){return n("throw",t,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:P}}function P(){return{value:void 0,done:!0}}return f.prototype=h,u(g,"constructor",h),u(h,"constructor",f),f.displayName=u(h,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,i,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(x.prototype),u(x.prototype,a,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new x(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},m(g),u(g,i,"Generator"),u(g,o,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}})),p="You do not have permission to perform this operation. Login to get access or contact the app owner to get access.";function f(t,e){return h.apply(this,arguments)}function h(){return(h=u(l.mark((function t(r,n){var o;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=y("__PLASMIC_EXECUTE_DATA_OP",d),t.next=3,e.wrapLoadingFetcher(o)(r,n);case 3:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function d(t,e){return v.apply(this,arguments)}function v(){return(v=u(l.mark((function t(e,r){var n,i,u,s;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.roleId){t.next=4;break}if(null!=r&&r.user&&r.user.roleIds.includes(e.roleId)){t.next=4;break}throw console.error(p),new Error(p);case 4:return i=y("__PLASMIC_DATA_HOST","https://data.plasmic.app"),u=i+"/api/v1/server-data/sources/"+e.sourceId+"/execute",t.next=8,o(u,{method:"POST",headers:c({"Content-Type":"application/json"},(null==r?void 0:r.userAuthToken)&&{"x-plasmic-data-user-auth-token":r.userAuthToken}),body:a({opId:e.opId,userArgs:null!=(n=e.userArgs)?n:{},paginate:null==r?void 0:r.paginate})});case 8:if(200===(s=t.sent).status){t.next=14;break}return t.next=12,s.text();case 12:throw new Error(t.sent);case 14:return t.next=16,s.json();case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function y(t,e){return"undefined"==typeof globalThis?e:null!=(r=globalThis[t])?r:e;var r}function g(t,o){var a=n.usePlasmicDataSourceContext(),i=e.useMutablePlasmicQueryData((function(){if(!t)return null;var e=JSON.stringify({sourceId:t.sourceId,opId:t.opId,args:t.userArgs,userAuthToken:null==a?void 0:a.userAuthToken,paginate:null==o?void 0:o.paginate});return t.cacheKey?""+t.cacheKey+e:e}),u(l.mark((function e(){return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f(t,{userAuthToken:(null==a?void 0:a.userAuthToken)||void 0,user:null==a?void 0:a.user,paginate:null==o?void 0:o.paginate});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))),s=i.data;return r.useMemo((function(){return c({},null!=s?s:{},function(t){for(var e={},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 t&&(e[u]=t[u])}return e}(i,"isLoading","error"))}),[s,i.error,i.isLoading])}Object.defineProperty(exports,"usePlasmicDataConfig",{enumerable:!0,get:function(){return e.usePlasmicDataConfig}}),exports.Fetcher=function(t){var e,n=t.children,o=t.name,a=t.pageIndex,i=t.pageSize,u=g(t.dataOp,c({},!!a&&!!i&&{paginate:{pageIndex:a,pageSize:i}})),s=r.useMemo((function(){var e;return c({},t.queries,((e={})[null!=o?o:"data"]=u,e))}),[t.queries,o,u]);return null!=(e=null==n?void 0:n(s))?e: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.executePlasmicDataOp=f,exports.useDependencyAwareQuery=function(t){var e,n,o=t.$queries,a=t.setDollarQueries,i=t.name,u=t.pageIndex,s=t.pageSize,l=g(function(t){try{return t()}catch(t){return}}(t.getDataOp),c({},!!u&&!!s&&{paginate:{pageIndex:u,pageSize:s}})),p=null!=i?i:"data",f=(e=p,n=r.useRef(void 0),r.useEffect((function(){return n.current=e,function(){n.current=void 0}})),n.current);r.useEffect((function(){if(!(p in o)||o[p]!==l){var t,e=c({},o,((t={})[p]=l,t));f&&p!==f&&f in o&&delete e[f],a(e)}}),[p,f,l,o,a])},exports.usePlasmicDataMutationOp=function(t,e){var o=null!=t?t:{},a=o.sourceId,i=o.opId,c=o.userArgs,s=n.usePlasmicDataSourceContext(),p=null==s?void 0:s.userAuthToken;return r.useCallback(u(l.mark((function t(){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a&&i){t.next=2;break}return t.abrupt("return",void 0);case 2:return t.abrupt("return",f({sourceId:a,opId:i,userArgs:c},{userAuthToken:p||void 0,user:null==s?void 0:s.user}));case 3:case"end":return t.stop()}}),t)}))),[a,i,c,p])},exports.usePlasmicDataOp=g; | ||
//# sourceMappingURL=data-sources.cjs.production.min.js.map |
@@ -6,2 +6,3 @@ import { wrapLoadingFetcher, useMutablePlasmicQueryData } from '@plasmicapp/query'; | ||
import fetch from '@plasmicapp/isomorphic-unfetch'; | ||
import stringify from 'fast-stringify'; | ||
@@ -770,3 +771,3 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
}), | ||
body: JSON.stringify({ | ||
body: stringify({ | ||
opId: op.opId, | ||
@@ -773,0 +774,0 @@ userArgs: (_op$userArgs = op.userArgs) != null ? _op$userArgs : {}, |
{ | ||
"version": "0.1.64", | ||
"version": "0.1.65", | ||
"license": "MIT", | ||
@@ -64,3 +64,4 @@ "main": "dist/index.js", | ||
"@plasmicapp/isomorphic-unfetch": "^1.0.1", | ||
"@plasmicapp/query": "0.1.61" | ||
"@plasmicapp/query": "0.1.61", | ||
"fast-stringify": "^2.0.0" | ||
}, | ||
@@ -70,3 +71,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "fdb37e4fae6510d955efef6034d992bab1a189e3" | ||
"gitHead": "4f7b6715a12f25ed7c89fd8bf028aae74fb4ab8c" | ||
} |
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
259084
2086
6
+ Addedfast-stringify@^2.0.0
+ Addedfast-stringify@2.0.0(transitive)