@merkur/plugin-graphql-client 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.umd.js +1 -1
  2. package/package.json +6 -6
package/lib/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(r,e){if("function"==typeof define&&define.amd)define("@merkur/plugin-graphql-client",["exports","@merkur/core","graphql","@merkur/plugin-error"],e);else if("undefined"!=typeof exports)e(exports,require("@merkur/core"),require("graphql"),require("@merkur/plugin-error"));else{var t={exports:{}};e(t.exports,r.Merkur.Core,r.graphql,r.Merkur.Plugin.Error),r.merkurPluginGraphqlClient=t.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(r,e,t,n){Object.defineProperty(r,"__esModule",{value:!0}),r.UnauthorizedError=r.GraphQLError=void 0,r.graphqlClientPlugin=function(){return{setup:function(r){return d((function*(){return(0,e.assignMissingKeys)(r,{graphql:{request:function(r,e){var n=arguments;return d((function*(){var u,a=n.length>2&&void 0!==n[2]?n[2]:{},c=n.length>3&&void 0!==n[3]?n[3]:{},l=r.$in.graphqlClient,f=l.endpointUrl,p=l.entityClasses,y=c.headers,d=void 0===y?{}:y,b=c.body,v=void 0===b?{}:b,h=function(r,e){if(null==r)return{};var t,n,o=function(r,e){if(null==r)return{};var t={};for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)){if(e.indexOf(n)>=0)continue;t[n]=r[n]}return t}(r,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}(c,o);u=e,e=(0,t.visit)(u,{SelectionSet:{enter:function(r,e,t){if(!t||"OperationDefinition"!==t.kind){var n=r.selections;if(n&&!(n.some((function(r){return"Field"===r.kind&&("__typename"===r.name.value||0===r.name.value.lastIndexOf("__",0))}))||"Field"===t.kind&&t.directives&&t.directives.some((function(r){return"export"===r.name.value}))))return Object.assign({},r,{selections:[].concat(i(n),[_])})}}}});var m=(yield r.http.request(s({url:f,method:"POST",headers:s({"Content-Type":"application/json"},d),body:s({query:(0,t.stripIgnoredCharacters)((0,t.print)(e)),variables:a},v)},h))).response.body,g=m.errors,O=m.data,j=void 0===O?{}:O;return g?Array.isArray(g)&&g.some((function(r){return"unauthorized"===r.status}))?Promise.reject(new S("Unauthorized Error",{errors:g,data:j})):Promise.reject(new E("Api Error",{errors:g,data:j})):A(j,p)}))()}}}),r.$in.graphqlClient={endpointUrl:"",entityClasses:{}},r}))()},create:function(r){return d((function*(){if(k===q&&!r.$in.httpClient)throw new Error("You must install missing plugin: npm i @merkur/plugin-http-client");return(0,e.bindWidgetToFunctions)(r,r.graphql),r}))()}}},r.setEndpointUrl=function(r,e){r.$in.graphqlClient.endpointUrl=e},r.setEntityClasses=function(r,e){r.$in.graphqlClient.entityClasses=function(r){var e={};return r.forEach((function(r){var t=r.entityType;Array.isArray(t)||(t=[t]),t.forEach((function(t){return e[t]=r}))})),e}(e)};var o=["headers","body"];function i(r){return function(r){if(Array.isArray(r))return l(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||c(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(r){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},u(r)}function a(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,u,a=[],c=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=i.call(t)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(r){l=!0,o=r}finally{try{if(!c&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(r,e)||c(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(r,e){if(r){if("string"==typeof r)return l(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(r,e):void 0}}function l(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function f(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?f(Object(t),!0).forEach((function(e){p(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):f(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}function p(r,e,t){return(e=h(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function y(r,e,t,n,o,i,u){try{var a=r[i](u),c=a.value}catch(r){return void t(r)}a.done?e(c):Promise.resolve(c).then(n,o)}function d(r){return function(){var e=this,t=arguments;return new Promise((function(n,o){var i=r.apply(e,t);function u(r){y(i,n,o,u,a,"next",r)}function a(r){y(i,n,o,u,a,"throw",r)}u(void 0)}))}}function b(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,h(n.key),n)}}function v(r,e,t){return e&&b(r.prototype,e),t&&b(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function h(r){var e=function(r,e){if("object"!=u(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==u(e)?e:e+""}function m(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function g(r,e,t){return e=j(e),function(r,e){if(e&&("object"===u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(r)}(r,O()?Reflect.construct(e,t||[],j(r).constructor):e.apply(r,t))}function O(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(r){}return(O=function(){return!!r})()}function j(r){return j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},j(r)}function w(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&P(r,e)}function P(r,e){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},P(r,e)}var E=r.GraphQLError=function(r){function e(){return m(this,e),g(this,e,arguments)}return w(e,r),v(e)}(n.GenericError),S=r.UnauthorizedError=function(r){function e(){return m(this,e),g(this,e,arguments)}return w(e,r),v(e)}(E),_={kind:"Field",name:{kind:"Name",value:"__typename"}},q="development",k="undefined"!=typeof process&&process&&process.env?process.env.NODE_ENV:q;function A(r,e){var t={};if("string"==typeof r)return r;Object.entries(r).forEach((function(r){var n=a(r,2),o=n[0],i=n[1];Array.isArray(i)?i=i.map((function(r){return A(r,e)})):"object"===u(i)&&null!==i&&(i=A(i,e)),t[o]=i}));var n=t.__typename;return n&&e[n]?Reflect.construct(e[n],[t]):t}}));
1
+ !function(r,e){if("function"==typeof define&&define.amd)define("@merkur/plugin-graphql-client",["exports","@merkur/core","graphql","@merkur/plugin-error"],e);else if("undefined"!=typeof exports)e(exports,require("@merkur/core"),require("graphql"),require("@merkur/plugin-error"));else{var t={exports:{}};e(t.exports,r.Merkur.Core,r.graphql,r.Merkur.Plugin.Error),r.merkurPluginGraphqlClient=t.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(r,e,t,n){Object.defineProperty(r,"__esModule",{value:!0}),r.UnauthorizedError=r.GraphQLError=void 0,r.graphqlClientPlugin=function(){return{setup:function(r){return d((function*(){return(0,e.assignMissingKeys)(r,{graphql:{request:function(r,e){var n=arguments;return d((function*(){var u,a=n.length>2&&void 0!==n[2]?n[2]:{},c=n.length>3&&void 0!==n[3]?n[3]:{},l=r.$in.graphqlClient,f=l.endpointUrl,p=l.entityClasses,y=c.headers,d=void 0===y?{}:y,b=c.body,v=void 0===b?{}:b,h=function(r,e){if(null==r)return{};var t,n,o=function(r,e){if(null==r)return{};var t={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(e.includes(n))continue;t[n]=r[n]}return t}(r,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)t=i[n],e.includes(t)||{}.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}(c,o);u=e,e=(0,t.visit)(u,{SelectionSet:{enter:function(r,e,t){if(!t||"OperationDefinition"!==t.kind){var n=r.selections;if(n&&!(n.some((function(r){return"Field"===r.kind&&("__typename"===r.name.value||0===r.name.value.lastIndexOf("__",0))}))||"Field"===t.kind&&t.directives&&t.directives.some((function(r){return"export"===r.name.value}))))return Object.assign({},r,{selections:[].concat(i(n),[_])})}}}});var m=(yield r.http.request(s({url:f,method:"POST",headers:s({"Content-Type":"application/json"},d),body:s({query:(0,t.stripIgnoredCharacters)((0,t.print)(e)),variables:a},v)},h))).response.body,g=m.errors,O=m.data,j=void 0===O?{}:O;return g?Array.isArray(g)&&g.some((function(r){return"unauthorized"===r.status}))?Promise.reject(new S("Unauthorized Error",{errors:g,data:j})):Promise.reject(new E("Api Error",{errors:g,data:j})):A(j,p)}))()}}}),r.$in.graphqlClient={endpointUrl:"",entityClasses:{}},r}))()},create:function(r){return d((function*(){if(k===q&&!r.$in.httpClient)throw new Error("You must install missing plugin: npm i @merkur/plugin-http-client");return(0,e.bindWidgetToFunctions)(r,r.graphql),r}))()}}},r.setEndpointUrl=function(r,e){r.$in.graphqlClient.endpointUrl=e},r.setEntityClasses=function(r,e){r.$in.graphqlClient.entityClasses=function(r){var e={};return r.forEach((function(r){var t=r.entityType;Array.isArray(t)||(t=[t]),t.forEach((function(t){return e[t]=r}))})),e}(e)};var o=["headers","body"];function i(r){return function(r){if(Array.isArray(r))return l(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||c(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(r){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},u(r)}function a(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,u,a=[],c=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=i.call(t)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(r){l=!0,o=r}finally{try{if(!c&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(r,e)||c(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(r,e){if(r){if("string"==typeof r)return l(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(r,e):void 0}}function l(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function f(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?f(Object(t),!0).forEach((function(e){p(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):f(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}function p(r,e,t){return(e=h(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function y(r,e,t,n,o,i,u){try{var a=r[i](u),c=a.value}catch(r){return void t(r)}a.done?e(c):Promise.resolve(c).then(n,o)}function d(r){return function(){var e=this,t=arguments;return new Promise((function(n,o){var i=r.apply(e,t);function u(r){y(i,n,o,u,a,"next",r)}function a(r){y(i,n,o,u,a,"throw",r)}u(void 0)}))}}function b(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,h(n.key),n)}}function v(r,e,t){return e&&b(r.prototype,e),t&&b(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function h(r){var e=function(r,e){if("object"!=u(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==u(e)?e:e+""}function m(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function g(r,e,t){return e=j(e),function(r,e){if(e&&("object"==u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(r)}(r,O()?Reflect.construct(e,t||[],j(r).constructor):e.apply(r,t))}function O(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(r){}return(O=function(){return!!r})()}function j(r){return j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},j(r)}function w(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&P(r,e)}function P(r,e){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},P(r,e)}var E=r.GraphQLError=function(r){function e(){return m(this,e),g(this,e,arguments)}return w(e,r),v(e)}(n.GenericError),S=r.UnauthorizedError=function(r){function e(){return m(this,e),g(this,e,arguments)}return w(e,r),v(e)}(E),_={kind:"Field",name:{kind:"Name",value:"__typename"}},q="development",k="undefined"!=typeof process&&process&&process.env?process.env.NODE_ENV:q;function A(r,e){var t={};if("string"==typeof r)return r;Object.entries(r).forEach((function(r){var n=a(r,2),o=n[0],i=n[1];Array.isArray(i)?i=i.map((function(r){return A(r,e)})):"object"===u(i)&&null!==i&&(i=A(i,e)),t[o]=i}));var n=t.__typename;return n&&e[n]?Reflect.construct(e[n],[t]):t}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/plugin-graphql-client",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "Merkur event emitter plugin.",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -51,10 +51,10 @@
51
51
  },
52
52
  "homepage": "https://merkur.js.org/",
53
53
  "devDependencies": {
54
- "@merkur/core": "^0.36.0",
55
- "@merkur/plugin-component": "^0.36.0",
56
- "@merkur/plugin-error": "^0.36.0",
57
- "@merkur/plugin-http-client": "^0.36.0"
54
+ "@merkur/core": "^0.37.0",
55
+ "@merkur/plugin-component": "^0.37.0",
56
+ "@merkur/plugin-error": "^0.37.0",
57
+ "@merkur/plugin-http-client": "^0.37.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@merkur/core": "*",
@@ -65,5 +65,5 @@
65
65
  "graphql": "^16.6.0",
66
66
  "graphql-tag": "^2.12.6"
67
67
  },
68
- "gitHead": "2471f91d8249ae75e49b2a0da8d0deb93062f014"
68
+ "gitHead": "af826493e5ed4b37602dd43ce89a59baeeb1bada"
69
69
  }