@merkur/plugin-graphql-client 0.31.0 → 0.33.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.
- package/README.md +1 -1
- package/lib/index.cjs +5 -10
- package/lib/index.es9.cjs +1 -7
- package/lib/index.es9.mjs +2 -5
- package/lib/index.js +5 -10
- package/lib/index.mjs +6 -9
- package/lib/index.umd.js +1 -1
- package/package.json +15 -16
- package/rollup.config.mjs +11 -0
- package/lib/index.es5.js +0 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|

|
|
12
12
|
[](https://github.com/prettier/prettier)
|
|
13
13
|
|
|
14
|
-
The [Merkur](https://merkur.js.org/) is tiny extensible javascript library for front-end microservices(micro frontends). It allows by default server side rendering for loading performance boost. You can connect it with other frameworks or languages because merkur defines easy API. You can use one of six predefined template's library [
|
|
14
|
+
The [Merkur](https://merkur.js.org/) is tiny extensible javascript library for front-end microservices(micro frontends). It allows by default server side rendering for loading performance boost. You can connect it with other frameworks or languages because merkur defines easy API. You can use one of six predefined template's library [Preact](https://preactjs.com/), [µhtml](https://github.com/WebReflection/uhtml#readme), [Svelte](https://svelte.dev/) and [vanilla](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) but you can easily extend for others.
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
- Flexible templating engine
|
package/lib/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@merkur/core');
|
|
6
4
|
var graphql = require('graphql');
|
|
7
5
|
var pluginError = require('@merkur/plugin-error');
|
|
@@ -35,10 +33,7 @@ function setEntityClasses(widget, entityClasses) {
|
|
|
35
33
|
function graphqlClientPlugin() {
|
|
36
34
|
return {
|
|
37
35
|
async setup(widget) {
|
|
38
|
-
widget
|
|
39
|
-
...graphqlClientAPI(),
|
|
40
|
-
...widget,
|
|
41
|
-
};
|
|
36
|
+
core.assignMissingKeys(widget, graphqlClientAPI());
|
|
42
37
|
|
|
43
38
|
widget.$in.graphqlClient = {
|
|
44
39
|
endpointUrl: '',
|
|
@@ -50,7 +45,7 @@ function graphqlClientPlugin() {
|
|
|
50
45
|
async create(widget) {
|
|
51
46
|
if (ENV === DEV && !widget.$in.httpClient) {
|
|
52
47
|
throw new Error(
|
|
53
|
-
'You must install missing plugin: npm i @merkur/plugin-http-client'
|
|
48
|
+
'You must install missing plugin: npm i @merkur/plugin-http-client',
|
|
54
49
|
);
|
|
55
50
|
}
|
|
56
51
|
|
|
@@ -92,12 +87,12 @@ function graphqlClientAPI() {
|
|
|
92
87
|
errors.some((error) => error.status === 'unauthorized')
|
|
93
88
|
) {
|
|
94
89
|
return Promise.reject(
|
|
95
|
-
new UnauthorizedError(`Unauthorized Error`, { errors, data })
|
|
90
|
+
new UnauthorizedError(`Unauthorized Error`, { errors, data }),
|
|
96
91
|
);
|
|
97
92
|
}
|
|
98
93
|
|
|
99
94
|
return Promise.reject(
|
|
100
|
-
new GraphQLError(`Api Error`, { errors, data })
|
|
95
|
+
new GraphQLError(`Api Error`, { errors, data }),
|
|
101
96
|
);
|
|
102
97
|
}
|
|
103
98
|
|
|
@@ -168,7 +163,7 @@ function addTypenameToSelections(document) {
|
|
|
168
163
|
(selection) =>
|
|
169
164
|
selection.kind === 'Field' &&
|
|
170
165
|
(selection.name.value === '__typename' ||
|
|
171
|
-
selection.name.value.lastIndexOf('__', 0) === 0)
|
|
166
|
+
selection.name.value.lastIndexOf('__', 0) === 0),
|
|
172
167
|
);
|
|
173
168
|
|
|
174
169
|
if (skip) {
|
package/lib/index.es9.cjs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
3
|
var core = require('@merkur/core');
|
|
7
4
|
var graphql = require('graphql');
|
|
8
5
|
var pluginError = require('@merkur/plugin-error');
|
|
@@ -26,10 +23,7 @@ function setEntityClasses(widget, entityClasses) {
|
|
|
26
23
|
function graphqlClientPlugin() {
|
|
27
24
|
return {
|
|
28
25
|
async setup(widget) {
|
|
29
|
-
widget
|
|
30
|
-
...graphqlClientAPI(),
|
|
31
|
-
...widget
|
|
32
|
-
};
|
|
26
|
+
core.assignMissingKeys(widget, graphqlClientAPI());
|
|
33
27
|
widget.$in.graphqlClient = {
|
|
34
28
|
endpointUrl: '',
|
|
35
29
|
entityClasses: {}
|
package/lib/index.es9.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bindWidgetToFunctions } from '@merkur/core';
|
|
1
|
+
import { assignMissingKeys, bindWidgetToFunctions } from '@merkur/core';
|
|
2
2
|
import { stripIgnoredCharacters, print, visit } from 'graphql';
|
|
3
3
|
import { GenericError } from '@merkur/plugin-error';
|
|
4
4
|
class GraphQLError extends GenericError {}
|
|
@@ -21,10 +21,7 @@ function setEntityClasses(widget, entityClasses) {
|
|
|
21
21
|
function graphqlClientPlugin() {
|
|
22
22
|
return {
|
|
23
23
|
async setup(widget) {
|
|
24
|
-
widget
|
|
25
|
-
...graphqlClientAPI(),
|
|
26
|
-
...widget
|
|
27
|
-
};
|
|
24
|
+
assignMissingKeys(widget, graphqlClientAPI());
|
|
28
25
|
widget.$in.graphqlClient = {
|
|
29
26
|
endpointUrl: '',
|
|
30
27
|
entityClasses: {}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@merkur/core');
|
|
6
4
|
var graphql = require('graphql');
|
|
7
5
|
var pluginError = require('@merkur/plugin-error');
|
|
@@ -35,10 +33,7 @@ function setEntityClasses(widget, entityClasses) {
|
|
|
35
33
|
function graphqlClientPlugin() {
|
|
36
34
|
return {
|
|
37
35
|
async setup(widget) {
|
|
38
|
-
widget
|
|
39
|
-
...graphqlClientAPI(),
|
|
40
|
-
...widget,
|
|
41
|
-
};
|
|
36
|
+
core.assignMissingKeys(widget, graphqlClientAPI());
|
|
42
37
|
|
|
43
38
|
widget.$in.graphqlClient = {
|
|
44
39
|
endpointUrl: '',
|
|
@@ -50,7 +45,7 @@ function graphqlClientPlugin() {
|
|
|
50
45
|
async create(widget) {
|
|
51
46
|
if (ENV === DEV && !widget.$in.httpClient) {
|
|
52
47
|
throw new Error(
|
|
53
|
-
'You must install missing plugin: npm i @merkur/plugin-http-client'
|
|
48
|
+
'You must install missing plugin: npm i @merkur/plugin-http-client',
|
|
54
49
|
);
|
|
55
50
|
}
|
|
56
51
|
|
|
@@ -92,12 +87,12 @@ function graphqlClientAPI() {
|
|
|
92
87
|
errors.some((error) => error.status === 'unauthorized')
|
|
93
88
|
) {
|
|
94
89
|
return Promise.reject(
|
|
95
|
-
new UnauthorizedError(`Unauthorized Error`, { errors, data })
|
|
90
|
+
new UnauthorizedError(`Unauthorized Error`, { errors, data }),
|
|
96
91
|
);
|
|
97
92
|
}
|
|
98
93
|
|
|
99
94
|
return Promise.reject(
|
|
100
|
-
new GraphQLError(`Api Error`, { errors, data })
|
|
95
|
+
new GraphQLError(`Api Error`, { errors, data }),
|
|
101
96
|
);
|
|
102
97
|
}
|
|
103
98
|
|
|
@@ -168,7 +163,7 @@ function addTypenameToSelections(document) {
|
|
|
168
163
|
(selection) =>
|
|
169
164
|
selection.kind === 'Field' &&
|
|
170
165
|
(selection.name.value === '__typename' ||
|
|
171
|
-
selection.name.value.lastIndexOf('__', 0) === 0)
|
|
166
|
+
selection.name.value.lastIndexOf('__', 0) === 0),
|
|
172
167
|
);
|
|
173
168
|
|
|
174
169
|
if (skip) {
|
package/lib/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bindWidgetToFunctions } from '@merkur/core';
|
|
1
|
+
import { assignMissingKeys, bindWidgetToFunctions } from '@merkur/core';
|
|
2
2
|
import { stripIgnoredCharacters, print, visit } from 'graphql';
|
|
3
3
|
import { GenericError } from '@merkur/plugin-error';
|
|
4
4
|
|
|
@@ -31,10 +31,7 @@ function setEntityClasses(widget, entityClasses) {
|
|
|
31
31
|
function graphqlClientPlugin() {
|
|
32
32
|
return {
|
|
33
33
|
async setup(widget) {
|
|
34
|
-
widget
|
|
35
|
-
...graphqlClientAPI(),
|
|
36
|
-
...widget,
|
|
37
|
-
};
|
|
34
|
+
assignMissingKeys(widget, graphqlClientAPI());
|
|
38
35
|
|
|
39
36
|
widget.$in.graphqlClient = {
|
|
40
37
|
endpointUrl: '',
|
|
@@ -46,7 +43,7 @@ function graphqlClientPlugin() {
|
|
|
46
43
|
async create(widget) {
|
|
47
44
|
if (ENV === DEV && !widget.$in.httpClient) {
|
|
48
45
|
throw new Error(
|
|
49
|
-
'You must install missing plugin: npm i @merkur/plugin-http-client'
|
|
46
|
+
'You must install missing plugin: npm i @merkur/plugin-http-client',
|
|
50
47
|
);
|
|
51
48
|
}
|
|
52
49
|
|
|
@@ -88,12 +85,12 @@ function graphqlClientAPI() {
|
|
|
88
85
|
errors.some((error) => error.status === 'unauthorized')
|
|
89
86
|
) {
|
|
90
87
|
return Promise.reject(
|
|
91
|
-
new UnauthorizedError(`Unauthorized Error`, { errors, data })
|
|
88
|
+
new UnauthorizedError(`Unauthorized Error`, { errors, data }),
|
|
92
89
|
);
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
return Promise.reject(
|
|
96
|
-
new GraphQLError(`Api Error`, { errors, data })
|
|
93
|
+
new GraphQLError(`Api Error`, { errors, data }),
|
|
97
94
|
);
|
|
98
95
|
}
|
|
99
96
|
|
|
@@ -164,7 +161,7 @@ function addTypenameToSelections(document) {
|
|
|
164
161
|
(selection) =>
|
|
165
162
|
selection.kind === 'Field' &&
|
|
166
163
|
(selection.name.value === '__typename' ||
|
|
167
|
-
selection.name.value.lastIndexOf('__', 0) === 0)
|
|
164
|
+
selection.name.value.lastIndexOf('__', 0) === 0),
|
|
168
165
|
);
|
|
169
166
|
|
|
170
167
|
if (skip) {
|
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
|
|
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,n,o={},i=Object.keys(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||(o[t]=r[t]);return o}(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),[S])})}}}});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 E("Unauthorized Error",{errors:g,data:j})):Promise.reject(new P("Api Error",{errors:g,data:j})):k(j,p)}))()}}}),r.$in.graphqlClient={endpointUrl:"",entityClasses:{}},r}))()},create:function(r){return d((function*(){if(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)||null===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:String(e)}function m(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function g(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&&O(r,e)}function O(r,e){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},O(r,e)}function j(r){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(r){return!1}}();return function(){var t,n=w(r);if(e){var o=w(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return 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)}(this,t)}}function w(r){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},w(r)}var P=function(r){g(t,r);var e=j(t);function t(){return m(this,t),e.apply(this,arguments)}return v(t)}(n.GenericError);r.GraphQLError=P;var E=function(r){g(t,r);var e=j(t);function t(){return m(this,t),e.apply(this,arguments)}return v(t)}(P);r.UnauthorizedError=E;var S={kind:"Field",name:{kind:"Name",value:"__typename"}},_="development",q="undefined"!=typeof process&&process&&process.env?process.env.NODE_ENV:_;function k(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 k(r,e)})):"object"===u(i)&&null!==i&&(i=k(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.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Merkur event emitter plugin.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"./webpack.js": "./webpack.js"
|
|
19
19
|
},
|
|
20
20
|
"browser": {
|
|
21
|
-
"./lib/index.js": "./lib/index.
|
|
22
|
-
"./lib/index.cjs": "./lib/index.
|
|
21
|
+
"./lib/index.js": "./lib/index.js",
|
|
22
|
+
"./lib/index.cjs": "./lib/index.cjs",
|
|
23
23
|
"./lib/index.mjs": "./lib/index.mjs",
|
|
24
24
|
"./lib/index.es9.mjs": "./lib/index.es9.mjs"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"preversion": "npm test",
|
|
28
|
-
"test": "
|
|
29
|
-
"test:es:version": "
|
|
30
|
-
"build": "
|
|
28
|
+
"test": "jest --no-watchman -c ./jest.config.js",
|
|
29
|
+
"test:es:version": "es-check es11 ./lib/index.mjs --module && es-check es9 ./lib/index.es9.mjs --module && es-check es9 ./lib/index.es9.cjs --module",
|
|
30
|
+
"build": "rollup -c rollup.config.mjs",
|
|
31
31
|
"prepare": "npm run build"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
@@ -51,20 +51,19 @@
|
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://merkur.js.org/",
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@merkur/core": "^0.
|
|
55
|
-
"@merkur/plugin-component": "^0.
|
|
56
|
-
"@merkur/plugin-error": "^0.
|
|
57
|
-
"@merkur/plugin-http-client": "^0.
|
|
58
|
-
"rollup": "^2.70.2"
|
|
54
|
+
"@merkur/core": "^0.33.0",
|
|
55
|
+
"@merkur/plugin-component": "^0.33.0",
|
|
56
|
+
"@merkur/plugin-error": "^0.33.0",
|
|
57
|
+
"@merkur/plugin-http-client": "^0.33.0"
|
|
59
58
|
},
|
|
60
59
|
"peerDependencies": {
|
|
61
60
|
"@merkur/core": "*",
|
|
62
|
-
"@merkur/plugin-error": "
|
|
63
|
-
"@merkur/plugin-http-client": "
|
|
61
|
+
"@merkur/plugin-error": "*",
|
|
62
|
+
"@merkur/plugin-http-client": "*"
|
|
64
63
|
},
|
|
65
64
|
"dependencies": {
|
|
66
|
-
"graphql": "^
|
|
67
|
-
"graphql-tag": "^2.12.
|
|
65
|
+
"graphql": "^16.6.0",
|
|
66
|
+
"graphql-tag": "^2.12.6"
|
|
68
67
|
},
|
|
69
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "3e88b57abfad267ac3f3b20b2ae6bf50f93f5375"
|
|
70
69
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRollupESConfig,
|
|
3
|
+
createRollupES9Config,
|
|
4
|
+
createRollupUMDConfig,
|
|
5
|
+
} from '../../createRollupConfig.mjs';
|
|
6
|
+
|
|
7
|
+
let esConfig = createRollupESConfig();
|
|
8
|
+
let es9Config = createRollupES9Config();
|
|
9
|
+
let umdConfig = createRollupUMDConfig();
|
|
10
|
+
|
|
11
|
+
export default [esConfig, es9Config, umdConfig];
|
package/lib/index.es5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";require("core-js/modules/es.object.set-prototype-of.js"),require("core-js/modules/es.function.bind.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.object.create.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.object.get-own-property-descriptor.js"),require("core-js/modules/es.object.get-own-property-descriptors.js"),require("core-js/modules/es.object.define-properties.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.symbol.async-iterator.js"),require("core-js/modules/es.symbol.to-string-tag.js"),require("core-js/modules/es.json.to-string-tag.js"),require("core-js/modules/es.math.to-string-tag.js"),require("core-js/modules/es.array.reverse.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.array.index-of.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.regexp.exec.js");var e=["headers","body"];function r(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||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 t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var n,o,i=[],u=!0,s=!1;try{for(t=t.call(e);!(u=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);u=!0);}catch(e){s=!0,o=e}finally{try{u||null==t.return||t.return()}finally{if(s)throw o}}return i}(e,r)||o(e,r)||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 o(e,r){if(e){if("string"==typeof e)return i(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function u(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function s(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */s=function(){return e};var e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{l({},"")}catch(e){l=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var i=r&&r.prototype instanceof h?r:h,u=Object.create(i.prototype),s=new _(n||[]);return o(u,"_invoke",{value:q(e,t,s)}),u}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var y={};function h(){}function d(){}function m(){}var v={};l(v,u,(function(){return this}));var j=Object.getPrototypeOf,b=j&&j(j(L([])));b&&b!==r&&n.call(b,u)&&(v=b);var g=m.prototype=h.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(r){l(e,r,(function(e){return this._invoke(r,e)}))}))}function O(e,r){function i(o,u,s,a){var c=p(e[o],e,u);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==t(f)&&n.call(f,"__await")?r.resolve(f.__await).then((function(e){i("next",e,s,a)}),(function(e){i("throw",e,s,a)})):r.resolve(f).then((function(e){l.value=e,s(l)}),(function(e){return i("throw",e,s,a)}))}a(c.arg)}var u;o(this,"_invoke",{value:function(e,t){function n(){return new r((function(r,n){i(e,t,r,n)}))}return u=u?u.then(n,n):n()}})}function q(e,r,t){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return S()}for(t.method=o,t.arg=i;;){var u=t.delegate;if(u){var s=x(u,t);if(s){if(s===y)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var a=p(e,r,t);if("normal"===a.type){if(n=t.done?"completed":"suspendedYield",a.arg===y)continue;return{value:a.arg,done:t.done}}"throw"===a.type&&(n="completed",t.method="throw",t.arg=a.arg)}}}function x(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,x(e,r),"throw"===r.method))return y;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var n=p(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,y;var o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function E(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function P(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function L(e){if(e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,o=function r(){for(;++t<e.length;)if(n.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:S}}function S(){return{value:void 0,done:!0}}return d.prototype=m,o(g,"constructor",{value:m,configurable:!0}),o(m,"constructor",{value:d,configurable:!0}),d.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===d||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},w(O.prototype),l(O.prototype,a,(function(){return this})),e.AsyncIterator=O,e.async=function(r,t,n,o,i){void 0===i&&(i=Promise);var u=new O(f(r,t,n,o),i);return e.isGeneratorFunction(t)?u:u.next().then((function(e){return e.done?e.value:u.next()}))},w(g),l(g,c,"Generator"),l(g,u,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=L,_.prototype={constructor:_,reset:function(e){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(P),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function t(t,n){return u.type="throw",u.arg=e,r.next=t,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),a=n.call(i,"finallyLoc");if(s&&a){if(this.prev<i.catchLoc)return t(i.catchLoc,!0);if(this.prev<i.finallyLoc)return t(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return t(i.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return t(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=e,u.arg=r,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(u)},complete:function(e,r){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&&r&&(this.next=r),y},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),P(t),y}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;P(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:L(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),y}},e}function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function c(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach((function(r){l(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function l(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function f(e,r,t,n,o,i,u){try{var s=e[i](u),a=s.value}catch(e){return void t(e)}s.done?r(a):Promise.resolve(a).then(n,o)}function p(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var i=e.apply(r,t);function u(e){f(i,n,o,u,s,"next",e)}function s(e){f(i,n,o,u,s,"throw",e)}u(void 0)}))}}function y(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function h(e,r,t){return r&&y(e.prototype,r),t&&y(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function m(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&v(e,r)}function v(e,r){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},v(e,r)}function j(e){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var t,n=g(e);if(r){var o=g(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return b(this,t)}}function b(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}require("core-js/modules/es.object.define-property.js"),require("core-js/modules/es.array.is-array.js"),require("core-js/modules/es.array.some.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.for-each.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.entries.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.reflect.construct.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.last-index-of.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/es.array.concat.js"),Object.defineProperty(exports,"__esModule",{value:!0});var w=require("@merkur/core"),O=require("graphql"),q=require("@merkur/plugin-error"),x=function(e){m(t,q.GenericError);var r=j(t);function t(){return d(this,t),r.apply(this,arguments)}return h(t)}(),E=function(e){m(t,x);var r=j(t);function t(){return d(this,t),r.apply(this,arguments)}return h(t)}(),P={kind:"Field",name:{kind:"Name",value:"__typename"}},_="development",L="undefined"!=typeof process&&process&&process.env?process.env.NODE_ENV:_;function S(e,r){var o={};if("string"==typeof e)return e;Object.entries(e).forEach((function(e){var i=n(e,2),u=i[0],s=i[1];Array.isArray(s)?s=s.map((function(e){return S(e,r)})):"object"===t(s)&&null!==s&&(s=S(s,r)),o[u]=s}));var i=o.__typename;return i&&r[i]?Reflect.construct(r[i],[o]):o}function k(e){return O.visit(e,{SelectionSet:{enter:function(e,t,n){if(!n||"OperationDefinition"!==n.kind){var o=e.selections;if(o)if(!(o.some((function(e){return"Field"===e.kind&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))||"Field"===n.kind&&n.directives&&n.directives.some((function(e){return"export"===e.name.value}))))return Object.assign({},e,{selections:[].concat(r(o),[P])})}}}})}exports.GraphQLError=x,exports.UnauthorizedError=E,exports.graphqlClientPlugin=function(){return{setup:function(r){return p(s().mark((function t(){return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=c(c({},{graphql:{request:function(r,t){var n=arguments;return p(s().mark((function o(){var i,a,l,f,p,y,h,d,m,v,j,b,g,w,q,P;return s().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return i=n.length>2&&void 0!==n[2]?n[2]:{},a=n.length>3&&void 0!==n[3]?n[3]:{},l=r.$in.graphqlClient,f=l.endpointUrl,p=l.entityClasses,y=a.headers,h=void 0===y?{}:y,d=a.body,m=void 0===d?{}:d,v=u(a,e),t=k(t),o.next=7,r.http.request(c({url:f,method:"POST",headers:c({"Content-Type":"application/json"},h),body:c({query:O.stripIgnoredCharacters(O.print(t)),variables:i},m)},v));case 7:if(j=o.sent,b=j.response,g=b.body,w=g.errors,q=g.data,P=void 0===q?{}:q,!w){o.next=14;break}if(!Array.isArray(w)||!w.some((function(e){return"unauthorized"===e.status}))){o.next=13;break}return o.abrupt("return",Promise.reject(new E("Unauthorized Error",{errors:w,data:P})));case 13:return o.abrupt("return",Promise.reject(new x("Api Error",{errors:w,data:P})));case 14:return o.abrupt("return",S(P,p));case 15:case"end":return o.stop()}}),o)})))()}}}),r),r.$in.graphqlClient={endpointUrl:"",entityClasses:{}},t.abrupt("return",r);case 3:case"end":return t.stop()}}),t)})))()},create:function(e){return p(s().mark((function r(){return s().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(L!==_||e.$in.httpClient){r.next=2;break}throw new Error("You must install missing plugin: npm i @merkur/plugin-http-client");case 2:return w.bindWidgetToFunctions(e,e.graphql),r.abrupt("return",e);case 4:case"end":return r.stop()}}),r)})))()}}},exports.setEndpointUrl=function(e,r){e.$in.graphqlClient.endpointUrl=r},exports.setEntityClasses=function(e,r){e.$in.graphqlClient.entityClasses=function(e){var r={};return e.forEach((function(e){var t=e.entityType;Array.isArray(t)||(t=[t]),t.forEach((function(t){return r[t]=e}))})),r}(r)};
|