andoncloud-widget-preview 1.0.3 → 1.1.1
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/dist/components/{Dashboard.d.ts → Dashboard/index.d.ts} +0 -0
- package/dist/components/{WidgetPreview.d.ts → WidgetPreview/index.d.ts} +0 -0
- package/dist/index.js +3111 -196
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +18 -18
- package/dist/utils/graphql-sdk.d.ts +0 -142
package/dist/index.js
CHANGED
|
@@ -8,6 +8,8 @@ var react = require('@emotion/react');
|
|
|
8
8
|
var reactDom = require('react-dom');
|
|
9
9
|
var require$$0 = require('react-is');
|
|
10
10
|
var iconsMaterial = require('@mui/icons-material');
|
|
11
|
+
var dragIcon_svg = require('../node_modules/andoncloud-dashboard-toolkit/dist/assets/drag-icon.svg');
|
|
12
|
+
var require$$1 = require('../node_modules/andoncloud-dashboard-toolkit/dist/assets/resize-icon.svg');
|
|
11
13
|
|
|
12
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
15
|
|
|
@@ -18,6 +20,8 @@ var react__default = /*#__PURE__*/_interopDefaultLegacy(react);
|
|
|
18
20
|
var reactDom__default = /*#__PURE__*/_interopDefaultLegacy(reactDom);
|
|
19
21
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
20
22
|
var iconsMaterial__default = /*#__PURE__*/_interopDefaultLegacy(iconsMaterial);
|
|
23
|
+
var dragIcon_svg__default = /*#__PURE__*/_interopDefaultLegacy(dragIcon_svg);
|
|
24
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
21
25
|
|
|
22
26
|
function _typeof(obj) {
|
|
23
27
|
"@babel/helpers - typeof";
|
|
@@ -69,6 +73,36 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
69
73
|
return Constructor;
|
|
70
74
|
}
|
|
71
75
|
|
|
76
|
+
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
|
|
77
|
+
var htmlEntities = {
|
|
78
|
+
'&': '&',
|
|
79
|
+
'&': '&',
|
|
80
|
+
'<': '<',
|
|
81
|
+
'<': '<',
|
|
82
|
+
'>': '>',
|
|
83
|
+
'>': '>',
|
|
84
|
+
''': "'",
|
|
85
|
+
''': "'",
|
|
86
|
+
'"': '"',
|
|
87
|
+
'"': '"',
|
|
88
|
+
' ': ' ',
|
|
89
|
+
' ': ' ',
|
|
90
|
+
'©': '©',
|
|
91
|
+
'©': '©',
|
|
92
|
+
'®': '®',
|
|
93
|
+
'®': '®',
|
|
94
|
+
'…': '…',
|
|
95
|
+
'…': '…'
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
|
|
99
|
+
return htmlEntities[m];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
var unescape = function unescape(text) {
|
|
103
|
+
return text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
104
|
+
};
|
|
105
|
+
|
|
72
106
|
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
73
107
|
|
|
74
108
|
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -79,9 +113,10 @@ var defaultOptions = {
|
|
|
79
113
|
transSupportBasicHtmlNodes: true,
|
|
80
114
|
transWrapTextNodes: '',
|
|
81
115
|
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
82
|
-
useSuspense: true
|
|
116
|
+
useSuspense: true,
|
|
117
|
+
unescape: unescape
|
|
83
118
|
};
|
|
84
|
-
|
|
119
|
+
React.createContext();
|
|
85
120
|
function setDefaults() {
|
|
86
121
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
87
122
|
defaultOptions = _objectSpread$7(_objectSpread$7({}, defaultOptions), options);
|
|
@@ -1129,7 +1164,7 @@ var Translator = function (_EventEmitter) {
|
|
|
1129
1164
|
} else {
|
|
1130
1165
|
var pluralSuffix;
|
|
1131
1166
|
if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
|
|
1132
|
-
var zeroSuffix =
|
|
1167
|
+
var zeroSuffix = "".concat(_this4.options.pluralSeparator, "zero");
|
|
1133
1168
|
|
|
1134
1169
|
if (needsPluralHandling) {
|
|
1135
1170
|
finalKeys.push(key + pluralSuffix);
|
|
@@ -2065,6 +2100,8 @@ var Connector = function (_EventEmitter) {
|
|
|
2065
2100
|
_this.waitingReads = [];
|
|
2066
2101
|
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
2067
2102
|
_this.readingCalls = 0;
|
|
2103
|
+
_this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
2104
|
+
_this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
2068
2105
|
_this.state = {};
|
|
2069
2106
|
_this.queue = [];
|
|
2070
2107
|
|
|
@@ -2171,7 +2208,7 @@ var Connector = function (_EventEmitter) {
|
|
|
2171
2208
|
var _this3 = this;
|
|
2172
2209
|
|
|
2173
2210
|
var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
2174
|
-
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] :
|
|
2211
|
+
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
|
|
2175
2212
|
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
2176
2213
|
if (!lng.length) return callback(null, {});
|
|
2177
2214
|
|
|
@@ -2189,13 +2226,6 @@ var Connector = function (_EventEmitter) {
|
|
|
2189
2226
|
|
|
2190
2227
|
this.readingCalls++;
|
|
2191
2228
|
return this.backend[fcName](lng, ns, function (err, data) {
|
|
2192
|
-
if (err && data && tried < 5) {
|
|
2193
|
-
setTimeout(function () {
|
|
2194
|
-
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
2195
|
-
}, wait);
|
|
2196
|
-
return;
|
|
2197
|
-
}
|
|
2198
|
-
|
|
2199
2229
|
_this3.readingCalls--;
|
|
2200
2230
|
|
|
2201
2231
|
if (_this3.waitingReads.length > 0) {
|
|
@@ -2204,6 +2234,13 @@ var Connector = function (_EventEmitter) {
|
|
|
2204
2234
|
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
2205
2235
|
}
|
|
2206
2236
|
|
|
2237
|
+
if (err && data && tried < _this3.maxRetries) {
|
|
2238
|
+
setTimeout(function () {
|
|
2239
|
+
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
2240
|
+
}, wait);
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2207
2244
|
callback(err, data);
|
|
2208
2245
|
});
|
|
2209
2246
|
}
|
|
@@ -2439,7 +2476,7 @@ var I18n = function (_EventEmitter) {
|
|
|
2439
2476
|
options = {};
|
|
2440
2477
|
}
|
|
2441
2478
|
|
|
2442
|
-
if (!options.defaultNS && options.ns) {
|
|
2479
|
+
if (!options.defaultNS && options.defaultNS !== false && options.ns) {
|
|
2443
2480
|
if (typeof options.ns === 'string') {
|
|
2444
2481
|
options.defaultNS = options.ns;
|
|
2445
2482
|
} else if (options.ns.indexOf('translation') < 0) {
|
|
@@ -2795,8 +2832,9 @@ var I18n = function (_EventEmitter) {
|
|
|
2795
2832
|
options.lng = options.lng || fixedT.lng;
|
|
2796
2833
|
options.lngs = options.lngs || fixedT.lngs;
|
|
2797
2834
|
options.ns = options.ns || fixedT.ns;
|
|
2835
|
+
options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
2798
2836
|
var keySeparator = _this5.options.keySeparator || '.';
|
|
2799
|
-
var resultKey = keyPrefix ? "".concat(keyPrefix).concat(keySeparator).concat(key) : key;
|
|
2837
|
+
var resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
|
|
2800
2838
|
return _this5.t(resultKey, options);
|
|
2801
2839
|
};
|
|
2802
2840
|
|
|
@@ -3012,16 +3050,18 @@ function createCommonjsModule(fn) {
|
|
|
3012
3050
|
return fn(module, module.exports), module.exports;
|
|
3013
3051
|
}
|
|
3014
3052
|
|
|
3015
|
-
var
|
|
3053
|
+
var dist_1 = createCommonjsModule(function (module, exports) {
|
|
3016
3054
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
3017
3055
|
|
|
3018
3056
|
|
|
3019
3057
|
var React__default$1 = _interopDefault(React__default["default"]);
|
|
3020
3058
|
|
|
3021
3059
|
|
|
3060
|
+
|
|
3022
3061
|
var reactIs = _interopDefault(require$$0__default["default"]);
|
|
3023
3062
|
|
|
3024
3063
|
|
|
3064
|
+
var resizeIcon = _interopDefault(require$$1__default["default"]);
|
|
3025
3065
|
|
|
3026
3066
|
function _extends() {
|
|
3027
3067
|
_extends = Object.assign || function (target) {
|
|
@@ -3041,6 +3081,21 @@ function _extends() {
|
|
|
3041
3081
|
return _extends.apply(this, arguments);
|
|
3042
3082
|
}
|
|
3043
3083
|
|
|
3084
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
3085
|
+
if (source == null) return {};
|
|
3086
|
+
var target = {};
|
|
3087
|
+
var sourceKeys = Object.keys(source);
|
|
3088
|
+
var key, i;
|
|
3089
|
+
|
|
3090
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
3091
|
+
key = sourceKeys[i];
|
|
3092
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
3093
|
+
target[key] = source[key];
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
return target;
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3044
3099
|
function _taggedTemplateLiteralLoose(strings, raw) {
|
|
3045
3100
|
if (!raw) {
|
|
3046
3101
|
raw = strings.slice(0);
|
|
@@ -3050,8 +3105,69 @@ function _taggedTemplateLiteralLoose(strings, raw) {
|
|
|
3050
3105
|
return strings;
|
|
3051
3106
|
}
|
|
3052
3107
|
|
|
3108
|
+
var styles = {
|
|
3109
|
+
buttons: {
|
|
3110
|
+
paddingTop: function paddingTop(theme) {
|
|
3111
|
+
return theme.spacing(2);
|
|
3112
|
+
}
|
|
3113
|
+
},
|
|
3114
|
+
cancelButton: {
|
|
3115
|
+
marginRight: '10px'
|
|
3116
|
+
},
|
|
3117
|
+
popper: {
|
|
3118
|
+
'.MuiTooltip-tooltip': {
|
|
3119
|
+
padding: '20px',
|
|
3120
|
+
fontSize: '14px',
|
|
3121
|
+
color: 'rgba(0, 0, 0, 0.75)',
|
|
3122
|
+
borderRadius: '8px',
|
|
3123
|
+
backgroundColor: 'white'
|
|
3124
|
+
},
|
|
3125
|
+
'.MuiTooltip-arrow': {
|
|
3126
|
+
color: 'white'
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
};
|
|
3130
|
+
|
|
3131
|
+
var _excluded = ["children", "confirmMessage", "confirmButtonText", "cancelButtonText", "onCancel", "onConfirm"];
|
|
3132
|
+
|
|
3133
|
+
var ConfirmTooltip = function ConfirmTooltip(_ref) {
|
|
3134
|
+
var children = _ref.children,
|
|
3135
|
+
confirmMessage = _ref.confirmMessage,
|
|
3136
|
+
confirmButtonText = _ref.confirmButtonText,
|
|
3137
|
+
cancelButtonText = _ref.cancelButtonText,
|
|
3138
|
+
onCancel = _ref.onCancel,
|
|
3139
|
+
onConfirm = _ref.onConfirm,
|
|
3140
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
3141
|
+
|
|
3142
|
+
return React__default$1.createElement(material__default["default"].Tooltip, Object.assign({}, props, {
|
|
3143
|
+
placement: "bottom-end",
|
|
3144
|
+
title: React__default$1.createElement(material__default["default"].Box, null, React__default$1.createElement(material__default["default"].Typography, null, confirmMessage), React__default$1.createElement(material__default["default"].Stack, {
|
|
3145
|
+
direction: "row",
|
|
3146
|
+
justifyContent: "flex-end",
|
|
3147
|
+
sx: styles.buttons
|
|
3148
|
+
}, React__default$1.createElement(material__default["default"].Button, {
|
|
3149
|
+
color: "secondary",
|
|
3150
|
+
onClick: function onClick(e) {
|
|
3151
|
+
e.stopPropagation();
|
|
3152
|
+
onCancel();
|
|
3153
|
+
},
|
|
3154
|
+
sx: styles.cancelButton
|
|
3155
|
+
}, cancelButtonText), React__default$1.createElement(material__default["default"].Button, {
|
|
3156
|
+
color: "error",
|
|
3157
|
+
onClick: function onClick(e) {
|
|
3158
|
+
e.stopPropagation();
|
|
3159
|
+
onConfirm();
|
|
3160
|
+
}
|
|
3161
|
+
}, confirmButtonText))),
|
|
3162
|
+
PopperProps: {
|
|
3163
|
+
sx: styles.popper
|
|
3164
|
+
},
|
|
3165
|
+
arrow: true
|
|
3166
|
+
}), children);
|
|
3167
|
+
};
|
|
3168
|
+
|
|
3053
3169
|
function _extends$1() {
|
|
3054
|
-
_extends$1 = Object.assign
|
|
3170
|
+
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
3055
3171
|
for (var i = 1; i < arguments.length; i++) {
|
|
3056
3172
|
var source = arguments[i];
|
|
3057
3173
|
|
|
@@ -3064,7 +3180,6 @@ function _extends$1() {
|
|
|
3064
3180
|
|
|
3065
3181
|
return target;
|
|
3066
3182
|
};
|
|
3067
|
-
|
|
3068
3183
|
return _extends$1.apply(this, arguments);
|
|
3069
3184
|
}
|
|
3070
3185
|
|
|
@@ -3080,7 +3195,7 @@ function _taggedTemplateLiteral(strings, raw) {
|
|
|
3080
3195
|
}));
|
|
3081
3196
|
}
|
|
3082
3197
|
|
|
3083
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
3198
|
+
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
3084
3199
|
if (source == null) return {};
|
|
3085
3200
|
var target = {};
|
|
3086
3201
|
var sourceKeys = Object.keys(source);
|
|
@@ -3097,7 +3212,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
3097
3212
|
|
|
3098
3213
|
function _objectWithoutProperties(source, excluded) {
|
|
3099
3214
|
if (source == null) return {};
|
|
3100
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
3215
|
+
var target = _objectWithoutPropertiesLoose$1(source, excluded);
|
|
3101
3216
|
var key, i;
|
|
3102
3217
|
|
|
3103
3218
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -3211,11 +3326,10 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
3211
3326
|
}
|
|
3212
3327
|
|
|
3213
3328
|
function _setPrototypeOf(o, p) {
|
|
3214
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
3329
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
3215
3330
|
o.__proto__ = p;
|
|
3216
3331
|
return o;
|
|
3217
3332
|
};
|
|
3218
|
-
|
|
3219
3333
|
return _setPrototypeOf(o, p);
|
|
3220
3334
|
}
|
|
3221
3335
|
|
|
@@ -4474,7 +4588,7 @@ var GroupHeading = function GroupHeading(props) {
|
|
|
4474
4588
|
}, innerProps));
|
|
4475
4589
|
};
|
|
4476
4590
|
|
|
4477
|
-
var _excluded = ["innerRef", "isDisabled", "isHidden", "inputClassName"];
|
|
4591
|
+
var _excluded$4 = ["innerRef", "isDisabled", "isHidden", "inputClassName"];
|
|
4478
4592
|
var inputCSS = function inputCSS(_ref) {
|
|
4479
4593
|
var isDisabled = _ref.isDisabled,
|
|
4480
4594
|
value = _ref.value,
|
|
@@ -4534,7 +4648,7 @@ var Input = function Input(props) {
|
|
|
4534
4648
|
isDisabled = _cleanCommonProps.isDisabled,
|
|
4535
4649
|
isHidden = _cleanCommonProps.isHidden,
|
|
4536
4650
|
inputClassName = _cleanCommonProps.inputClassName,
|
|
4537
|
-
innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded);
|
|
4651
|
+
innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded$4);
|
|
4538
4652
|
|
|
4539
4653
|
return react__default["default"].jsx("div", {
|
|
4540
4654
|
className: cx({
|
|
@@ -4806,7 +4920,7 @@ var defaultComponents = function defaultComponents(props) {
|
|
|
4806
4920
|
return _objectSpread2(_objectSpread2({}, components), props.components);
|
|
4807
4921
|
};
|
|
4808
4922
|
|
|
4809
|
-
var _excluded$
|
|
4923
|
+
var _excluded$5 = ["defaultInputValue", "defaultMenuIsOpen", "defaultValue", "inputValue", "menuIsOpen", "onChange", "onInputChange", "onMenuClose", "onMenuOpen", "value"];
|
|
4810
4924
|
function useStateManager(_ref) {
|
|
4811
4925
|
var _ref$defaultInputValu = _ref.defaultInputValue,
|
|
4812
4926
|
defaultInputValue = _ref$defaultInputValu === void 0 ? '' : _ref$defaultInputValu,
|
|
@@ -4821,7 +4935,7 @@ function useStateManager(_ref) {
|
|
|
4821
4935
|
propsOnMenuClose = _ref.onMenuClose,
|
|
4822
4936
|
propsOnMenuOpen = _ref.onMenuOpen,
|
|
4823
4937
|
propsValue = _ref.value,
|
|
4824
|
-
restSelectProps = _objectWithoutProperties(_ref, _excluded$
|
|
4938
|
+
restSelectProps = _objectWithoutProperties(_ref, _excluded$5);
|
|
4825
4939
|
|
|
4826
4940
|
var _useState = React__default["default"].useState(propsInputValue !== undefined ? propsInputValue : defaultInputValue),
|
|
4827
4941
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -5490,10 +5604,10 @@ var createFilter = function createFilter(config) {
|
|
|
5490
5604
|
};
|
|
5491
5605
|
};
|
|
5492
5606
|
|
|
5493
|
-
var _excluded$
|
|
5607
|
+
var _excluded$6 = ["innerRef"];
|
|
5494
5608
|
function DummyInput(_ref) {
|
|
5495
5609
|
var innerRef = _ref.innerRef,
|
|
5496
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
5610
|
+
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
5497
5611
|
|
|
5498
5612
|
// Remove animation props not meant for HTML elements
|
|
5499
5613
|
var filteredProps = removeProps(props, 'onExited', 'in', 'enter', 'exit', 'appear');
|
|
@@ -6768,7 +6882,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6768
6882
|
}
|
|
6769
6883
|
|
|
6770
6884
|
if (isFocused && isDisabled && !prevProps.isDisabled) {
|
|
6771
|
-
// ensure select state gets blurred in case Select is
|
|
6885
|
+
// ensure select state gets blurred in case Select is programmatically disabled while focused
|
|
6772
6886
|
// eslint-disable-next-line react/no-did-update-set-state
|
|
6773
6887
|
this.setState({
|
|
6774
6888
|
isFocused: false
|
|
@@ -7675,6 +7789,10 @@ function createCommonjsModule(fn, module) {
|
|
|
7675
7789
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
7676
7790
|
}
|
|
7677
7791
|
|
|
7792
|
+
function getCjsExportFromNamespace (n) {
|
|
7793
|
+
return n && n['default'] || n;
|
|
7794
|
+
}
|
|
7795
|
+
|
|
7678
7796
|
function commonjsRequire () {
|
|
7679
7797
|
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
7680
7798
|
}
|
|
@@ -7774,7 +7892,7 @@ function _slicedToArray(arr, i) {
|
|
|
7774
7892
|
module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
7775
7893
|
});
|
|
7776
7894
|
|
|
7777
|
-
unwrapExports(slicedToArray);
|
|
7895
|
+
var _slicedToArray$1 = unwrapExports(slicedToArray);
|
|
7778
7896
|
|
|
7779
7897
|
var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
|
|
7780
7898
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
@@ -7915,7 +8033,7 @@ function _defineProperty(obj, key, value) {
|
|
|
7915
8033
|
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
7916
8034
|
});
|
|
7917
8035
|
|
|
7918
|
-
unwrapExports(defineProperty);
|
|
8036
|
+
var _defineProperty$2 = unwrapExports(defineProperty);
|
|
7919
8037
|
|
|
7920
8038
|
var StateManagedSelect = /*#__PURE__*/React__default["default"].forwardRef(function (props, ref) {
|
|
7921
8039
|
var baseSelectProps = useStateManager(props);
|
|
@@ -7962,7 +8080,7 @@ function _possibleConstructorReturn$1(self, call) {
|
|
|
7962
8080
|
}
|
|
7963
8081
|
|
|
7964
8082
|
function _getPrototypeOf$1(o) {
|
|
7965
|
-
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
8083
|
+
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
7966
8084
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
7967
8085
|
};
|
|
7968
8086
|
return _getPrototypeOf$1(o);
|
|
@@ -10542,24 +10660,481 @@ var SortableSelect = function SortableSelect(_ref) {
|
|
|
10542
10660
|
});
|
|
10543
10661
|
};
|
|
10544
10662
|
|
|
10545
|
-
var
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10663
|
+
var classCallCheck = createCommonjsModule(function (module) {
|
|
10664
|
+
function _classCallCheck(instance, Constructor) {
|
|
10665
|
+
if (!(instance instanceof Constructor)) {
|
|
10666
|
+
throw new TypeError("Cannot call a class as a function");
|
|
10667
|
+
}
|
|
10668
|
+
}
|
|
10669
|
+
|
|
10670
|
+
module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
10671
|
+
});
|
|
10672
|
+
|
|
10673
|
+
var _classCallCheck$1 = unwrapExports(classCallCheck);
|
|
10674
|
+
|
|
10675
|
+
var createClass = createCommonjsModule(function (module) {
|
|
10676
|
+
function _defineProperties(target, props) {
|
|
10677
|
+
for (var i = 0; i < props.length; i++) {
|
|
10678
|
+
var descriptor = props[i];
|
|
10679
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10680
|
+
descriptor.configurable = true;
|
|
10681
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
10682
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
10683
|
+
}
|
|
10684
|
+
}
|
|
10685
|
+
|
|
10686
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
10687
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
10688
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
10689
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
10690
|
+
writable: false
|
|
10691
|
+
});
|
|
10692
|
+
return Constructor;
|
|
10693
|
+
}
|
|
10694
|
+
|
|
10695
|
+
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
10696
|
+
});
|
|
10697
|
+
|
|
10698
|
+
var _createClass$1 = unwrapExports(createClass);
|
|
10699
|
+
|
|
10700
|
+
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
|
|
10701
|
+
var htmlEntities = {
|
|
10702
|
+
'&': '&',
|
|
10703
|
+
'&': '&',
|
|
10704
|
+
'<': '<',
|
|
10705
|
+
'<': '<',
|
|
10706
|
+
'>': '>',
|
|
10707
|
+
'>': '>',
|
|
10708
|
+
''': "'",
|
|
10709
|
+
''': "'",
|
|
10710
|
+
'"': '"',
|
|
10711
|
+
'"': '"',
|
|
10712
|
+
' ': ' ',
|
|
10713
|
+
' ': ' ',
|
|
10714
|
+
'©': '©',
|
|
10715
|
+
'©': '©',
|
|
10716
|
+
'®': '®',
|
|
10717
|
+
'®': '®',
|
|
10718
|
+
'…': '…',
|
|
10719
|
+
'…': '…'
|
|
10720
|
+
};
|
|
10721
|
+
|
|
10722
|
+
var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
|
|
10723
|
+
return htmlEntities[m];
|
|
10560
10724
|
};
|
|
10561
10725
|
|
|
10562
|
-
|
|
10726
|
+
var unescape = function unescape(text) {
|
|
10727
|
+
return text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
10728
|
+
};
|
|
10729
|
+
|
|
10730
|
+
var defaultOptions = {
|
|
10731
|
+
bindI18n: 'languageChanged',
|
|
10732
|
+
bindI18nStore: '',
|
|
10733
|
+
transEmptyNodeValue: '',
|
|
10734
|
+
transSupportBasicHtmlNodes: true,
|
|
10735
|
+
transWrapTextNodes: '',
|
|
10736
|
+
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
10737
|
+
useSuspense: true,
|
|
10738
|
+
unescape: unescape
|
|
10739
|
+
};
|
|
10740
|
+
var i18nInstance;
|
|
10741
|
+
var I18nContext = React__default["default"].createContext();
|
|
10742
|
+
function getDefaults() {
|
|
10743
|
+
return defaultOptions;
|
|
10744
|
+
}
|
|
10745
|
+
var ReportNamespaces = function () {
|
|
10746
|
+
function ReportNamespaces() {
|
|
10747
|
+
_classCallCheck$1(this, ReportNamespaces);
|
|
10748
|
+
|
|
10749
|
+
this.usedNamespaces = {};
|
|
10750
|
+
}
|
|
10751
|
+
|
|
10752
|
+
_createClass$1(ReportNamespaces, [{
|
|
10753
|
+
key: "addUsedNamespaces",
|
|
10754
|
+
value: function addUsedNamespaces(namespaces) {
|
|
10755
|
+
var _this = this;
|
|
10756
|
+
|
|
10757
|
+
namespaces.forEach(function (ns) {
|
|
10758
|
+
if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
|
|
10759
|
+
});
|
|
10760
|
+
}
|
|
10761
|
+
}, {
|
|
10762
|
+
key: "getUsedNamespaces",
|
|
10763
|
+
value: function getUsedNamespaces() {
|
|
10764
|
+
return Object.keys(this.usedNamespaces);
|
|
10765
|
+
}
|
|
10766
|
+
}]);
|
|
10767
|
+
|
|
10768
|
+
return ReportNamespaces;
|
|
10769
|
+
}();
|
|
10770
|
+
function getI18n() {
|
|
10771
|
+
return i18nInstance;
|
|
10772
|
+
}
|
|
10773
|
+
|
|
10774
|
+
function warn() {
|
|
10775
|
+
if (console && console.warn) {
|
|
10776
|
+
var _console;
|
|
10777
|
+
|
|
10778
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10779
|
+
args[_key] = arguments[_key];
|
|
10780
|
+
}
|
|
10781
|
+
|
|
10782
|
+
if (typeof args[0] === 'string') args[0] = "react-i18next:: ".concat(args[0]);
|
|
10783
|
+
|
|
10784
|
+
(_console = console).warn.apply(_console, args);
|
|
10785
|
+
}
|
|
10786
|
+
}
|
|
10787
|
+
var alreadyWarned = {};
|
|
10788
|
+
function warnOnce() {
|
|
10789
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
10790
|
+
args[_key2] = arguments[_key2];
|
|
10791
|
+
}
|
|
10792
|
+
|
|
10793
|
+
if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
|
|
10794
|
+
if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
|
|
10795
|
+
warn.apply(void 0, args);
|
|
10796
|
+
}
|
|
10797
|
+
function loadNamespaces(i18n, ns, cb) {
|
|
10798
|
+
i18n.loadNamespaces(ns, function () {
|
|
10799
|
+
if (i18n.isInitialized) {
|
|
10800
|
+
cb();
|
|
10801
|
+
} else {
|
|
10802
|
+
var initialized = function initialized() {
|
|
10803
|
+
setTimeout(function () {
|
|
10804
|
+
i18n.off('initialized', initialized);
|
|
10805
|
+
}, 0);
|
|
10806
|
+
cb();
|
|
10807
|
+
};
|
|
10808
|
+
|
|
10809
|
+
i18n.on('initialized', initialized);
|
|
10810
|
+
}
|
|
10811
|
+
});
|
|
10812
|
+
}
|
|
10813
|
+
|
|
10814
|
+
function oldI18nextHasLoadedNamespace(ns, i18n) {
|
|
10815
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10816
|
+
var lng = i18n.languages[0];
|
|
10817
|
+
var fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
|
|
10818
|
+
var lastLng = i18n.languages[i18n.languages.length - 1];
|
|
10819
|
+
if (lng.toLowerCase() === 'cimode') return true;
|
|
10820
|
+
|
|
10821
|
+
var loadNotPending = function loadNotPending(l, n) {
|
|
10822
|
+
var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
|
|
10823
|
+
return loadState === -1 || loadState === 2;
|
|
10824
|
+
};
|
|
10825
|
+
|
|
10826
|
+
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
|
|
10827
|
+
if (i18n.hasResourceBundle(lng, ns)) return true;
|
|
10828
|
+
if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
|
|
10829
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
10830
|
+
return false;
|
|
10831
|
+
}
|
|
10832
|
+
|
|
10833
|
+
function hasLoadedNamespace(ns, i18n) {
|
|
10834
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10835
|
+
|
|
10836
|
+
if (!i18n.languages || !i18n.languages.length) {
|
|
10837
|
+
warnOnce('i18n.languages were undefined or empty', i18n.languages);
|
|
10838
|
+
return true;
|
|
10839
|
+
}
|
|
10840
|
+
|
|
10841
|
+
var isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
|
|
10842
|
+
|
|
10843
|
+
if (!isNewerI18next) {
|
|
10844
|
+
return oldI18nextHasLoadedNamespace(ns, i18n, options);
|
|
10845
|
+
}
|
|
10846
|
+
|
|
10847
|
+
return i18n.hasLoadedNamespace(ns, {
|
|
10848
|
+
precheck: function precheck(i18nInstance, loadNotPending) {
|
|
10849
|
+
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
|
|
10850
|
+
}
|
|
10851
|
+
});
|
|
10852
|
+
}
|
|
10853
|
+
|
|
10854
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
10855
|
+
|
|
10856
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10857
|
+
|
|
10858
|
+
var usePrevious = function usePrevious(value, ignore) {
|
|
10859
|
+
var ref = React__default["default"].useRef();
|
|
10860
|
+
React__default["default"].useEffect(function () {
|
|
10861
|
+
ref.current = ignore ? ref.current : value;
|
|
10862
|
+
}, [value, ignore]);
|
|
10863
|
+
return ref.current;
|
|
10864
|
+
};
|
|
10865
|
+
|
|
10866
|
+
function useTranslation(ns) {
|
|
10867
|
+
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10868
|
+
var i18nFromProps = props.i18n;
|
|
10869
|
+
|
|
10870
|
+
var _ref = React__default["default"].useContext(I18nContext) || {},
|
|
10871
|
+
i18nFromContext = _ref.i18n,
|
|
10872
|
+
defaultNSFromContext = _ref.defaultNS;
|
|
10873
|
+
|
|
10874
|
+
var i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
10875
|
+
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
|
|
10876
|
+
|
|
10877
|
+
if (!i18n) {
|
|
10878
|
+
warnOnce('You will need to pass in an i18next instance by using initReactI18next');
|
|
10879
|
+
|
|
10880
|
+
var notReadyT = function notReadyT(k) {
|
|
10881
|
+
return Array.isArray(k) ? k[k.length - 1] : k;
|
|
10882
|
+
};
|
|
10883
|
+
|
|
10884
|
+
var retNotReady = [notReadyT, {}, false];
|
|
10885
|
+
retNotReady.t = notReadyT;
|
|
10886
|
+
retNotReady.i18n = {};
|
|
10887
|
+
retNotReady.ready = false;
|
|
10888
|
+
return retNotReady;
|
|
10889
|
+
}
|
|
10890
|
+
|
|
10891
|
+
if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
10892
|
+
|
|
10893
|
+
var i18nOptions = _objectSpread$1(_objectSpread$1(_objectSpread$1({}, getDefaults()), i18n.options.react), props);
|
|
10894
|
+
|
|
10895
|
+
var useSuspense = i18nOptions.useSuspense,
|
|
10896
|
+
keyPrefix = i18nOptions.keyPrefix;
|
|
10897
|
+
var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
|
|
10898
|
+
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
|
|
10899
|
+
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
|
|
10900
|
+
var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(function (n) {
|
|
10901
|
+
return hasLoadedNamespace(n, i18n, i18nOptions);
|
|
10902
|
+
});
|
|
10903
|
+
|
|
10904
|
+
function getT() {
|
|
10905
|
+
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
|
|
10906
|
+
}
|
|
10907
|
+
|
|
10908
|
+
var _useState = React__default["default"].useState(getT),
|
|
10909
|
+
_useState2 = _slicedToArray$1(_useState, 2),
|
|
10910
|
+
t = _useState2[0],
|
|
10911
|
+
setT = _useState2[1];
|
|
10912
|
+
|
|
10913
|
+
var joinedNS = namespaces.join();
|
|
10914
|
+
var previousJoinedNS = usePrevious(joinedNS);
|
|
10915
|
+
var isMounted = React__default["default"].useRef(true);
|
|
10916
|
+
React__default["default"].useEffect(function () {
|
|
10917
|
+
var bindI18n = i18nOptions.bindI18n,
|
|
10918
|
+
bindI18nStore = i18nOptions.bindI18nStore;
|
|
10919
|
+
isMounted.current = true;
|
|
10920
|
+
|
|
10921
|
+
if (!ready && !useSuspense) {
|
|
10922
|
+
loadNamespaces(i18n, namespaces, function () {
|
|
10923
|
+
if (isMounted.current) setT(getT);
|
|
10924
|
+
});
|
|
10925
|
+
}
|
|
10926
|
+
|
|
10927
|
+
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
|
|
10928
|
+
setT(getT);
|
|
10929
|
+
}
|
|
10930
|
+
|
|
10931
|
+
function boundReset() {
|
|
10932
|
+
if (isMounted.current) setT(getT);
|
|
10933
|
+
}
|
|
10934
|
+
|
|
10935
|
+
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
10936
|
+
if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
|
|
10937
|
+
return function () {
|
|
10938
|
+
isMounted.current = false;
|
|
10939
|
+
if (bindI18n && i18n) bindI18n.split(' ').forEach(function (e) {
|
|
10940
|
+
return i18n.off(e, boundReset);
|
|
10941
|
+
});
|
|
10942
|
+
if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(function (e) {
|
|
10943
|
+
return i18n.store.off(e, boundReset);
|
|
10944
|
+
});
|
|
10945
|
+
};
|
|
10946
|
+
}, [i18n, joinedNS]);
|
|
10947
|
+
var isInitial = React__default["default"].useRef(true);
|
|
10948
|
+
React__default["default"].useEffect(function () {
|
|
10949
|
+
if (isMounted.current && !isInitial.current) {
|
|
10950
|
+
setT(getT);
|
|
10951
|
+
}
|
|
10952
|
+
|
|
10953
|
+
isInitial.current = false;
|
|
10954
|
+
}, [i18n, keyPrefix]);
|
|
10955
|
+
var ret = [t, i18n, ready];
|
|
10956
|
+
ret.t = t;
|
|
10957
|
+
ret.i18n = i18n;
|
|
10958
|
+
ret.ready = ready;
|
|
10959
|
+
if (ready) return ret;
|
|
10960
|
+
if (!ready && !useSuspense) return ret;
|
|
10961
|
+
throw new Promise(function (resolve) {
|
|
10962
|
+
loadNamespaces(i18n, namespaces, function () {
|
|
10963
|
+
resolve();
|
|
10964
|
+
});
|
|
10965
|
+
});
|
|
10966
|
+
}
|
|
10967
|
+
|
|
10968
|
+
var styles$1 = {
|
|
10969
|
+
root: {
|
|
10970
|
+
boxShadow: 'none',
|
|
10971
|
+
'& .react-resizable-handle': {
|
|
10972
|
+
width: '24px',
|
|
10973
|
+
height: '24px',
|
|
10974
|
+
borderRadius: '4px',
|
|
10975
|
+
background: function background(theme) {
|
|
10976
|
+
return theme.palette.primary.main + " url(" + resizeIcon + ")";
|
|
10977
|
+
},
|
|
10978
|
+
backgroundRepeat: 'no-repeat',
|
|
10979
|
+
backgroundSize: '50%',
|
|
10980
|
+
backgroundPosition: '50%',
|
|
10981
|
+
'&:hover': {
|
|
10982
|
+
backgroundColor: function backgroundColor(theme) {
|
|
10983
|
+
return theme.palette.primary.dark;
|
|
10984
|
+
}
|
|
10985
|
+
}
|
|
10986
|
+
},
|
|
10987
|
+
'& .react-resizable-handle:after': {
|
|
10988
|
+
display: 'none'
|
|
10989
|
+
}
|
|
10990
|
+
},
|
|
10991
|
+
header: {
|
|
10992
|
+
height: '40px'
|
|
10993
|
+
},
|
|
10994
|
+
dragIcon: {
|
|
10995
|
+
width: '30px',
|
|
10996
|
+
height: '30px',
|
|
10997
|
+
marginLeft: function marginLeft(theme) {
|
|
10998
|
+
return "-" + theme.spacing(1);
|
|
10999
|
+
},
|
|
11000
|
+
padding: '8px',
|
|
11001
|
+
borderRadius: '4px',
|
|
11002
|
+
background: function background(theme) {
|
|
11003
|
+
return theme.palette.primary.main;
|
|
11004
|
+
},
|
|
11005
|
+
'&:hover': {
|
|
11006
|
+
cursor: 'move',
|
|
11007
|
+
background: function background(theme) {
|
|
11008
|
+
return theme.palette.primary.dark;
|
|
11009
|
+
}
|
|
11010
|
+
}
|
|
11011
|
+
},
|
|
11012
|
+
actionButtons: {
|
|
11013
|
+
height: '30px',
|
|
11014
|
+
marginTop: '-7px'
|
|
11015
|
+
},
|
|
11016
|
+
settingsButton: {
|
|
11017
|
+
color: 'rgba(255, 255, 255, 0.45)',
|
|
11018
|
+
borderRadius: '4px',
|
|
11019
|
+
borderTopRightRadius: 0,
|
|
11020
|
+
borderBottomRightRadius: 0
|
|
11021
|
+
},
|
|
11022
|
+
deleteButton: {
|
|
11023
|
+
color: 'rgba(255, 255, 255, 0.45)',
|
|
11024
|
+
marginLeft: '1px',
|
|
11025
|
+
borderRadius: '4px',
|
|
11026
|
+
borderTopLeftRadius: 0,
|
|
11027
|
+
borderBottomLeftRadius: 0
|
|
11028
|
+
},
|
|
11029
|
+
content: {
|
|
11030
|
+
height: 'calc(100% - 40px)',
|
|
11031
|
+
padding: 0,
|
|
11032
|
+
background: 'transparent',
|
|
11033
|
+
border: '1px solid rgba(255, 255, 255, 0.2)',
|
|
11034
|
+
borderTop: 'none',
|
|
11035
|
+
borderRadius: '4px',
|
|
11036
|
+
boxShadow: '0px 4px 8px rgba(0, 0, 0, 0.25)'
|
|
11037
|
+
}
|
|
11038
|
+
};
|
|
11039
|
+
|
|
11040
|
+
var _excluded$7 = ["children", "title", "Widget", "id", "url", "token", "lang", "data", "settings", "openSettingsModal", "onSettingsModalOpened", "onSettingsModalClosed", "onDelete", "editMode"];
|
|
11041
|
+
var WidgetCard = React__default$1.forwardRef(function (_ref, ref) {
|
|
11042
|
+
var children = _ref.children,
|
|
11043
|
+
title = _ref.title,
|
|
11044
|
+
Widget = _ref.Widget,
|
|
11045
|
+
id = _ref.id,
|
|
11046
|
+
url = _ref.url,
|
|
11047
|
+
token = _ref.token,
|
|
11048
|
+
lang = _ref.lang,
|
|
11049
|
+
data = _ref.data,
|
|
11050
|
+
settings = _ref.settings,
|
|
11051
|
+
openSettingsModal = _ref.openSettingsModal,
|
|
11052
|
+
onSettingsModalOpened = _ref.onSettingsModalOpened,
|
|
11053
|
+
onSettingsModalClosed = _ref.onSettingsModalClosed,
|
|
11054
|
+
onDelete = _ref.onDelete,
|
|
11055
|
+
editMode = _ref.editMode,
|
|
11056
|
+
cardProps = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
11057
|
+
|
|
11058
|
+
var _useState = React__default["default"].useState(false),
|
|
11059
|
+
removeTooltipOpened = _useState[0],
|
|
11060
|
+
setRemoveTooltipOpened = _useState[1];
|
|
11061
|
+
|
|
11062
|
+
var _useTranslation = useTranslation(),
|
|
11063
|
+
t = _useTranslation.t;
|
|
11064
|
+
|
|
11065
|
+
var handleOpenSettingsModal = function handleOpenSettingsModal() {
|
|
11066
|
+
if (onSettingsModalOpened) onSettingsModalOpened();
|
|
11067
|
+
};
|
|
11068
|
+
|
|
11069
|
+
var handleDelete = function handleDelete() {
|
|
11070
|
+
if (onDelete) onDelete();
|
|
11071
|
+
setRemoveTooltipOpened(false);
|
|
11072
|
+
};
|
|
11073
|
+
|
|
11074
|
+
var renderDragHandle = function renderDragHandle() {
|
|
11075
|
+
return React__default$1.createElement(material__default["default"].SvgIcon, {
|
|
11076
|
+
component: dragIcon_svg__default["default"].ReactComponent,
|
|
11077
|
+
className: "draggable-handle",
|
|
11078
|
+
sx: styles$1.dragIcon,
|
|
11079
|
+
inheritViewBox: true
|
|
11080
|
+
});
|
|
11081
|
+
};
|
|
11082
|
+
|
|
11083
|
+
var renderActionButtons = function renderActionButtons() {
|
|
11084
|
+
return React__default$1.createElement(material__default["default"].Stack, {
|
|
11085
|
+
direction: "row",
|
|
11086
|
+
sx: styles$1.actionButtons
|
|
11087
|
+
}, React__default$1.createElement(material__default["default"].Button, {
|
|
11088
|
+
color: "secondary",
|
|
11089
|
+
sx: styles$1.settingsButton,
|
|
11090
|
+
onClick: handleOpenSettingsModal
|
|
11091
|
+
}, React__default$1.createElement(iconsMaterial__default["default"].Settings, null)), React__default$1.createElement(ConfirmTooltip, {
|
|
11092
|
+
open: removeTooltipOpened,
|
|
11093
|
+
confirmMessage: t('Are you sure you want to delete this widget?'),
|
|
11094
|
+
confirmButtonText: t('Delete'),
|
|
11095
|
+
cancelButtonText: t('Cancel'),
|
|
11096
|
+
onCancel: function onCancel() {
|
|
11097
|
+
return setRemoveTooltipOpened(false);
|
|
11098
|
+
},
|
|
11099
|
+
onConfirm: handleDelete
|
|
11100
|
+
}, React__default$1.createElement(material__default["default"].Button, {
|
|
11101
|
+
color: "secondary",
|
|
11102
|
+
sx: styles$1.deleteButton,
|
|
11103
|
+
onClick: function onClick(e) {
|
|
11104
|
+
e.stopPropagation();
|
|
11105
|
+
setRemoveTooltipOpened(true);
|
|
11106
|
+
}
|
|
11107
|
+
}, React__default$1.createElement(iconsMaterial__default["default"].Delete, null))));
|
|
11108
|
+
};
|
|
11109
|
+
|
|
11110
|
+
return React__default$1.createElement(material__default["default"].Card, Object.assign({
|
|
11111
|
+
ref: ref,
|
|
11112
|
+
sx: styles$1.root
|
|
11113
|
+
}, cardProps), React__default$1.createElement(material__default["default"].CardHeader, {
|
|
11114
|
+
avatar: editMode && renderDragHandle(),
|
|
11115
|
+
title: title,
|
|
11116
|
+
titleTypographyProps: {
|
|
11117
|
+
variant: 'subtitle1'
|
|
11118
|
+
},
|
|
11119
|
+
action: editMode && renderActionButtons(),
|
|
11120
|
+
sx: styles$1.header
|
|
11121
|
+
}), React__default$1.createElement(material__default["default"].CardContent, {
|
|
11122
|
+
sx: styles$1.content
|
|
11123
|
+
}, React__default$1.createElement(Widget, {
|
|
11124
|
+
id: id,
|
|
11125
|
+
url: url,
|
|
11126
|
+
token: token,
|
|
11127
|
+
lang: lang,
|
|
11128
|
+
data: data,
|
|
11129
|
+
settings: settings,
|
|
11130
|
+
openSettingsModal: openSettingsModal,
|
|
11131
|
+
onSettingsModalOpened: onSettingsModalOpened,
|
|
11132
|
+
onSettingsModalClosed: onSettingsModalClosed,
|
|
11133
|
+
editMode: editMode
|
|
11134
|
+
})), editMode && children);
|
|
11135
|
+
});
|
|
11136
|
+
|
|
11137
|
+
/******************************************************************************
|
|
10563
11138
|
Copyright (c) Microsoft Corporation.
|
|
10564
11139
|
|
|
10565
11140
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -10691,17 +11266,17 @@ function leftPad(len, str) {
|
|
|
10691
11266
|
|
|
10692
11267
|
function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
|
|
10693
11268
|
|
|
10694
|
-
function ownKeys$
|
|
11269
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
10695
11270
|
|
|
10696
|
-
function _objectSpread$
|
|
11271
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty$3(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10697
11272
|
|
|
10698
|
-
function _defineProperty$
|
|
11273
|
+
function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10699
11274
|
|
|
10700
|
-
function _classCallCheck$
|
|
11275
|
+
function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10701
11276
|
|
|
10702
11277
|
function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
10703
11278
|
|
|
10704
|
-
function _createClass$
|
|
11279
|
+
function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
|
|
10705
11280
|
|
|
10706
11281
|
function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$1(subClass, superClass); }
|
|
10707
11282
|
|
|
@@ -10780,7 +11355,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
10780
11355
|
|
|
10781
11356
|
var _this;
|
|
10782
11357
|
|
|
10783
|
-
_classCallCheck$
|
|
11358
|
+
_classCallCheck$2(this, GraphQLError);
|
|
10784
11359
|
|
|
10785
11360
|
_this = _super.call(this, message);
|
|
10786
11361
|
_this.name = 'GraphQLError';
|
|
@@ -10815,7 +11390,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
10815
11390
|
var originalExtensions = originalError === null || originalError === void 0 ? void 0 : originalError.extensions;
|
|
10816
11391
|
|
|
10817
11392
|
if (extensions == null && isObjectLike(originalExtensions)) {
|
|
10818
|
-
_this.extensions = _objectSpread$
|
|
11393
|
+
_this.extensions = _objectSpread$2({}, originalExtensions);
|
|
10819
11394
|
} else {
|
|
10820
11395
|
_this.extensions = extensions !== null && extensions !== void 0 ? extensions : {};
|
|
10821
11396
|
} // By being enumerable, JSON.stringify will include bellow properties in the resulting output.
|
|
@@ -10875,7 +11450,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
10875
11450
|
return _this;
|
|
10876
11451
|
}
|
|
10877
11452
|
|
|
10878
|
-
_createClass$
|
|
11453
|
+
_createClass$2(GraphQLError, [{
|
|
10879
11454
|
key: "toString",
|
|
10880
11455
|
value: function toString() {
|
|
10881
11456
|
return printError(this);
|
|
@@ -11125,6 +11700,13 @@ var Token = /*#__PURE__*/function () {
|
|
|
11125
11700
|
}(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
|
|
11126
11701
|
|
|
11127
11702
|
defineInspect(Token);
|
|
11703
|
+
/**
|
|
11704
|
+
* @internal
|
|
11705
|
+
*/
|
|
11706
|
+
|
|
11707
|
+
function isNode(maybeNode) {
|
|
11708
|
+
return maybeNode != null && typeof maybeNode.kind === 'string';
|
|
11709
|
+
}
|
|
11128
11710
|
/**
|
|
11129
11711
|
* The list of all possible AST node types.
|
|
11130
11712
|
*/
|
|
@@ -11327,7 +11909,7 @@ function instanceOf(value, constructor) {
|
|
|
11327
11909
|
|
|
11328
11910
|
function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11329
11911
|
|
|
11330
|
-
function _createClass$
|
|
11912
|
+
function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; }
|
|
11331
11913
|
|
|
11332
11914
|
/**
|
|
11333
11915
|
* A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
|
|
@@ -11352,7 +11934,7 @@ var Source = /*#__PURE__*/function () {
|
|
|
11352
11934
|
} // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
11353
11935
|
|
|
11354
11936
|
|
|
11355
|
-
_createClass$
|
|
11937
|
+
_createClass$3(Source, [{
|
|
11356
11938
|
key: SYMBOL_TO_STRING_TAG,
|
|
11357
11939
|
get: function get() {
|
|
11358
11940
|
return 'Source';
|
|
@@ -11496,6 +12078,36 @@ function getBlockStringIndentation(value) {
|
|
|
11496
12078
|
|
|
11497
12079
|
return (_commonIndent = commonIndent) !== null && _commonIndent !== void 0 ? _commonIndent : 0;
|
|
11498
12080
|
}
|
|
12081
|
+
/**
|
|
12082
|
+
* Print a block string in the indented block form by adding a leading and
|
|
12083
|
+
* trailing blank line. However, if a block string starts with whitespace and is
|
|
12084
|
+
* a single-line, adding a leading blank line would strip that whitespace.
|
|
12085
|
+
*
|
|
12086
|
+
* @internal
|
|
12087
|
+
*/
|
|
12088
|
+
|
|
12089
|
+
function printBlockString(value) {
|
|
12090
|
+
var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
12091
|
+
var preferMultipleLines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
12092
|
+
var isSingleLine = value.indexOf('\n') === -1;
|
|
12093
|
+
var hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
|
|
12094
|
+
var hasTrailingQuote = value[value.length - 1] === '"';
|
|
12095
|
+
var hasTrailingSlash = value[value.length - 1] === '\\';
|
|
12096
|
+
var printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;
|
|
12097
|
+
var result = ''; // Format a multi-line block quote to account for leading space.
|
|
12098
|
+
|
|
12099
|
+
if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {
|
|
12100
|
+
result += '\n' + indentation;
|
|
12101
|
+
}
|
|
12102
|
+
|
|
12103
|
+
result += indentation ? value.replace(/\n/g, '\n' + indentation) : value;
|
|
12104
|
+
|
|
12105
|
+
if (printAsMultipleLines) {
|
|
12106
|
+
result += '\n';
|
|
12107
|
+
}
|
|
12108
|
+
|
|
12109
|
+
return '"""' + result.replace(/"""/g, '\\"""') + '"""';
|
|
12110
|
+
}
|
|
11499
12111
|
|
|
11500
12112
|
/**
|
|
11501
12113
|
* Given a Source object, creates a Lexer for that source.
|
|
@@ -12183,8 +12795,44 @@ function parse(source, options) {
|
|
|
12183
12795
|
return parser.parseDocument();
|
|
12184
12796
|
}
|
|
12185
12797
|
/**
|
|
12186
|
-
*
|
|
12187
|
-
*
|
|
12798
|
+
* Given a string containing a GraphQL value (ex. `[42]`), parse the AST for
|
|
12799
|
+
* that value.
|
|
12800
|
+
* Throws GraphQLError if a syntax error is encountered.
|
|
12801
|
+
*
|
|
12802
|
+
* This is useful within tools that operate upon GraphQL Values directly and
|
|
12803
|
+
* in isolation of complete GraphQL documents.
|
|
12804
|
+
*
|
|
12805
|
+
* Consider providing the results to the utility function: valueFromAST().
|
|
12806
|
+
*/
|
|
12807
|
+
|
|
12808
|
+
function parseValue(source, options) {
|
|
12809
|
+
var parser = new Parser(source, options);
|
|
12810
|
+
parser.expectToken(TokenKind.SOF);
|
|
12811
|
+
var value = parser.parseValueLiteral(false);
|
|
12812
|
+
parser.expectToken(TokenKind.EOF);
|
|
12813
|
+
return value;
|
|
12814
|
+
}
|
|
12815
|
+
/**
|
|
12816
|
+
* Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
|
|
12817
|
+
* that type.
|
|
12818
|
+
* Throws GraphQLError if a syntax error is encountered.
|
|
12819
|
+
*
|
|
12820
|
+
* This is useful within tools that operate upon GraphQL Types directly and
|
|
12821
|
+
* in isolation of complete GraphQL documents.
|
|
12822
|
+
*
|
|
12823
|
+
* Consider providing the results to the utility function: typeFromAST().
|
|
12824
|
+
*/
|
|
12825
|
+
|
|
12826
|
+
function parseType(source, options) {
|
|
12827
|
+
var parser = new Parser(source, options);
|
|
12828
|
+
parser.expectToken(TokenKind.SOF);
|
|
12829
|
+
var type = parser.parseTypeReference();
|
|
12830
|
+
parser.expectToken(TokenKind.EOF);
|
|
12831
|
+
return type;
|
|
12832
|
+
}
|
|
12833
|
+
/**
|
|
12834
|
+
* This class is exported only to assist people in implementing their own parsers
|
|
12835
|
+
* without duplicating too much code and should be used only as last resort for cases
|
|
12188
12836
|
* such as experimental syntax or if certain features could not be contributed upstream.
|
|
12189
12837
|
*
|
|
12190
12838
|
* It is still part of the internal API and is versioned, so any changes to it are never
|
|
@@ -13675,6 +14323,659 @@ function getTokenKindDesc(kind) {
|
|
|
13675
14323
|
return isPunctuatorTokenKind(kind) ? "\"".concat(kind, "\"") : kind;
|
|
13676
14324
|
}
|
|
13677
14325
|
|
|
14326
|
+
var parser = {
|
|
14327
|
+
__proto__: null,
|
|
14328
|
+
parse: parse,
|
|
14329
|
+
parseValue: parseValue,
|
|
14330
|
+
parseType: parseType,
|
|
14331
|
+
Parser: Parser
|
|
14332
|
+
};
|
|
14333
|
+
|
|
14334
|
+
/**
|
|
14335
|
+
* A visitor is provided to visit, it contains the collection of
|
|
14336
|
+
* relevant functions to be called during the visitor's traversal.
|
|
14337
|
+
*/
|
|
14338
|
+
|
|
14339
|
+
var QueryDocumentKeys = {
|
|
14340
|
+
Name: [],
|
|
14341
|
+
Document: ['definitions'],
|
|
14342
|
+
OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],
|
|
14343
|
+
VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],
|
|
14344
|
+
Variable: ['name'],
|
|
14345
|
+
SelectionSet: ['selections'],
|
|
14346
|
+
Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
|
|
14347
|
+
Argument: ['name', 'value'],
|
|
14348
|
+
FragmentSpread: ['name', 'directives'],
|
|
14349
|
+
InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
|
|
14350
|
+
FragmentDefinition: ['name', // Note: fragment variable definitions are experimental and may be changed
|
|
14351
|
+
// or removed in the future.
|
|
14352
|
+
'variableDefinitions', 'typeCondition', 'directives', 'selectionSet'],
|
|
14353
|
+
IntValue: [],
|
|
14354
|
+
FloatValue: [],
|
|
14355
|
+
StringValue: [],
|
|
14356
|
+
BooleanValue: [],
|
|
14357
|
+
NullValue: [],
|
|
14358
|
+
EnumValue: [],
|
|
14359
|
+
ListValue: ['values'],
|
|
14360
|
+
ObjectValue: ['fields'],
|
|
14361
|
+
ObjectField: ['name', 'value'],
|
|
14362
|
+
Directive: ['name', 'arguments'],
|
|
14363
|
+
NamedType: ['name'],
|
|
14364
|
+
ListType: ['type'],
|
|
14365
|
+
NonNullType: ['type'],
|
|
14366
|
+
SchemaDefinition: ['description', 'directives', 'operationTypes'],
|
|
14367
|
+
OperationTypeDefinition: ['type'],
|
|
14368
|
+
ScalarTypeDefinition: ['description', 'name', 'directives'],
|
|
14369
|
+
ObjectTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],
|
|
14370
|
+
FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],
|
|
14371
|
+
InputValueDefinition: ['description', 'name', 'type', 'defaultValue', 'directives'],
|
|
14372
|
+
InterfaceTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],
|
|
14373
|
+
UnionTypeDefinition: ['description', 'name', 'directives', 'types'],
|
|
14374
|
+
EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
|
|
14375
|
+
EnumValueDefinition: ['description', 'name', 'directives'],
|
|
14376
|
+
InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
|
|
14377
|
+
DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
|
|
14378
|
+
SchemaExtension: ['directives', 'operationTypes'],
|
|
14379
|
+
ScalarTypeExtension: ['name', 'directives'],
|
|
14380
|
+
ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
|
|
14381
|
+
InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
|
|
14382
|
+
UnionTypeExtension: ['name', 'directives', 'types'],
|
|
14383
|
+
EnumTypeExtension: ['name', 'directives', 'values'],
|
|
14384
|
+
InputObjectTypeExtension: ['name', 'directives', 'fields']
|
|
14385
|
+
};
|
|
14386
|
+
var BREAK = Object.freeze({});
|
|
14387
|
+
/**
|
|
14388
|
+
* visit() will walk through an AST using a depth-first traversal, calling
|
|
14389
|
+
* the visitor's enter function at each node in the traversal, and calling the
|
|
14390
|
+
* leave function after visiting that node and all of its child nodes.
|
|
14391
|
+
*
|
|
14392
|
+
* By returning different values from the enter and leave functions, the
|
|
14393
|
+
* behavior of the visitor can be altered, including skipping over a sub-tree of
|
|
14394
|
+
* the AST (by returning false), editing the AST by returning a value or null
|
|
14395
|
+
* to remove the value, or to stop the whole traversal by returning BREAK.
|
|
14396
|
+
*
|
|
14397
|
+
* When using visit() to edit an AST, the original AST will not be modified, and
|
|
14398
|
+
* a new version of the AST with the changes applied will be returned from the
|
|
14399
|
+
* visit function.
|
|
14400
|
+
*
|
|
14401
|
+
* const editedAST = visit(ast, {
|
|
14402
|
+
* enter(node, key, parent, path, ancestors) {
|
|
14403
|
+
* // @return
|
|
14404
|
+
* // undefined: no action
|
|
14405
|
+
* // false: skip visiting this node
|
|
14406
|
+
* // visitor.BREAK: stop visiting altogether
|
|
14407
|
+
* // null: delete this node
|
|
14408
|
+
* // any value: replace this node with the returned value
|
|
14409
|
+
* },
|
|
14410
|
+
* leave(node, key, parent, path, ancestors) {
|
|
14411
|
+
* // @return
|
|
14412
|
+
* // undefined: no action
|
|
14413
|
+
* // false: no action
|
|
14414
|
+
* // visitor.BREAK: stop visiting altogether
|
|
14415
|
+
* // null: delete this node
|
|
14416
|
+
* // any value: replace this node with the returned value
|
|
14417
|
+
* }
|
|
14418
|
+
* });
|
|
14419
|
+
*
|
|
14420
|
+
* Alternatively to providing enter() and leave() functions, a visitor can
|
|
14421
|
+
* instead provide functions named the same as the kinds of AST nodes, or
|
|
14422
|
+
* enter/leave visitors at a named key, leading to four permutations of the
|
|
14423
|
+
* visitor API:
|
|
14424
|
+
*
|
|
14425
|
+
* 1) Named visitors triggered when entering a node of a specific kind.
|
|
14426
|
+
*
|
|
14427
|
+
* visit(ast, {
|
|
14428
|
+
* Kind(node) {
|
|
14429
|
+
* // enter the "Kind" node
|
|
14430
|
+
* }
|
|
14431
|
+
* })
|
|
14432
|
+
*
|
|
14433
|
+
* 2) Named visitors that trigger upon entering and leaving a node of
|
|
14434
|
+
* a specific kind.
|
|
14435
|
+
*
|
|
14436
|
+
* visit(ast, {
|
|
14437
|
+
* Kind: {
|
|
14438
|
+
* enter(node) {
|
|
14439
|
+
* // enter the "Kind" node
|
|
14440
|
+
* }
|
|
14441
|
+
* leave(node) {
|
|
14442
|
+
* // leave the "Kind" node
|
|
14443
|
+
* }
|
|
14444
|
+
* }
|
|
14445
|
+
* })
|
|
14446
|
+
*
|
|
14447
|
+
* 3) Generic visitors that trigger upon entering and leaving any node.
|
|
14448
|
+
*
|
|
14449
|
+
* visit(ast, {
|
|
14450
|
+
* enter(node) {
|
|
14451
|
+
* // enter any node
|
|
14452
|
+
* },
|
|
14453
|
+
* leave(node) {
|
|
14454
|
+
* // leave any node
|
|
14455
|
+
* }
|
|
14456
|
+
* })
|
|
14457
|
+
*
|
|
14458
|
+
* 4) Parallel visitors for entering and leaving nodes of a specific kind.
|
|
14459
|
+
*
|
|
14460
|
+
* visit(ast, {
|
|
14461
|
+
* enter: {
|
|
14462
|
+
* Kind(node) {
|
|
14463
|
+
* // enter the "Kind" node
|
|
14464
|
+
* }
|
|
14465
|
+
* },
|
|
14466
|
+
* leave: {
|
|
14467
|
+
* Kind(node) {
|
|
14468
|
+
* // leave the "Kind" node
|
|
14469
|
+
* }
|
|
14470
|
+
* }
|
|
14471
|
+
* })
|
|
14472
|
+
*/
|
|
14473
|
+
|
|
14474
|
+
function visit(root, visitor) {
|
|
14475
|
+
var visitorKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QueryDocumentKeys;
|
|
14476
|
+
|
|
14477
|
+
/* eslint-disable no-undef-init */
|
|
14478
|
+
var stack = undefined;
|
|
14479
|
+
var inArray = Array.isArray(root);
|
|
14480
|
+
var keys = [root];
|
|
14481
|
+
var index = -1;
|
|
14482
|
+
var edits = [];
|
|
14483
|
+
var node = undefined;
|
|
14484
|
+
var key = undefined;
|
|
14485
|
+
var parent = undefined;
|
|
14486
|
+
var path = [];
|
|
14487
|
+
var ancestors = [];
|
|
14488
|
+
var newRoot = root;
|
|
14489
|
+
/* eslint-enable no-undef-init */
|
|
14490
|
+
|
|
14491
|
+
do {
|
|
14492
|
+
index++;
|
|
14493
|
+
var isLeaving = index === keys.length;
|
|
14494
|
+
var isEdited = isLeaving && edits.length !== 0;
|
|
14495
|
+
|
|
14496
|
+
if (isLeaving) {
|
|
14497
|
+
key = ancestors.length === 0 ? undefined : path[path.length - 1];
|
|
14498
|
+
node = parent;
|
|
14499
|
+
parent = ancestors.pop();
|
|
14500
|
+
|
|
14501
|
+
if (isEdited) {
|
|
14502
|
+
if (inArray) {
|
|
14503
|
+
node = node.slice();
|
|
14504
|
+
} else {
|
|
14505
|
+
var clone = {};
|
|
14506
|
+
|
|
14507
|
+
for (var _i2 = 0, _Object$keys2 = Object.keys(node); _i2 < _Object$keys2.length; _i2++) {
|
|
14508
|
+
var k = _Object$keys2[_i2];
|
|
14509
|
+
clone[k] = node[k];
|
|
14510
|
+
}
|
|
14511
|
+
|
|
14512
|
+
node = clone;
|
|
14513
|
+
}
|
|
14514
|
+
|
|
14515
|
+
var editOffset = 0;
|
|
14516
|
+
|
|
14517
|
+
for (var ii = 0; ii < edits.length; ii++) {
|
|
14518
|
+
var editKey = edits[ii][0];
|
|
14519
|
+
var editValue = edits[ii][1];
|
|
14520
|
+
|
|
14521
|
+
if (inArray) {
|
|
14522
|
+
editKey -= editOffset;
|
|
14523
|
+
}
|
|
14524
|
+
|
|
14525
|
+
if (inArray && editValue === null) {
|
|
14526
|
+
node.splice(editKey, 1);
|
|
14527
|
+
editOffset++;
|
|
14528
|
+
} else {
|
|
14529
|
+
node[editKey] = editValue;
|
|
14530
|
+
}
|
|
14531
|
+
}
|
|
14532
|
+
}
|
|
14533
|
+
|
|
14534
|
+
index = stack.index;
|
|
14535
|
+
keys = stack.keys;
|
|
14536
|
+
edits = stack.edits;
|
|
14537
|
+
inArray = stack.inArray;
|
|
14538
|
+
stack = stack.prev;
|
|
14539
|
+
} else {
|
|
14540
|
+
key = parent ? inArray ? index : keys[index] : undefined;
|
|
14541
|
+
node = parent ? parent[key] : newRoot;
|
|
14542
|
+
|
|
14543
|
+
if (node === null || node === undefined) {
|
|
14544
|
+
continue;
|
|
14545
|
+
}
|
|
14546
|
+
|
|
14547
|
+
if (parent) {
|
|
14548
|
+
path.push(key);
|
|
14549
|
+
}
|
|
14550
|
+
}
|
|
14551
|
+
|
|
14552
|
+
var result = void 0;
|
|
14553
|
+
|
|
14554
|
+
if (!Array.isArray(node)) {
|
|
14555
|
+
if (!isNode(node)) {
|
|
14556
|
+
throw new Error("Invalid AST Node: ".concat(inspect(node), "."));
|
|
14557
|
+
}
|
|
14558
|
+
|
|
14559
|
+
var visitFn = getVisitFn(visitor, node.kind, isLeaving);
|
|
14560
|
+
|
|
14561
|
+
if (visitFn) {
|
|
14562
|
+
result = visitFn.call(visitor, node, key, parent, path, ancestors);
|
|
14563
|
+
|
|
14564
|
+
if (result === BREAK) {
|
|
14565
|
+
break;
|
|
14566
|
+
}
|
|
14567
|
+
|
|
14568
|
+
if (result === false) {
|
|
14569
|
+
if (!isLeaving) {
|
|
14570
|
+
path.pop();
|
|
14571
|
+
continue;
|
|
14572
|
+
}
|
|
14573
|
+
} else if (result !== undefined) {
|
|
14574
|
+
edits.push([key, result]);
|
|
14575
|
+
|
|
14576
|
+
if (!isLeaving) {
|
|
14577
|
+
if (isNode(result)) {
|
|
14578
|
+
node = result;
|
|
14579
|
+
} else {
|
|
14580
|
+
path.pop();
|
|
14581
|
+
continue;
|
|
14582
|
+
}
|
|
14583
|
+
}
|
|
14584
|
+
}
|
|
14585
|
+
}
|
|
14586
|
+
}
|
|
14587
|
+
|
|
14588
|
+
if (result === undefined && isEdited) {
|
|
14589
|
+
edits.push([key, node]);
|
|
14590
|
+
}
|
|
14591
|
+
|
|
14592
|
+
if (isLeaving) {
|
|
14593
|
+
path.pop();
|
|
14594
|
+
} else {
|
|
14595
|
+
var _visitorKeys$node$kin;
|
|
14596
|
+
|
|
14597
|
+
stack = {
|
|
14598
|
+
inArray: inArray,
|
|
14599
|
+
index: index,
|
|
14600
|
+
keys: keys,
|
|
14601
|
+
edits: edits,
|
|
14602
|
+
prev: stack
|
|
14603
|
+
};
|
|
14604
|
+
inArray = Array.isArray(node);
|
|
14605
|
+
keys = inArray ? node : (_visitorKeys$node$kin = visitorKeys[node.kind]) !== null && _visitorKeys$node$kin !== void 0 ? _visitorKeys$node$kin : [];
|
|
14606
|
+
index = -1;
|
|
14607
|
+
edits = [];
|
|
14608
|
+
|
|
14609
|
+
if (parent) {
|
|
14610
|
+
ancestors.push(parent);
|
|
14611
|
+
}
|
|
14612
|
+
|
|
14613
|
+
parent = node;
|
|
14614
|
+
}
|
|
14615
|
+
} while (stack !== undefined);
|
|
14616
|
+
|
|
14617
|
+
if (edits.length !== 0) {
|
|
14618
|
+
newRoot = edits[edits.length - 1][1];
|
|
14619
|
+
}
|
|
14620
|
+
|
|
14621
|
+
return newRoot;
|
|
14622
|
+
}
|
|
14623
|
+
/**
|
|
14624
|
+
* Given a visitor instance, if it is leaving or not, and a node kind, return
|
|
14625
|
+
* the function the visitor runtime should call.
|
|
14626
|
+
*/
|
|
14627
|
+
|
|
14628
|
+
function getVisitFn(visitor, kind, isLeaving) {
|
|
14629
|
+
var kindVisitor = visitor[kind];
|
|
14630
|
+
|
|
14631
|
+
if (kindVisitor) {
|
|
14632
|
+
if (!isLeaving && typeof kindVisitor === 'function') {
|
|
14633
|
+
// { Kind() {} }
|
|
14634
|
+
return kindVisitor;
|
|
14635
|
+
}
|
|
14636
|
+
|
|
14637
|
+
var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;
|
|
14638
|
+
|
|
14639
|
+
if (typeof kindSpecificVisitor === 'function') {
|
|
14640
|
+
// { Kind: { enter() {}, leave() {} } }
|
|
14641
|
+
return kindSpecificVisitor;
|
|
14642
|
+
}
|
|
14643
|
+
} else {
|
|
14644
|
+
var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
|
|
14645
|
+
|
|
14646
|
+
if (specificVisitor) {
|
|
14647
|
+
if (typeof specificVisitor === 'function') {
|
|
14648
|
+
// { enter() {}, leave() {} }
|
|
14649
|
+
return specificVisitor;
|
|
14650
|
+
}
|
|
14651
|
+
|
|
14652
|
+
var specificKindVisitor = specificVisitor[kind];
|
|
14653
|
+
|
|
14654
|
+
if (typeof specificKindVisitor === 'function') {
|
|
14655
|
+
// { enter: { Kind() {} }, leave: { Kind() {} } }
|
|
14656
|
+
return specificKindVisitor;
|
|
14657
|
+
}
|
|
14658
|
+
}
|
|
14659
|
+
}
|
|
14660
|
+
}
|
|
14661
|
+
|
|
14662
|
+
/**
|
|
14663
|
+
* Converts an AST into a string, using one set of reasonable
|
|
14664
|
+
* formatting rules.
|
|
14665
|
+
*/
|
|
14666
|
+
|
|
14667
|
+
function print(ast) {
|
|
14668
|
+
return visit(ast, {
|
|
14669
|
+
leave: printDocASTReducer
|
|
14670
|
+
});
|
|
14671
|
+
}
|
|
14672
|
+
var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future
|
|
14673
|
+
|
|
14674
|
+
var printDocASTReducer = {
|
|
14675
|
+
Name: function Name(node) {
|
|
14676
|
+
return node.value;
|
|
14677
|
+
},
|
|
14678
|
+
Variable: function Variable(node) {
|
|
14679
|
+
return '$' + node.name;
|
|
14680
|
+
},
|
|
14681
|
+
// Document
|
|
14682
|
+
Document: function Document(node) {
|
|
14683
|
+
return join(node.definitions, '\n\n') + '\n';
|
|
14684
|
+
},
|
|
14685
|
+
OperationDefinition: function OperationDefinition(node) {
|
|
14686
|
+
var op = node.operation;
|
|
14687
|
+
var name = node.name;
|
|
14688
|
+
var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
|
|
14689
|
+
var directives = join(node.directives, ' ');
|
|
14690
|
+
var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
|
|
14691
|
+
// the query short form.
|
|
14692
|
+
|
|
14693
|
+
return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
|
|
14694
|
+
},
|
|
14695
|
+
VariableDefinition: function VariableDefinition(_ref) {
|
|
14696
|
+
var variable = _ref.variable,
|
|
14697
|
+
type = _ref.type,
|
|
14698
|
+
defaultValue = _ref.defaultValue,
|
|
14699
|
+
directives = _ref.directives;
|
|
14700
|
+
return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
|
|
14701
|
+
},
|
|
14702
|
+
SelectionSet: function SelectionSet(_ref2) {
|
|
14703
|
+
var selections = _ref2.selections;
|
|
14704
|
+
return block(selections);
|
|
14705
|
+
},
|
|
14706
|
+
Field: function Field(_ref3) {
|
|
14707
|
+
var alias = _ref3.alias,
|
|
14708
|
+
name = _ref3.name,
|
|
14709
|
+
args = _ref3.arguments,
|
|
14710
|
+
directives = _ref3.directives,
|
|
14711
|
+
selectionSet = _ref3.selectionSet;
|
|
14712
|
+
var prefix = wrap('', alias, ': ') + name;
|
|
14713
|
+
var argsLine = prefix + wrap('(', join(args, ', '), ')');
|
|
14714
|
+
|
|
14715
|
+
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
14716
|
+
argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
|
|
14717
|
+
}
|
|
14718
|
+
|
|
14719
|
+
return join([argsLine, join(directives, ' '), selectionSet], ' ');
|
|
14720
|
+
},
|
|
14721
|
+
Argument: function Argument(_ref4) {
|
|
14722
|
+
var name = _ref4.name,
|
|
14723
|
+
value = _ref4.value;
|
|
14724
|
+
return name + ': ' + value;
|
|
14725
|
+
},
|
|
14726
|
+
// Fragments
|
|
14727
|
+
FragmentSpread: function FragmentSpread(_ref5) {
|
|
14728
|
+
var name = _ref5.name,
|
|
14729
|
+
directives = _ref5.directives;
|
|
14730
|
+
return '...' + name + wrap(' ', join(directives, ' '));
|
|
14731
|
+
},
|
|
14732
|
+
InlineFragment: function InlineFragment(_ref6) {
|
|
14733
|
+
var typeCondition = _ref6.typeCondition,
|
|
14734
|
+
directives = _ref6.directives,
|
|
14735
|
+
selectionSet = _ref6.selectionSet;
|
|
14736
|
+
return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
|
|
14737
|
+
},
|
|
14738
|
+
FragmentDefinition: function FragmentDefinition(_ref7) {
|
|
14739
|
+
var name = _ref7.name,
|
|
14740
|
+
typeCondition = _ref7.typeCondition,
|
|
14741
|
+
variableDefinitions = _ref7.variableDefinitions,
|
|
14742
|
+
directives = _ref7.directives,
|
|
14743
|
+
selectionSet = _ref7.selectionSet;
|
|
14744
|
+
return (// Note: fragment variable definitions are experimental and may be changed
|
|
14745
|
+
// or removed in the future.
|
|
14746
|
+
"fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
|
|
14747
|
+
);
|
|
14748
|
+
},
|
|
14749
|
+
// Value
|
|
14750
|
+
IntValue: function IntValue(_ref8) {
|
|
14751
|
+
var value = _ref8.value;
|
|
14752
|
+
return value;
|
|
14753
|
+
},
|
|
14754
|
+
FloatValue: function FloatValue(_ref9) {
|
|
14755
|
+
var value = _ref9.value;
|
|
14756
|
+
return value;
|
|
14757
|
+
},
|
|
14758
|
+
StringValue: function StringValue(_ref10, key) {
|
|
14759
|
+
var value = _ref10.value,
|
|
14760
|
+
isBlockString = _ref10.block;
|
|
14761
|
+
return isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
|
|
14762
|
+
},
|
|
14763
|
+
BooleanValue: function BooleanValue(_ref11) {
|
|
14764
|
+
var value = _ref11.value;
|
|
14765
|
+
return value ? 'true' : 'false';
|
|
14766
|
+
},
|
|
14767
|
+
NullValue: function NullValue() {
|
|
14768
|
+
return 'null';
|
|
14769
|
+
},
|
|
14770
|
+
EnumValue: function EnumValue(_ref12) {
|
|
14771
|
+
var value = _ref12.value;
|
|
14772
|
+
return value;
|
|
14773
|
+
},
|
|
14774
|
+
ListValue: function ListValue(_ref13) {
|
|
14775
|
+
var values = _ref13.values;
|
|
14776
|
+
return '[' + join(values, ', ') + ']';
|
|
14777
|
+
},
|
|
14778
|
+
ObjectValue: function ObjectValue(_ref14) {
|
|
14779
|
+
var fields = _ref14.fields;
|
|
14780
|
+
return '{' + join(fields, ', ') + '}';
|
|
14781
|
+
},
|
|
14782
|
+
ObjectField: function ObjectField(_ref15) {
|
|
14783
|
+
var name = _ref15.name,
|
|
14784
|
+
value = _ref15.value;
|
|
14785
|
+
return name + ': ' + value;
|
|
14786
|
+
},
|
|
14787
|
+
// Directive
|
|
14788
|
+
Directive: function Directive(_ref16) {
|
|
14789
|
+
var name = _ref16.name,
|
|
14790
|
+
args = _ref16.arguments;
|
|
14791
|
+
return '@' + name + wrap('(', join(args, ', '), ')');
|
|
14792
|
+
},
|
|
14793
|
+
// Type
|
|
14794
|
+
NamedType: function NamedType(_ref17) {
|
|
14795
|
+
var name = _ref17.name;
|
|
14796
|
+
return name;
|
|
14797
|
+
},
|
|
14798
|
+
ListType: function ListType(_ref18) {
|
|
14799
|
+
var type = _ref18.type;
|
|
14800
|
+
return '[' + type + ']';
|
|
14801
|
+
},
|
|
14802
|
+
NonNullType: function NonNullType(_ref19) {
|
|
14803
|
+
var type = _ref19.type;
|
|
14804
|
+
return type + '!';
|
|
14805
|
+
},
|
|
14806
|
+
// Type System Definitions
|
|
14807
|
+
SchemaDefinition: addDescription(function (_ref20) {
|
|
14808
|
+
var directives = _ref20.directives,
|
|
14809
|
+
operationTypes = _ref20.operationTypes;
|
|
14810
|
+
return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
14811
|
+
}),
|
|
14812
|
+
OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
|
|
14813
|
+
var operation = _ref21.operation,
|
|
14814
|
+
type = _ref21.type;
|
|
14815
|
+
return operation + ': ' + type;
|
|
14816
|
+
},
|
|
14817
|
+
ScalarTypeDefinition: addDescription(function (_ref22) {
|
|
14818
|
+
var name = _ref22.name,
|
|
14819
|
+
directives = _ref22.directives;
|
|
14820
|
+
return join(['scalar', name, join(directives, ' ')], ' ');
|
|
14821
|
+
}),
|
|
14822
|
+
ObjectTypeDefinition: addDescription(function (_ref23) {
|
|
14823
|
+
var name = _ref23.name,
|
|
14824
|
+
interfaces = _ref23.interfaces,
|
|
14825
|
+
directives = _ref23.directives,
|
|
14826
|
+
fields = _ref23.fields;
|
|
14827
|
+
return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
14828
|
+
}),
|
|
14829
|
+
FieldDefinition: addDescription(function (_ref24) {
|
|
14830
|
+
var name = _ref24.name,
|
|
14831
|
+
args = _ref24.arguments,
|
|
14832
|
+
type = _ref24.type,
|
|
14833
|
+
directives = _ref24.directives;
|
|
14834
|
+
return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
|
|
14835
|
+
}),
|
|
14836
|
+
InputValueDefinition: addDescription(function (_ref25) {
|
|
14837
|
+
var name = _ref25.name,
|
|
14838
|
+
type = _ref25.type,
|
|
14839
|
+
defaultValue = _ref25.defaultValue,
|
|
14840
|
+
directives = _ref25.directives;
|
|
14841
|
+
return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
|
|
14842
|
+
}),
|
|
14843
|
+
InterfaceTypeDefinition: addDescription(function (_ref26) {
|
|
14844
|
+
var name = _ref26.name,
|
|
14845
|
+
interfaces = _ref26.interfaces,
|
|
14846
|
+
directives = _ref26.directives,
|
|
14847
|
+
fields = _ref26.fields;
|
|
14848
|
+
return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
14849
|
+
}),
|
|
14850
|
+
UnionTypeDefinition: addDescription(function (_ref27) {
|
|
14851
|
+
var name = _ref27.name,
|
|
14852
|
+
directives = _ref27.directives,
|
|
14853
|
+
types = _ref27.types;
|
|
14854
|
+
return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
|
|
14855
|
+
}),
|
|
14856
|
+
EnumTypeDefinition: addDescription(function (_ref28) {
|
|
14857
|
+
var name = _ref28.name,
|
|
14858
|
+
directives = _ref28.directives,
|
|
14859
|
+
values = _ref28.values;
|
|
14860
|
+
return join(['enum', name, join(directives, ' '), block(values)], ' ');
|
|
14861
|
+
}),
|
|
14862
|
+
EnumValueDefinition: addDescription(function (_ref29) {
|
|
14863
|
+
var name = _ref29.name,
|
|
14864
|
+
directives = _ref29.directives;
|
|
14865
|
+
return join([name, join(directives, ' ')], ' ');
|
|
14866
|
+
}),
|
|
14867
|
+
InputObjectTypeDefinition: addDescription(function (_ref30) {
|
|
14868
|
+
var name = _ref30.name,
|
|
14869
|
+
directives = _ref30.directives,
|
|
14870
|
+
fields = _ref30.fields;
|
|
14871
|
+
return join(['input', name, join(directives, ' '), block(fields)], ' ');
|
|
14872
|
+
}),
|
|
14873
|
+
DirectiveDefinition: addDescription(function (_ref31) {
|
|
14874
|
+
var name = _ref31.name,
|
|
14875
|
+
args = _ref31.arguments,
|
|
14876
|
+
repeatable = _ref31.repeatable,
|
|
14877
|
+
locations = _ref31.locations;
|
|
14878
|
+
return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ');
|
|
14879
|
+
}),
|
|
14880
|
+
SchemaExtension: function SchemaExtension(_ref32) {
|
|
14881
|
+
var directives = _ref32.directives,
|
|
14882
|
+
operationTypes = _ref32.operationTypes;
|
|
14883
|
+
return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
14884
|
+
},
|
|
14885
|
+
ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
|
|
14886
|
+
var name = _ref33.name,
|
|
14887
|
+
directives = _ref33.directives;
|
|
14888
|
+
return join(['extend scalar', name, join(directives, ' ')], ' ');
|
|
14889
|
+
},
|
|
14890
|
+
ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
|
|
14891
|
+
var name = _ref34.name,
|
|
14892
|
+
interfaces = _ref34.interfaces,
|
|
14893
|
+
directives = _ref34.directives,
|
|
14894
|
+
fields = _ref34.fields;
|
|
14895
|
+
return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
14896
|
+
},
|
|
14897
|
+
InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
|
|
14898
|
+
var name = _ref35.name,
|
|
14899
|
+
interfaces = _ref35.interfaces,
|
|
14900
|
+
directives = _ref35.directives,
|
|
14901
|
+
fields = _ref35.fields;
|
|
14902
|
+
return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
14903
|
+
},
|
|
14904
|
+
UnionTypeExtension: function UnionTypeExtension(_ref36) {
|
|
14905
|
+
var name = _ref36.name,
|
|
14906
|
+
directives = _ref36.directives,
|
|
14907
|
+
types = _ref36.types;
|
|
14908
|
+
return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
|
|
14909
|
+
},
|
|
14910
|
+
EnumTypeExtension: function EnumTypeExtension(_ref37) {
|
|
14911
|
+
var name = _ref37.name,
|
|
14912
|
+
directives = _ref37.directives,
|
|
14913
|
+
values = _ref37.values;
|
|
14914
|
+
return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
|
|
14915
|
+
},
|
|
14916
|
+
InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
|
|
14917
|
+
var name = _ref38.name,
|
|
14918
|
+
directives = _ref38.directives,
|
|
14919
|
+
fields = _ref38.fields;
|
|
14920
|
+
return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
|
|
14921
|
+
}
|
|
14922
|
+
};
|
|
14923
|
+
|
|
14924
|
+
function addDescription(cb) {
|
|
14925
|
+
return function (node) {
|
|
14926
|
+
return join([node.description, cb(node)], '\n');
|
|
14927
|
+
};
|
|
14928
|
+
}
|
|
14929
|
+
/**
|
|
14930
|
+
* Given maybeArray, print an empty string if it is null or empty, otherwise
|
|
14931
|
+
* print all items together separated by separator if provided
|
|
14932
|
+
*/
|
|
14933
|
+
|
|
14934
|
+
|
|
14935
|
+
function join(maybeArray) {
|
|
14936
|
+
var _maybeArray$filter$jo;
|
|
14937
|
+
|
|
14938
|
+
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
14939
|
+
return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter(function (x) {
|
|
14940
|
+
return x;
|
|
14941
|
+
}).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : '';
|
|
14942
|
+
}
|
|
14943
|
+
/**
|
|
14944
|
+
* Given array, print each item on its own line, wrapped in an
|
|
14945
|
+
* indented "{ }" block.
|
|
14946
|
+
*/
|
|
14947
|
+
|
|
14948
|
+
|
|
14949
|
+
function block(array) {
|
|
14950
|
+
return wrap('{\n', indent(join(array, '\n')), '\n}');
|
|
14951
|
+
}
|
|
14952
|
+
/**
|
|
14953
|
+
* If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
|
|
14954
|
+
*/
|
|
14955
|
+
|
|
14956
|
+
|
|
14957
|
+
function wrap(start, maybeString) {
|
|
14958
|
+
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
14959
|
+
return maybeString != null && maybeString !== '' ? start + maybeString + end : '';
|
|
14960
|
+
}
|
|
14961
|
+
|
|
14962
|
+
function indent(str) {
|
|
14963
|
+
return wrap(' ', str.replace(/\n/g, '\n '));
|
|
14964
|
+
}
|
|
14965
|
+
|
|
14966
|
+
function isMultiline(str) {
|
|
14967
|
+
return str.indexOf('\n') !== -1;
|
|
14968
|
+
}
|
|
14969
|
+
|
|
14970
|
+
function hasMultilineItems(maybeArray) {
|
|
14971
|
+
return maybeArray != null && maybeArray.some(isMultiline);
|
|
14972
|
+
}
|
|
14973
|
+
|
|
14974
|
+
var printer = {
|
|
14975
|
+
__proto__: null,
|
|
14976
|
+
print: print
|
|
14977
|
+
};
|
|
14978
|
+
|
|
13678
14979
|
var docCache = new Map();
|
|
13679
14980
|
var fragmentSourceMap = new Map();
|
|
13680
14981
|
var printFragmentWarnings = true;
|
|
@@ -15868,147 +17169,1766 @@ var Observable = /*@__PURE__*/ (function () {
|
|
|
15868
17169
|
}
|
|
15869
17170
|
return pipeFromArray(operations)(this);
|
|
15870
17171
|
};
|
|
15871
|
-
Observable.prototype.toPromise = function (promiseCtor) {
|
|
17172
|
+
Observable.prototype.toPromise = function (promiseCtor) {
|
|
17173
|
+
var _this = this;
|
|
17174
|
+
promiseCtor = getPromiseCtor(promiseCtor);
|
|
17175
|
+
return new promiseCtor(function (resolve, reject) {
|
|
17176
|
+
var value;
|
|
17177
|
+
_this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
17178
|
+
});
|
|
17179
|
+
};
|
|
17180
|
+
Observable.create = function (subscribe) {
|
|
17181
|
+
return new Observable(subscribe);
|
|
17182
|
+
};
|
|
17183
|
+
return Observable;
|
|
17184
|
+
}());
|
|
17185
|
+
function getPromiseCtor(promiseCtor) {
|
|
17186
|
+
if (!promiseCtor) {
|
|
17187
|
+
promiseCtor = Promise;
|
|
17188
|
+
}
|
|
17189
|
+
if (!promiseCtor) {
|
|
17190
|
+
throw new Error('no Promise impl found');
|
|
17191
|
+
}
|
|
17192
|
+
return promiseCtor;
|
|
17193
|
+
}
|
|
17194
|
+
|
|
17195
|
+
var ActionCableClient = /*#__PURE__*/function () {
|
|
17196
|
+
function ActionCableClient(url) {
|
|
17197
|
+
var _this = this;
|
|
17198
|
+
|
|
17199
|
+
this.cable = null;
|
|
17200
|
+
this.subscriptions = new Map();
|
|
17201
|
+
|
|
17202
|
+
this.addSubscription = function (id, subscription) {
|
|
17203
|
+
_this.subscriptions.set(id, subscription);
|
|
17204
|
+
};
|
|
17205
|
+
|
|
17206
|
+
this.wsURL = url;
|
|
17207
|
+
}
|
|
17208
|
+
|
|
17209
|
+
var _proto = ActionCableClient.prototype;
|
|
17210
|
+
|
|
17211
|
+
_proto.connect = function connect(token, lang) {
|
|
17212
|
+
this.cable = action_cable.createConsumer(this.wsURL + "?token=" + token + "&lang=" + lang);
|
|
17213
|
+
};
|
|
17214
|
+
|
|
17215
|
+
_proto.request = function request(_request) {
|
|
17216
|
+
var cable = this.cable,
|
|
17217
|
+
subscriptions = this.subscriptions,
|
|
17218
|
+
addSubscription = this.addSubscription;
|
|
17219
|
+
var subscription;
|
|
17220
|
+
return new Observable(function (observer) {
|
|
17221
|
+
if (cable) {
|
|
17222
|
+
var _request$variables;
|
|
17223
|
+
|
|
17224
|
+
var subscriptionId = ((_request$variables = _request.variables) === null || _request$variables === void 0 ? void 0 : _request$variables.id) || 'company';
|
|
17225
|
+
|
|
17226
|
+
if (!subscriptions.has(subscriptionId)) {
|
|
17227
|
+
subscription = cable.subscriptions.create({
|
|
17228
|
+
channel: 'GraphqlChannel',
|
|
17229
|
+
channelId: Math.round(Date.now() + Math.random() * 100000).toString(16)
|
|
17230
|
+
}, {
|
|
17231
|
+
connected: function connected() {
|
|
17232
|
+
this.perform('execute', _request);
|
|
17233
|
+
},
|
|
17234
|
+
received: function received(payload) {
|
|
17235
|
+
if (!payload.more) {
|
|
17236
|
+
if (observer.complete) {
|
|
17237
|
+
observer.complete();
|
|
17238
|
+
}
|
|
17239
|
+
} else if (payload.result.errors) {
|
|
17240
|
+
if (observer.error) {
|
|
17241
|
+
observer.error(payload.result.errors[0]);
|
|
17242
|
+
}
|
|
17243
|
+
} else if (payload.result.data) {
|
|
17244
|
+
if (observer.next) {
|
|
17245
|
+
if (!lodash_isempty(payload.result.data)) {
|
|
17246
|
+
observer.next(payload.result);
|
|
17247
|
+
}
|
|
17248
|
+
}
|
|
17249
|
+
}
|
|
17250
|
+
}
|
|
17251
|
+
});
|
|
17252
|
+
addSubscription(subscriptionId, subscription);
|
|
17253
|
+
}
|
|
17254
|
+
}
|
|
17255
|
+
});
|
|
17256
|
+
};
|
|
17257
|
+
|
|
17258
|
+
_proto.hasSubscription = function hasSubscription(id) {
|
|
17259
|
+
return this.subscriptions.has(id);
|
|
17260
|
+
};
|
|
17261
|
+
|
|
17262
|
+
return ActionCableClient;
|
|
17263
|
+
}();
|
|
17264
|
+
|
|
17265
|
+
var GraphqlWsClient = /*#__PURE__*/function () {
|
|
17266
|
+
function GraphqlWsClient(url, token, lang) {
|
|
17267
|
+
this.actionCableClient = null;
|
|
17268
|
+
this.actionCableClient = new ActionCableClient(url);
|
|
17269
|
+
this.actionCableClient.connect(token, lang);
|
|
17270
|
+
}
|
|
17271
|
+
|
|
17272
|
+
var _proto = GraphqlWsClient.prototype;
|
|
17273
|
+
|
|
17274
|
+
_proto.subscribe = function subscribe(query, variables, onData, onError) {
|
|
17275
|
+
if (onError === void 0) {
|
|
17276
|
+
onError = function onError(error) {
|
|
17277
|
+
throw error;
|
|
17278
|
+
};
|
|
17279
|
+
}
|
|
17280
|
+
|
|
17281
|
+
var getFirstValue = function getFirstValue(data) {
|
|
17282
|
+
var keys = Object.keys(data);
|
|
17283
|
+
if (keys.length !== 1) throw new Error("Expected exactly one response key, got: " + keys.join(', '));
|
|
17284
|
+
return data[keys[0]];
|
|
17285
|
+
};
|
|
17286
|
+
|
|
17287
|
+
if (!this.actionCableClient) throw new Error('No WS client available');
|
|
17288
|
+
var subscription = this.actionCableClient.request({
|
|
17289
|
+
query: query,
|
|
17290
|
+
variables: variables
|
|
17291
|
+
}).subscribe({
|
|
17292
|
+
next: function next(_ref) {
|
|
17293
|
+
var data = _ref.data,
|
|
17294
|
+
errors = _ref.errors;
|
|
17295
|
+
|
|
17296
|
+
if (errors) {
|
|
17297
|
+
return onError(new Error(JSON.stringify(errors)));
|
|
17298
|
+
}
|
|
17299
|
+
|
|
17300
|
+
if (data && onData) onData(getFirstValue(data));
|
|
17301
|
+
}
|
|
17302
|
+
});
|
|
17303
|
+
return function () {
|
|
17304
|
+
return subscription.unsubscribe();
|
|
17305
|
+
};
|
|
17306
|
+
};
|
|
17307
|
+
|
|
17308
|
+
return GraphqlWsClient;
|
|
17309
|
+
}();
|
|
17310
|
+
|
|
17311
|
+
var getGqlWsClient = function getGqlWsClient(url, token, lang) {
|
|
17312
|
+
return new GraphqlWsClient(url, token, lang);
|
|
17313
|
+
};
|
|
17314
|
+
|
|
17315
|
+
var browserPonyfill = createCommonjsModule(function (module, exports) {
|
|
17316
|
+
var global = typeof self !== 'undefined' ? self : commonjsGlobal$1;
|
|
17317
|
+
var __self__ = (function () {
|
|
17318
|
+
function F() {
|
|
17319
|
+
this.fetch = false;
|
|
17320
|
+
this.DOMException = global.DOMException;
|
|
17321
|
+
}
|
|
17322
|
+
F.prototype = global;
|
|
17323
|
+
return new F();
|
|
17324
|
+
})();
|
|
17325
|
+
(function(self) {
|
|
17326
|
+
|
|
17327
|
+
((function (exports) {
|
|
17328
|
+
|
|
17329
|
+
var support = {
|
|
17330
|
+
searchParams: 'URLSearchParams' in self,
|
|
17331
|
+
iterable: 'Symbol' in self && 'iterator' in Symbol,
|
|
17332
|
+
blob:
|
|
17333
|
+
'FileReader' in self &&
|
|
17334
|
+
'Blob' in self &&
|
|
17335
|
+
(function() {
|
|
17336
|
+
try {
|
|
17337
|
+
new Blob();
|
|
17338
|
+
return true
|
|
17339
|
+
} catch (e) {
|
|
17340
|
+
return false
|
|
17341
|
+
}
|
|
17342
|
+
})(),
|
|
17343
|
+
formData: 'FormData' in self,
|
|
17344
|
+
arrayBuffer: 'ArrayBuffer' in self
|
|
17345
|
+
};
|
|
17346
|
+
|
|
17347
|
+
function isDataView(obj) {
|
|
17348
|
+
return obj && DataView.prototype.isPrototypeOf(obj)
|
|
17349
|
+
}
|
|
17350
|
+
|
|
17351
|
+
if (support.arrayBuffer) {
|
|
17352
|
+
var viewClasses = [
|
|
17353
|
+
'[object Int8Array]',
|
|
17354
|
+
'[object Uint8Array]',
|
|
17355
|
+
'[object Uint8ClampedArray]',
|
|
17356
|
+
'[object Int16Array]',
|
|
17357
|
+
'[object Uint16Array]',
|
|
17358
|
+
'[object Int32Array]',
|
|
17359
|
+
'[object Uint32Array]',
|
|
17360
|
+
'[object Float32Array]',
|
|
17361
|
+
'[object Float64Array]'
|
|
17362
|
+
];
|
|
17363
|
+
|
|
17364
|
+
var isArrayBufferView =
|
|
17365
|
+
ArrayBuffer.isView ||
|
|
17366
|
+
function(obj) {
|
|
17367
|
+
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
|
17368
|
+
};
|
|
17369
|
+
}
|
|
17370
|
+
|
|
17371
|
+
function normalizeName(name) {
|
|
17372
|
+
if (typeof name !== 'string') {
|
|
17373
|
+
name = String(name);
|
|
17374
|
+
}
|
|
17375
|
+
if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
|
|
17376
|
+
throw new TypeError('Invalid character in header field name')
|
|
17377
|
+
}
|
|
17378
|
+
return name.toLowerCase()
|
|
17379
|
+
}
|
|
17380
|
+
|
|
17381
|
+
function normalizeValue(value) {
|
|
17382
|
+
if (typeof value !== 'string') {
|
|
17383
|
+
value = String(value);
|
|
17384
|
+
}
|
|
17385
|
+
return value
|
|
17386
|
+
}
|
|
17387
|
+
|
|
17388
|
+
// Build a destructive iterator for the value list
|
|
17389
|
+
function iteratorFor(items) {
|
|
17390
|
+
var iterator = {
|
|
17391
|
+
next: function() {
|
|
17392
|
+
var value = items.shift();
|
|
17393
|
+
return {done: value === undefined, value: value}
|
|
17394
|
+
}
|
|
17395
|
+
};
|
|
17396
|
+
|
|
17397
|
+
if (support.iterable) {
|
|
17398
|
+
iterator[Symbol.iterator] = function() {
|
|
17399
|
+
return iterator
|
|
17400
|
+
};
|
|
17401
|
+
}
|
|
17402
|
+
|
|
17403
|
+
return iterator
|
|
17404
|
+
}
|
|
17405
|
+
|
|
17406
|
+
function Headers(headers) {
|
|
17407
|
+
this.map = {};
|
|
17408
|
+
|
|
17409
|
+
if (headers instanceof Headers) {
|
|
17410
|
+
headers.forEach(function(value, name) {
|
|
17411
|
+
this.append(name, value);
|
|
17412
|
+
}, this);
|
|
17413
|
+
} else if (Array.isArray(headers)) {
|
|
17414
|
+
headers.forEach(function(header) {
|
|
17415
|
+
this.append(header[0], header[1]);
|
|
17416
|
+
}, this);
|
|
17417
|
+
} else if (headers) {
|
|
17418
|
+
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
17419
|
+
this.append(name, headers[name]);
|
|
17420
|
+
}, this);
|
|
17421
|
+
}
|
|
17422
|
+
}
|
|
17423
|
+
|
|
17424
|
+
Headers.prototype.append = function(name, value) {
|
|
17425
|
+
name = normalizeName(name);
|
|
17426
|
+
value = normalizeValue(value);
|
|
17427
|
+
var oldValue = this.map[name];
|
|
17428
|
+
this.map[name] = oldValue ? oldValue + ', ' + value : value;
|
|
17429
|
+
};
|
|
17430
|
+
|
|
17431
|
+
Headers.prototype['delete'] = function(name) {
|
|
17432
|
+
delete this.map[normalizeName(name)];
|
|
17433
|
+
};
|
|
17434
|
+
|
|
17435
|
+
Headers.prototype.get = function(name) {
|
|
17436
|
+
name = normalizeName(name);
|
|
17437
|
+
return this.has(name) ? this.map[name] : null
|
|
17438
|
+
};
|
|
17439
|
+
|
|
17440
|
+
Headers.prototype.has = function(name) {
|
|
17441
|
+
return this.map.hasOwnProperty(normalizeName(name))
|
|
17442
|
+
};
|
|
17443
|
+
|
|
17444
|
+
Headers.prototype.set = function(name, value) {
|
|
17445
|
+
this.map[normalizeName(name)] = normalizeValue(value);
|
|
17446
|
+
};
|
|
17447
|
+
|
|
17448
|
+
Headers.prototype.forEach = function(callback, thisArg) {
|
|
17449
|
+
for (var name in this.map) {
|
|
17450
|
+
if (this.map.hasOwnProperty(name)) {
|
|
17451
|
+
callback.call(thisArg, this.map[name], name, this);
|
|
17452
|
+
}
|
|
17453
|
+
}
|
|
17454
|
+
};
|
|
17455
|
+
|
|
17456
|
+
Headers.prototype.keys = function() {
|
|
17457
|
+
var items = [];
|
|
17458
|
+
this.forEach(function(value, name) {
|
|
17459
|
+
items.push(name);
|
|
17460
|
+
});
|
|
17461
|
+
return iteratorFor(items)
|
|
17462
|
+
};
|
|
17463
|
+
|
|
17464
|
+
Headers.prototype.values = function() {
|
|
17465
|
+
var items = [];
|
|
17466
|
+
this.forEach(function(value) {
|
|
17467
|
+
items.push(value);
|
|
17468
|
+
});
|
|
17469
|
+
return iteratorFor(items)
|
|
17470
|
+
};
|
|
17471
|
+
|
|
17472
|
+
Headers.prototype.entries = function() {
|
|
17473
|
+
var items = [];
|
|
17474
|
+
this.forEach(function(value, name) {
|
|
17475
|
+
items.push([name, value]);
|
|
17476
|
+
});
|
|
17477
|
+
return iteratorFor(items)
|
|
17478
|
+
};
|
|
17479
|
+
|
|
17480
|
+
if (support.iterable) {
|
|
17481
|
+
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
|
|
17482
|
+
}
|
|
17483
|
+
|
|
17484
|
+
function consumed(body) {
|
|
17485
|
+
if (body.bodyUsed) {
|
|
17486
|
+
return Promise.reject(new TypeError('Already read'))
|
|
17487
|
+
}
|
|
17488
|
+
body.bodyUsed = true;
|
|
17489
|
+
}
|
|
17490
|
+
|
|
17491
|
+
function fileReaderReady(reader) {
|
|
17492
|
+
return new Promise(function(resolve, reject) {
|
|
17493
|
+
reader.onload = function() {
|
|
17494
|
+
resolve(reader.result);
|
|
17495
|
+
};
|
|
17496
|
+
reader.onerror = function() {
|
|
17497
|
+
reject(reader.error);
|
|
17498
|
+
};
|
|
17499
|
+
})
|
|
17500
|
+
}
|
|
17501
|
+
|
|
17502
|
+
function readBlobAsArrayBuffer(blob) {
|
|
17503
|
+
var reader = new FileReader();
|
|
17504
|
+
var promise = fileReaderReady(reader);
|
|
17505
|
+
reader.readAsArrayBuffer(blob);
|
|
17506
|
+
return promise
|
|
17507
|
+
}
|
|
17508
|
+
|
|
17509
|
+
function readBlobAsText(blob) {
|
|
17510
|
+
var reader = new FileReader();
|
|
17511
|
+
var promise = fileReaderReady(reader);
|
|
17512
|
+
reader.readAsText(blob);
|
|
17513
|
+
return promise
|
|
17514
|
+
}
|
|
17515
|
+
|
|
17516
|
+
function readArrayBufferAsText(buf) {
|
|
17517
|
+
var view = new Uint8Array(buf);
|
|
17518
|
+
var chars = new Array(view.length);
|
|
17519
|
+
|
|
17520
|
+
for (var i = 0; i < view.length; i++) {
|
|
17521
|
+
chars[i] = String.fromCharCode(view[i]);
|
|
17522
|
+
}
|
|
17523
|
+
return chars.join('')
|
|
17524
|
+
}
|
|
17525
|
+
|
|
17526
|
+
function bufferClone(buf) {
|
|
17527
|
+
if (buf.slice) {
|
|
17528
|
+
return buf.slice(0)
|
|
17529
|
+
} else {
|
|
17530
|
+
var view = new Uint8Array(buf.byteLength);
|
|
17531
|
+
view.set(new Uint8Array(buf));
|
|
17532
|
+
return view.buffer
|
|
17533
|
+
}
|
|
17534
|
+
}
|
|
17535
|
+
|
|
17536
|
+
function Body() {
|
|
17537
|
+
this.bodyUsed = false;
|
|
17538
|
+
|
|
17539
|
+
this._initBody = function(body) {
|
|
17540
|
+
this._bodyInit = body;
|
|
17541
|
+
if (!body) {
|
|
17542
|
+
this._bodyText = '';
|
|
17543
|
+
} else if (typeof body === 'string') {
|
|
17544
|
+
this._bodyText = body;
|
|
17545
|
+
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
17546
|
+
this._bodyBlob = body;
|
|
17547
|
+
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
17548
|
+
this._bodyFormData = body;
|
|
17549
|
+
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
17550
|
+
this._bodyText = body.toString();
|
|
17551
|
+
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
17552
|
+
this._bodyArrayBuffer = bufferClone(body.buffer);
|
|
17553
|
+
// IE 10-11 can't handle a DataView body.
|
|
17554
|
+
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
|
17555
|
+
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
17556
|
+
this._bodyArrayBuffer = bufferClone(body);
|
|
17557
|
+
} else {
|
|
17558
|
+
this._bodyText = body = Object.prototype.toString.call(body);
|
|
17559
|
+
}
|
|
17560
|
+
|
|
17561
|
+
if (!this.headers.get('content-type')) {
|
|
17562
|
+
if (typeof body === 'string') {
|
|
17563
|
+
this.headers.set('content-type', 'text/plain;charset=UTF-8');
|
|
17564
|
+
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
17565
|
+
this.headers.set('content-type', this._bodyBlob.type);
|
|
17566
|
+
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
17567
|
+
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
|
17568
|
+
}
|
|
17569
|
+
}
|
|
17570
|
+
};
|
|
17571
|
+
|
|
17572
|
+
if (support.blob) {
|
|
17573
|
+
this.blob = function() {
|
|
17574
|
+
var rejected = consumed(this);
|
|
17575
|
+
if (rejected) {
|
|
17576
|
+
return rejected
|
|
17577
|
+
}
|
|
17578
|
+
|
|
17579
|
+
if (this._bodyBlob) {
|
|
17580
|
+
return Promise.resolve(this._bodyBlob)
|
|
17581
|
+
} else if (this._bodyArrayBuffer) {
|
|
17582
|
+
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
|
17583
|
+
} else if (this._bodyFormData) {
|
|
17584
|
+
throw new Error('could not read FormData body as blob')
|
|
17585
|
+
} else {
|
|
17586
|
+
return Promise.resolve(new Blob([this._bodyText]))
|
|
17587
|
+
}
|
|
17588
|
+
};
|
|
17589
|
+
|
|
17590
|
+
this.arrayBuffer = function() {
|
|
17591
|
+
if (this._bodyArrayBuffer) {
|
|
17592
|
+
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
|
|
17593
|
+
} else {
|
|
17594
|
+
return this.blob().then(readBlobAsArrayBuffer)
|
|
17595
|
+
}
|
|
17596
|
+
};
|
|
17597
|
+
}
|
|
17598
|
+
|
|
17599
|
+
this.text = function() {
|
|
17600
|
+
var rejected = consumed(this);
|
|
17601
|
+
if (rejected) {
|
|
17602
|
+
return rejected
|
|
17603
|
+
}
|
|
17604
|
+
|
|
17605
|
+
if (this._bodyBlob) {
|
|
17606
|
+
return readBlobAsText(this._bodyBlob)
|
|
17607
|
+
} else if (this._bodyArrayBuffer) {
|
|
17608
|
+
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
|
17609
|
+
} else if (this._bodyFormData) {
|
|
17610
|
+
throw new Error('could not read FormData body as text')
|
|
17611
|
+
} else {
|
|
17612
|
+
return Promise.resolve(this._bodyText)
|
|
17613
|
+
}
|
|
17614
|
+
};
|
|
17615
|
+
|
|
17616
|
+
if (support.formData) {
|
|
17617
|
+
this.formData = function() {
|
|
17618
|
+
return this.text().then(decode)
|
|
17619
|
+
};
|
|
17620
|
+
}
|
|
17621
|
+
|
|
17622
|
+
this.json = function() {
|
|
17623
|
+
return this.text().then(JSON.parse)
|
|
17624
|
+
};
|
|
17625
|
+
|
|
17626
|
+
return this
|
|
17627
|
+
}
|
|
17628
|
+
|
|
17629
|
+
// HTTP methods whose capitalization should be normalized
|
|
17630
|
+
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
|
|
17631
|
+
|
|
17632
|
+
function normalizeMethod(method) {
|
|
17633
|
+
var upcased = method.toUpperCase();
|
|
17634
|
+
return methods.indexOf(upcased) > -1 ? upcased : method
|
|
17635
|
+
}
|
|
17636
|
+
|
|
17637
|
+
function Request(input, options) {
|
|
17638
|
+
options = options || {};
|
|
17639
|
+
var body = options.body;
|
|
17640
|
+
|
|
17641
|
+
if (input instanceof Request) {
|
|
17642
|
+
if (input.bodyUsed) {
|
|
17643
|
+
throw new TypeError('Already read')
|
|
17644
|
+
}
|
|
17645
|
+
this.url = input.url;
|
|
17646
|
+
this.credentials = input.credentials;
|
|
17647
|
+
if (!options.headers) {
|
|
17648
|
+
this.headers = new Headers(input.headers);
|
|
17649
|
+
}
|
|
17650
|
+
this.method = input.method;
|
|
17651
|
+
this.mode = input.mode;
|
|
17652
|
+
this.signal = input.signal;
|
|
17653
|
+
if (!body && input._bodyInit != null) {
|
|
17654
|
+
body = input._bodyInit;
|
|
17655
|
+
input.bodyUsed = true;
|
|
17656
|
+
}
|
|
17657
|
+
} else {
|
|
17658
|
+
this.url = String(input);
|
|
17659
|
+
}
|
|
17660
|
+
|
|
17661
|
+
this.credentials = options.credentials || this.credentials || 'same-origin';
|
|
17662
|
+
if (options.headers || !this.headers) {
|
|
17663
|
+
this.headers = new Headers(options.headers);
|
|
17664
|
+
}
|
|
17665
|
+
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
17666
|
+
this.mode = options.mode || this.mode || null;
|
|
17667
|
+
this.signal = options.signal || this.signal;
|
|
17668
|
+
this.referrer = null;
|
|
17669
|
+
|
|
17670
|
+
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
17671
|
+
throw new TypeError('Body not allowed for GET or HEAD requests')
|
|
17672
|
+
}
|
|
17673
|
+
this._initBody(body);
|
|
17674
|
+
}
|
|
17675
|
+
|
|
17676
|
+
Request.prototype.clone = function() {
|
|
17677
|
+
return new Request(this, {body: this._bodyInit})
|
|
17678
|
+
};
|
|
17679
|
+
|
|
17680
|
+
function decode(body) {
|
|
17681
|
+
var form = new FormData();
|
|
17682
|
+
body
|
|
17683
|
+
.trim()
|
|
17684
|
+
.split('&')
|
|
17685
|
+
.forEach(function(bytes) {
|
|
17686
|
+
if (bytes) {
|
|
17687
|
+
var split = bytes.split('=');
|
|
17688
|
+
var name = split.shift().replace(/\+/g, ' ');
|
|
17689
|
+
var value = split.join('=').replace(/\+/g, ' ');
|
|
17690
|
+
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
17691
|
+
}
|
|
17692
|
+
});
|
|
17693
|
+
return form
|
|
17694
|
+
}
|
|
17695
|
+
|
|
17696
|
+
function parseHeaders(rawHeaders) {
|
|
17697
|
+
var headers = new Headers();
|
|
17698
|
+
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
|
17699
|
+
// https://tools.ietf.org/html/rfc7230#section-3.2
|
|
17700
|
+
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
|
17701
|
+
preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
|
|
17702
|
+
var parts = line.split(':');
|
|
17703
|
+
var key = parts.shift().trim();
|
|
17704
|
+
if (key) {
|
|
17705
|
+
var value = parts.join(':').trim();
|
|
17706
|
+
headers.append(key, value);
|
|
17707
|
+
}
|
|
17708
|
+
});
|
|
17709
|
+
return headers
|
|
17710
|
+
}
|
|
17711
|
+
|
|
17712
|
+
Body.call(Request.prototype);
|
|
17713
|
+
|
|
17714
|
+
function Response(bodyInit, options) {
|
|
17715
|
+
if (!options) {
|
|
17716
|
+
options = {};
|
|
17717
|
+
}
|
|
17718
|
+
|
|
17719
|
+
this.type = 'default';
|
|
17720
|
+
this.status = options.status === undefined ? 200 : options.status;
|
|
17721
|
+
this.ok = this.status >= 200 && this.status < 300;
|
|
17722
|
+
this.statusText = 'statusText' in options ? options.statusText : 'OK';
|
|
17723
|
+
this.headers = new Headers(options.headers);
|
|
17724
|
+
this.url = options.url || '';
|
|
17725
|
+
this._initBody(bodyInit);
|
|
17726
|
+
}
|
|
17727
|
+
|
|
17728
|
+
Body.call(Response.prototype);
|
|
17729
|
+
|
|
17730
|
+
Response.prototype.clone = function() {
|
|
17731
|
+
return new Response(this._bodyInit, {
|
|
17732
|
+
status: this.status,
|
|
17733
|
+
statusText: this.statusText,
|
|
17734
|
+
headers: new Headers(this.headers),
|
|
17735
|
+
url: this.url
|
|
17736
|
+
})
|
|
17737
|
+
};
|
|
17738
|
+
|
|
17739
|
+
Response.error = function() {
|
|
17740
|
+
var response = new Response(null, {status: 0, statusText: ''});
|
|
17741
|
+
response.type = 'error';
|
|
17742
|
+
return response
|
|
17743
|
+
};
|
|
17744
|
+
|
|
17745
|
+
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
17746
|
+
|
|
17747
|
+
Response.redirect = function(url, status) {
|
|
17748
|
+
if (redirectStatuses.indexOf(status) === -1) {
|
|
17749
|
+
throw new RangeError('Invalid status code')
|
|
17750
|
+
}
|
|
17751
|
+
|
|
17752
|
+
return new Response(null, {status: status, headers: {location: url}})
|
|
17753
|
+
};
|
|
17754
|
+
|
|
17755
|
+
exports.DOMException = self.DOMException;
|
|
17756
|
+
try {
|
|
17757
|
+
new exports.DOMException();
|
|
17758
|
+
} catch (err) {
|
|
17759
|
+
exports.DOMException = function(message, name) {
|
|
17760
|
+
this.message = message;
|
|
17761
|
+
this.name = name;
|
|
17762
|
+
var error = Error(message);
|
|
17763
|
+
this.stack = error.stack;
|
|
17764
|
+
};
|
|
17765
|
+
exports.DOMException.prototype = Object.create(Error.prototype);
|
|
17766
|
+
exports.DOMException.prototype.constructor = exports.DOMException;
|
|
17767
|
+
}
|
|
17768
|
+
|
|
17769
|
+
function fetch(input, init) {
|
|
17770
|
+
return new Promise(function(resolve, reject) {
|
|
17771
|
+
var request = new Request(input, init);
|
|
17772
|
+
|
|
17773
|
+
if (request.signal && request.signal.aborted) {
|
|
17774
|
+
return reject(new exports.DOMException('Aborted', 'AbortError'))
|
|
17775
|
+
}
|
|
17776
|
+
|
|
17777
|
+
var xhr = new XMLHttpRequest();
|
|
17778
|
+
|
|
17779
|
+
function abortXhr() {
|
|
17780
|
+
xhr.abort();
|
|
17781
|
+
}
|
|
17782
|
+
|
|
17783
|
+
xhr.onload = function() {
|
|
17784
|
+
var options = {
|
|
17785
|
+
status: xhr.status,
|
|
17786
|
+
statusText: xhr.statusText,
|
|
17787
|
+
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
17788
|
+
};
|
|
17789
|
+
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
17790
|
+
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
17791
|
+
resolve(new Response(body, options));
|
|
17792
|
+
};
|
|
17793
|
+
|
|
17794
|
+
xhr.onerror = function() {
|
|
17795
|
+
reject(new TypeError('Network request failed'));
|
|
17796
|
+
};
|
|
17797
|
+
|
|
17798
|
+
xhr.ontimeout = function() {
|
|
17799
|
+
reject(new TypeError('Network request failed'));
|
|
17800
|
+
};
|
|
17801
|
+
|
|
17802
|
+
xhr.onabort = function() {
|
|
17803
|
+
reject(new exports.DOMException('Aborted', 'AbortError'));
|
|
17804
|
+
};
|
|
17805
|
+
|
|
17806
|
+
xhr.open(request.method, request.url, true);
|
|
17807
|
+
|
|
17808
|
+
if (request.credentials === 'include') {
|
|
17809
|
+
xhr.withCredentials = true;
|
|
17810
|
+
} else if (request.credentials === 'omit') {
|
|
17811
|
+
xhr.withCredentials = false;
|
|
17812
|
+
}
|
|
17813
|
+
|
|
17814
|
+
if ('responseType' in xhr && support.blob) {
|
|
17815
|
+
xhr.responseType = 'blob';
|
|
17816
|
+
}
|
|
17817
|
+
|
|
17818
|
+
request.headers.forEach(function(value, name) {
|
|
17819
|
+
xhr.setRequestHeader(name, value);
|
|
17820
|
+
});
|
|
17821
|
+
|
|
17822
|
+
if (request.signal) {
|
|
17823
|
+
request.signal.addEventListener('abort', abortXhr);
|
|
17824
|
+
|
|
17825
|
+
xhr.onreadystatechange = function() {
|
|
17826
|
+
// DONE (success or failure)
|
|
17827
|
+
if (xhr.readyState === 4) {
|
|
17828
|
+
request.signal.removeEventListener('abort', abortXhr);
|
|
17829
|
+
}
|
|
17830
|
+
};
|
|
17831
|
+
}
|
|
17832
|
+
|
|
17833
|
+
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
|
|
17834
|
+
})
|
|
17835
|
+
}
|
|
17836
|
+
|
|
17837
|
+
fetch.polyfill = true;
|
|
17838
|
+
|
|
17839
|
+
if (!self.fetch) {
|
|
17840
|
+
self.fetch = fetch;
|
|
17841
|
+
self.Headers = Headers;
|
|
17842
|
+
self.Request = Request;
|
|
17843
|
+
self.Response = Response;
|
|
17844
|
+
}
|
|
17845
|
+
|
|
17846
|
+
exports.Headers = Headers;
|
|
17847
|
+
exports.Request = Request;
|
|
17848
|
+
exports.Response = Response;
|
|
17849
|
+
exports.fetch = fetch;
|
|
17850
|
+
|
|
17851
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
17852
|
+
|
|
17853
|
+
return exports;
|
|
17854
|
+
|
|
17855
|
+
}))({});
|
|
17856
|
+
})(__self__);
|
|
17857
|
+
__self__.fetch.ponyfill = true;
|
|
17858
|
+
// Remove "polyfill" property added by whatwg-fetch
|
|
17859
|
+
delete __self__.fetch.polyfill;
|
|
17860
|
+
// Choose between native implementation (global) or custom implementation (__self__)
|
|
17861
|
+
// var ctx = global.fetch ? global : __self__;
|
|
17862
|
+
var ctx = __self__; // this line disable service worker support temporarily
|
|
17863
|
+
exports = ctx.fetch; // To enable: import fetch from 'cross-fetch'
|
|
17864
|
+
exports.default = ctx.fetch; // For TypeScript consumers without esModuleInterop.
|
|
17865
|
+
exports.fetch = ctx.fetch; // To enable: import {fetch} from 'cross-fetch'
|
|
17866
|
+
exports.Headers = ctx.Headers;
|
|
17867
|
+
exports.Request = ctx.Request;
|
|
17868
|
+
exports.Response = ctx.Response;
|
|
17869
|
+
module.exports = exports;
|
|
17870
|
+
});
|
|
17871
|
+
|
|
17872
|
+
unwrapExports(browserPonyfill);
|
|
17873
|
+
|
|
17874
|
+
var ReactNativeFile = function ReactNativeFile(_ref) {
|
|
17875
|
+
var uri = _ref.uri,
|
|
17876
|
+
name = _ref.name,
|
|
17877
|
+
type = _ref.type;
|
|
17878
|
+
this.uri = uri;
|
|
17879
|
+
this.name = name;
|
|
17880
|
+
this.type = type;
|
|
17881
|
+
};
|
|
17882
|
+
|
|
17883
|
+
var isExtractableFile = function isExtractableFile(value) {
|
|
17884
|
+
return (
|
|
17885
|
+
(typeof File !== 'undefined' && value instanceof File) ||
|
|
17886
|
+
(typeof Blob !== 'undefined' && value instanceof Blob) ||
|
|
17887
|
+
value instanceof ReactNativeFile
|
|
17888
|
+
);
|
|
17889
|
+
};
|
|
17890
|
+
|
|
17891
|
+
var extractFiles = function extractFiles(value, path, isExtractableFile$1) {
|
|
17892
|
+
if (path === void 0) {
|
|
17893
|
+
path = '';
|
|
17894
|
+
}
|
|
17895
|
+
|
|
17896
|
+
if (isExtractableFile$1 === void 0) {
|
|
17897
|
+
isExtractableFile$1 = isExtractableFile;
|
|
17898
|
+
}
|
|
17899
|
+
|
|
17900
|
+
var clone;
|
|
17901
|
+
var files = new Map();
|
|
17902
|
+
|
|
17903
|
+
function addFile(paths, file) {
|
|
17904
|
+
var storedPaths = files.get(file);
|
|
17905
|
+
if (storedPaths) storedPaths.push.apply(storedPaths, paths);
|
|
17906
|
+
else files.set(file, paths);
|
|
17907
|
+
}
|
|
17908
|
+
|
|
17909
|
+
if (isExtractableFile$1(value)) {
|
|
17910
|
+
clone = null;
|
|
17911
|
+
addFile([path], value);
|
|
17912
|
+
} else {
|
|
17913
|
+
var prefix = path ? path + '.' : '';
|
|
17914
|
+
if (typeof FileList !== 'undefined' && value instanceof FileList)
|
|
17915
|
+
clone = Array.prototype.map.call(value, function (file, i) {
|
|
17916
|
+
addFile(['' + prefix + i], file);
|
|
17917
|
+
return null;
|
|
17918
|
+
});
|
|
17919
|
+
else if (Array.isArray(value))
|
|
17920
|
+
clone = value.map(function (child, i) {
|
|
17921
|
+
var result = extractFiles(child, '' + prefix + i, isExtractableFile$1);
|
|
17922
|
+
result.files.forEach(addFile);
|
|
17923
|
+
return result.clone;
|
|
17924
|
+
});
|
|
17925
|
+
else if (value && value.constructor === Object) {
|
|
17926
|
+
clone = {};
|
|
17927
|
+
|
|
17928
|
+
for (var i in value) {
|
|
17929
|
+
var result = extractFiles(value[i], '' + prefix + i, isExtractableFile$1);
|
|
17930
|
+
result.files.forEach(addFile);
|
|
17931
|
+
clone[i] = result.clone;
|
|
17932
|
+
}
|
|
17933
|
+
} else clone = value;
|
|
17934
|
+
}
|
|
17935
|
+
|
|
17936
|
+
return {
|
|
17937
|
+
clone: clone,
|
|
17938
|
+
files: files,
|
|
17939
|
+
};
|
|
17940
|
+
};
|
|
17941
|
+
|
|
17942
|
+
|
|
17943
|
+
|
|
17944
|
+
var _public = {
|
|
17945
|
+
__proto__: null,
|
|
17946
|
+
ReactNativeFile: ReactNativeFile,
|
|
17947
|
+
extractFiles: extractFiles,
|
|
17948
|
+
isExtractableFile: isExtractableFile
|
|
17949
|
+
};
|
|
17950
|
+
|
|
17951
|
+
/* eslint-env browser */
|
|
17952
|
+
var browser$1 = typeof self == 'object' ? self.FormData : window.FormData;
|
|
17953
|
+
|
|
17954
|
+
var defaultJsonSerializer = createCommonjsModule(function (module, exports) {
|
|
17955
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17956
|
+
exports.defaultJsonSerializer = void 0;
|
|
17957
|
+
exports.defaultJsonSerializer = {
|
|
17958
|
+
parse: JSON.parse,
|
|
17959
|
+
stringify: JSON.stringify
|
|
17960
|
+
};
|
|
17961
|
+
|
|
17962
|
+
});
|
|
17963
|
+
|
|
17964
|
+
unwrapExports(defaultJsonSerializer);
|
|
17965
|
+
|
|
17966
|
+
var extract_files_1 = getCjsExportFromNamespace(_public);
|
|
17967
|
+
|
|
17968
|
+
var createRequestBody_1 = createCommonjsModule(function (module, exports) {
|
|
17969
|
+
var __importDefault = (commonjsGlobal$1 && commonjsGlobal$1.__importDefault) || function (mod) {
|
|
17970
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17971
|
+
};
|
|
17972
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17973
|
+
|
|
17974
|
+
var form_data_1 = __importDefault(browser$1);
|
|
17975
|
+
|
|
17976
|
+
/**
|
|
17977
|
+
* Duck type if NodeJS stream
|
|
17978
|
+
* https://github.com/sindresorhus/is-stream/blob/3750505b0727f6df54324784fe369365ef78841e/index.js#L3
|
|
17979
|
+
*/
|
|
17980
|
+
var isExtractableFileEnhanced = function (value) {
|
|
17981
|
+
return extract_files_1.isExtractableFile(value) ||
|
|
17982
|
+
(value !== null && typeof value === 'object' && typeof value.pipe === 'function');
|
|
17983
|
+
};
|
|
17984
|
+
/**
|
|
17985
|
+
* Returns Multipart Form if body contains files
|
|
17986
|
+
* (https://github.com/jaydenseric/graphql-multipart-request-spec)
|
|
17987
|
+
* Otherwise returns JSON
|
|
17988
|
+
*/
|
|
17989
|
+
function createRequestBody(query, variables, operationName, jsonSerializer) {
|
|
17990
|
+
if (jsonSerializer === void 0) { jsonSerializer = defaultJsonSerializer.defaultJsonSerializer; }
|
|
17991
|
+
var _a = extract_files_1.extractFiles({ query: query, variables: variables, operationName: operationName }, '', isExtractableFileEnhanced), clone = _a.clone, files = _a.files;
|
|
17992
|
+
if (files.size === 0) {
|
|
17993
|
+
if (!Array.isArray(query)) {
|
|
17994
|
+
return jsonSerializer.stringify(clone);
|
|
17995
|
+
}
|
|
17996
|
+
if (typeof variables !== 'undefined' && !Array.isArray(variables)) {
|
|
17997
|
+
throw new Error('Cannot create request body with given variable type, array expected');
|
|
17998
|
+
}
|
|
17999
|
+
// Batch support
|
|
18000
|
+
var payload = query.reduce(function (accu, currentQuery, index) {
|
|
18001
|
+
accu.push({ query: currentQuery, variables: variables ? variables[index] : undefined });
|
|
18002
|
+
return accu;
|
|
18003
|
+
}, []);
|
|
18004
|
+
return jsonSerializer.stringify(payload);
|
|
18005
|
+
}
|
|
18006
|
+
var Form = typeof FormData === 'undefined' ? form_data_1.default : FormData;
|
|
18007
|
+
var form = new Form();
|
|
18008
|
+
form.append('operations', jsonSerializer.stringify(clone));
|
|
18009
|
+
var map = {};
|
|
18010
|
+
var i = 0;
|
|
18011
|
+
files.forEach(function (paths) {
|
|
18012
|
+
map[++i] = paths;
|
|
18013
|
+
});
|
|
18014
|
+
form.append('map', jsonSerializer.stringify(map));
|
|
18015
|
+
i = 0;
|
|
18016
|
+
files.forEach(function (paths, file) {
|
|
18017
|
+
form.append("" + ++i, file);
|
|
18018
|
+
});
|
|
18019
|
+
return form;
|
|
18020
|
+
}
|
|
18021
|
+
exports.default = createRequestBody;
|
|
18022
|
+
|
|
18023
|
+
});
|
|
18024
|
+
|
|
18025
|
+
unwrapExports(createRequestBody_1);
|
|
18026
|
+
|
|
18027
|
+
var parseArgs = createCommonjsModule(function (module, exports) {
|
|
18028
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18029
|
+
exports.parseBatchRequestsExtendedArgs = exports.parseRawRequestExtendedArgs = exports.parseRequestExtendedArgs = exports.parseBatchRequestArgs = exports.parseRawRequestArgs = exports.parseRequestArgs = void 0;
|
|
18030
|
+
function parseRequestArgs(documentOrOptions, variables, requestHeaders) {
|
|
18031
|
+
return documentOrOptions.document
|
|
18032
|
+
? documentOrOptions
|
|
18033
|
+
: {
|
|
18034
|
+
document: documentOrOptions,
|
|
18035
|
+
variables: variables,
|
|
18036
|
+
requestHeaders: requestHeaders,
|
|
18037
|
+
signal: undefined,
|
|
18038
|
+
};
|
|
18039
|
+
}
|
|
18040
|
+
exports.parseRequestArgs = parseRequestArgs;
|
|
18041
|
+
function parseRawRequestArgs(queryOrOptions, variables, requestHeaders) {
|
|
18042
|
+
return queryOrOptions.query
|
|
18043
|
+
? queryOrOptions
|
|
18044
|
+
: {
|
|
18045
|
+
query: queryOrOptions,
|
|
18046
|
+
variables: variables,
|
|
18047
|
+
requestHeaders: requestHeaders,
|
|
18048
|
+
signal: undefined,
|
|
18049
|
+
};
|
|
18050
|
+
}
|
|
18051
|
+
exports.parseRawRequestArgs = parseRawRequestArgs;
|
|
18052
|
+
function parseBatchRequestArgs(documentsOrOptions, requestHeaders) {
|
|
18053
|
+
return documentsOrOptions.documents
|
|
18054
|
+
? documentsOrOptions
|
|
18055
|
+
: {
|
|
18056
|
+
documents: documentsOrOptions,
|
|
18057
|
+
requestHeaders: requestHeaders,
|
|
18058
|
+
signal: undefined,
|
|
18059
|
+
};
|
|
18060
|
+
}
|
|
18061
|
+
exports.parseBatchRequestArgs = parseBatchRequestArgs;
|
|
18062
|
+
function parseRequestExtendedArgs(urlOrOptions, document, variables, requestHeaders) {
|
|
18063
|
+
return urlOrOptions.document
|
|
18064
|
+
? urlOrOptions
|
|
18065
|
+
: {
|
|
18066
|
+
url: urlOrOptions,
|
|
18067
|
+
document: document,
|
|
18068
|
+
variables: variables,
|
|
18069
|
+
requestHeaders: requestHeaders,
|
|
18070
|
+
signal: undefined,
|
|
18071
|
+
};
|
|
18072
|
+
}
|
|
18073
|
+
exports.parseRequestExtendedArgs = parseRequestExtendedArgs;
|
|
18074
|
+
function parseRawRequestExtendedArgs(urlOrOptions, query, variables, requestHeaders) {
|
|
18075
|
+
return urlOrOptions.query
|
|
18076
|
+
? urlOrOptions
|
|
18077
|
+
: {
|
|
18078
|
+
url: urlOrOptions,
|
|
18079
|
+
query: query,
|
|
18080
|
+
variables: variables,
|
|
18081
|
+
requestHeaders: requestHeaders,
|
|
18082
|
+
signal: undefined,
|
|
18083
|
+
};
|
|
18084
|
+
}
|
|
18085
|
+
exports.parseRawRequestExtendedArgs = parseRawRequestExtendedArgs;
|
|
18086
|
+
function parseBatchRequestsExtendedArgs(urlOrOptions, documents, requestHeaders) {
|
|
18087
|
+
return urlOrOptions.documents
|
|
18088
|
+
? urlOrOptions
|
|
18089
|
+
: {
|
|
18090
|
+
url: urlOrOptions,
|
|
18091
|
+
documents: documents,
|
|
18092
|
+
requestHeaders: requestHeaders,
|
|
18093
|
+
signal: undefined,
|
|
18094
|
+
};
|
|
18095
|
+
}
|
|
18096
|
+
exports.parseBatchRequestsExtendedArgs = parseBatchRequestsExtendedArgs;
|
|
18097
|
+
|
|
18098
|
+
});
|
|
18099
|
+
|
|
18100
|
+
unwrapExports(parseArgs);
|
|
18101
|
+
|
|
18102
|
+
var types = createCommonjsModule(function (module, exports) {
|
|
18103
|
+
var __extends = (commonjsGlobal$1 && commonjsGlobal$1.__extends) || (function () {
|
|
18104
|
+
var extendStatics = function (d, b) {
|
|
18105
|
+
extendStatics = Object.setPrototypeOf ||
|
|
18106
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
18107
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
18108
|
+
return extendStatics(d, b);
|
|
18109
|
+
};
|
|
18110
|
+
return function (d, b) {
|
|
18111
|
+
if (typeof b !== "function" && b !== null)
|
|
18112
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18113
|
+
extendStatics(d, b);
|
|
18114
|
+
function __() { this.constructor = d; }
|
|
18115
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
18116
|
+
};
|
|
18117
|
+
})();
|
|
18118
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18119
|
+
exports.ClientError = void 0;
|
|
18120
|
+
var ClientError = /** @class */ (function (_super) {
|
|
18121
|
+
__extends(ClientError, _super);
|
|
18122
|
+
function ClientError(response, request) {
|
|
18123
|
+
var _this = this;
|
|
18124
|
+
var message = ClientError.extractMessage(response) + ": " + JSON.stringify({
|
|
18125
|
+
response: response,
|
|
18126
|
+
request: request,
|
|
18127
|
+
});
|
|
18128
|
+
_this = _super.call(this, message) || this;
|
|
18129
|
+
Object.setPrototypeOf(_this, ClientError.prototype);
|
|
18130
|
+
_this.response = response;
|
|
18131
|
+
_this.request = request;
|
|
18132
|
+
// this is needed as Safari doesn't support .captureStackTrace
|
|
18133
|
+
if (typeof Error.captureStackTrace === 'function') {
|
|
18134
|
+
Error.captureStackTrace(_this, ClientError);
|
|
18135
|
+
}
|
|
18136
|
+
return _this;
|
|
18137
|
+
}
|
|
18138
|
+
ClientError.extractMessage = function (response) {
|
|
18139
|
+
try {
|
|
18140
|
+
return response.errors[0].message;
|
|
18141
|
+
}
|
|
18142
|
+
catch (e) {
|
|
18143
|
+
return "GraphQL Error (Code: " + response.status + ")";
|
|
18144
|
+
}
|
|
18145
|
+
};
|
|
18146
|
+
return ClientError;
|
|
18147
|
+
}(Error));
|
|
18148
|
+
exports.ClientError = ClientError;
|
|
18149
|
+
|
|
18150
|
+
});
|
|
18151
|
+
|
|
18152
|
+
unwrapExports(types);
|
|
18153
|
+
|
|
18154
|
+
var graphqlWs = createCommonjsModule(function (module, exports) {
|
|
18155
|
+
var __assign = (commonjsGlobal$1 && commonjsGlobal$1.__assign) || function () {
|
|
18156
|
+
__assign = Object.assign || function(t) {
|
|
18157
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18158
|
+
s = arguments[i];
|
|
18159
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
18160
|
+
t[p] = s[p];
|
|
18161
|
+
}
|
|
18162
|
+
return t;
|
|
18163
|
+
};
|
|
18164
|
+
return __assign.apply(this, arguments);
|
|
18165
|
+
};
|
|
18166
|
+
var __awaiter = (commonjsGlobal$1 && commonjsGlobal$1.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18167
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18168
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18169
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18170
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18171
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18172
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18173
|
+
});
|
|
18174
|
+
};
|
|
18175
|
+
var __generator = (commonjsGlobal$1 && commonjsGlobal$1.__generator) || function (thisArg, body) {
|
|
18176
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
18177
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18178
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
18179
|
+
function step(op) {
|
|
18180
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18181
|
+
while (_) try {
|
|
18182
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18183
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
18184
|
+
switch (op[0]) {
|
|
18185
|
+
case 0: case 1: t = op; break;
|
|
18186
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
18187
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
18188
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
18189
|
+
default:
|
|
18190
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18191
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
18192
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
18193
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
18194
|
+
if (t[2]) _.ops.pop();
|
|
18195
|
+
_.trys.pop(); continue;
|
|
18196
|
+
}
|
|
18197
|
+
op = body.call(thisArg, _);
|
|
18198
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
18199
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
18200
|
+
}
|
|
18201
|
+
};
|
|
18202
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18203
|
+
exports.GraphQLWebSocketClient = void 0;
|
|
18204
|
+
|
|
18205
|
+
|
|
18206
|
+
var CONNECTION_INIT = 'connection_init';
|
|
18207
|
+
var CONNECTION_ACK = 'connection_ack';
|
|
18208
|
+
var PING = 'ping';
|
|
18209
|
+
var PONG = 'pong';
|
|
18210
|
+
var SUBSCRIBE = 'subscribe';
|
|
18211
|
+
var NEXT = 'next';
|
|
18212
|
+
var ERROR = 'error';
|
|
18213
|
+
var COMPLETE = 'complete';
|
|
18214
|
+
var GraphQLWebSocketMessage = /** @class */ (function () {
|
|
18215
|
+
function GraphQLWebSocketMessage(type, payload, id) {
|
|
18216
|
+
this._type = type;
|
|
18217
|
+
this._payload = payload;
|
|
18218
|
+
this._id = id;
|
|
18219
|
+
}
|
|
18220
|
+
Object.defineProperty(GraphQLWebSocketMessage.prototype, "type", {
|
|
18221
|
+
get: function () { return this._type; },
|
|
18222
|
+
enumerable: false,
|
|
18223
|
+
configurable: true
|
|
18224
|
+
});
|
|
18225
|
+
Object.defineProperty(GraphQLWebSocketMessage.prototype, "id", {
|
|
18226
|
+
get: function () { return this._id; },
|
|
18227
|
+
enumerable: false,
|
|
18228
|
+
configurable: true
|
|
18229
|
+
});
|
|
18230
|
+
Object.defineProperty(GraphQLWebSocketMessage.prototype, "payload", {
|
|
18231
|
+
get: function () { return this._payload; },
|
|
18232
|
+
enumerable: false,
|
|
18233
|
+
configurable: true
|
|
18234
|
+
});
|
|
18235
|
+
Object.defineProperty(GraphQLWebSocketMessage.prototype, "text", {
|
|
18236
|
+
get: function () {
|
|
18237
|
+
var result = { type: this.type };
|
|
18238
|
+
if (this.id != null && this.id != undefined)
|
|
18239
|
+
result.id = this.id;
|
|
18240
|
+
if (this.payload != null && this.payload != undefined)
|
|
18241
|
+
result.payload = this.payload;
|
|
18242
|
+
return JSON.stringify(result);
|
|
18243
|
+
},
|
|
18244
|
+
enumerable: false,
|
|
18245
|
+
configurable: true
|
|
18246
|
+
});
|
|
18247
|
+
GraphQLWebSocketMessage.parse = function (data, f) {
|
|
18248
|
+
var _a = JSON.parse(data), type = _a.type, payload = _a.payload, id = _a.id;
|
|
18249
|
+
return new GraphQLWebSocketMessage(type, f(payload), id);
|
|
18250
|
+
};
|
|
18251
|
+
return GraphQLWebSocketMessage;
|
|
18252
|
+
}());
|
|
18253
|
+
var GraphQLWebSocketClient = /** @class */ (function () {
|
|
18254
|
+
function GraphQLWebSocketClient(socket, _a) {
|
|
18255
|
+
var _this = this;
|
|
18256
|
+
var onInit = _a.onInit, onAcknowledged = _a.onAcknowledged, onPing = _a.onPing, onPong = _a.onPong;
|
|
18257
|
+
this.socketState = { acknowledged: false, lastRequestId: 0, subscriptions: {} };
|
|
18258
|
+
this.socket = socket;
|
|
18259
|
+
socket.onopen = function (e) { return __awaiter(_this, void 0, void 0, function () {
|
|
18260
|
+
var _a, _b, _c, _d;
|
|
18261
|
+
return __generator(this, function (_e) {
|
|
18262
|
+
switch (_e.label) {
|
|
18263
|
+
case 0:
|
|
18264
|
+
this.socketState.acknowledged = false;
|
|
18265
|
+
this.socketState.subscriptions = {};
|
|
18266
|
+
_b = (_a = socket).send;
|
|
18267
|
+
_c = ConnectionInit;
|
|
18268
|
+
if (!onInit) return [3 /*break*/, 2];
|
|
18269
|
+
return [4 /*yield*/, onInit()];
|
|
18270
|
+
case 1:
|
|
18271
|
+
_d = _e.sent();
|
|
18272
|
+
return [3 /*break*/, 3];
|
|
18273
|
+
case 2:
|
|
18274
|
+
_d = null;
|
|
18275
|
+
_e.label = 3;
|
|
18276
|
+
case 3:
|
|
18277
|
+
_b.apply(_a, [_c.apply(void 0, [_d]).text]);
|
|
18278
|
+
return [2 /*return*/];
|
|
18279
|
+
}
|
|
18280
|
+
});
|
|
18281
|
+
}); };
|
|
18282
|
+
socket.onclose = function (e) {
|
|
18283
|
+
_this.socketState.acknowledged = false;
|
|
18284
|
+
_this.socketState.subscriptions = {};
|
|
18285
|
+
};
|
|
18286
|
+
socket.onerror = function (e) {
|
|
18287
|
+
console.error(e);
|
|
18288
|
+
};
|
|
18289
|
+
socket.onmessage = function (e) {
|
|
18290
|
+
try {
|
|
18291
|
+
var message = parseMessage(e.data);
|
|
18292
|
+
switch (message.type) {
|
|
18293
|
+
case CONNECTION_ACK: {
|
|
18294
|
+
if (_this.socketState.acknowledged) {
|
|
18295
|
+
console.warn("Duplicate CONNECTION_ACK message ignored");
|
|
18296
|
+
}
|
|
18297
|
+
else {
|
|
18298
|
+
_this.socketState.acknowledged = true;
|
|
18299
|
+
if (onAcknowledged)
|
|
18300
|
+
onAcknowledged(message.payload);
|
|
18301
|
+
}
|
|
18302
|
+
return;
|
|
18303
|
+
}
|
|
18304
|
+
case PING: {
|
|
18305
|
+
if (onPing)
|
|
18306
|
+
onPing(message.payload).then(function (r) { return socket.send(Pong(r).text); });
|
|
18307
|
+
else
|
|
18308
|
+
socket.send(Pong(null).text);
|
|
18309
|
+
return;
|
|
18310
|
+
}
|
|
18311
|
+
case PONG: {
|
|
18312
|
+
if (onPong)
|
|
18313
|
+
onPong(message.payload);
|
|
18314
|
+
return;
|
|
18315
|
+
}
|
|
18316
|
+
}
|
|
18317
|
+
if (!_this.socketState.acknowledged) {
|
|
18318
|
+
// Web-socket connection not acknowledged
|
|
18319
|
+
return;
|
|
18320
|
+
}
|
|
18321
|
+
if (message.id === undefined || message.id === null || !_this.socketState.subscriptions[message.id]) {
|
|
18322
|
+
// No subscription identifer or subscription indentifier is not found
|
|
18323
|
+
return;
|
|
18324
|
+
}
|
|
18325
|
+
var _a = _this.socketState.subscriptions[message.id], query = _a.query, variables = _a.variables, subscriber = _a.subscriber;
|
|
18326
|
+
switch (message.type) {
|
|
18327
|
+
case NEXT: {
|
|
18328
|
+
if (!message.payload.errors && message.payload.data) {
|
|
18329
|
+
subscriber.next && subscriber.next(message.payload.data);
|
|
18330
|
+
}
|
|
18331
|
+
if (message.payload.errors) {
|
|
18332
|
+
subscriber.error && subscriber.error(new types.ClientError(__assign(__assign({}, message.payload), { status: 200 }), { query: query, variables: variables }));
|
|
18333
|
+
}
|
|
18334
|
+
else {
|
|
18335
|
+
}
|
|
18336
|
+
return;
|
|
18337
|
+
}
|
|
18338
|
+
case ERROR: {
|
|
18339
|
+
subscriber.error && subscriber.error(new types.ClientError({ errors: message.payload, status: 200 }, { query: query, variables: variables }));
|
|
18340
|
+
return;
|
|
18341
|
+
}
|
|
18342
|
+
case COMPLETE: {
|
|
18343
|
+
subscriber.complete && subscriber.complete();
|
|
18344
|
+
delete _this.socketState.subscriptions[message.id];
|
|
18345
|
+
return;
|
|
18346
|
+
}
|
|
18347
|
+
}
|
|
18348
|
+
}
|
|
18349
|
+
catch (e) {
|
|
18350
|
+
// Unexpected errors while handling graphql-ws message
|
|
18351
|
+
console.error(e);
|
|
18352
|
+
socket.close(1006);
|
|
18353
|
+
}
|
|
18354
|
+
socket.close(4400, "Unknown graphql-ws message.");
|
|
18355
|
+
};
|
|
18356
|
+
}
|
|
18357
|
+
GraphQLWebSocketClient.prototype.makeSubscribe = function (query, operationName, variables, subscriber) {
|
|
18358
|
+
var _this = this;
|
|
18359
|
+
var subscriptionId = (this.socketState.lastRequestId++).toString();
|
|
18360
|
+
this.socketState.subscriptions[subscriptionId] = { query: query, variables: variables, subscriber: subscriber };
|
|
18361
|
+
this.socket.send(Subscribe(subscriptionId, { query: query, operationName: operationName, variables: variables }).text);
|
|
18362
|
+
return function () {
|
|
18363
|
+
_this.socket.send(Complete(subscriptionId).text);
|
|
18364
|
+
delete _this.socketState.subscriptions[subscriptionId];
|
|
18365
|
+
};
|
|
18366
|
+
};
|
|
18367
|
+
GraphQLWebSocketClient.prototype.rawRequest = function (query, variables) {
|
|
15872
18368
|
var _this = this;
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
18369
|
+
return new Promise(function (resolve, reject) {
|
|
18370
|
+
var result;
|
|
18371
|
+
_this.rawSubscribe(query, {
|
|
18372
|
+
next: function (data, extensions) { return (result = { data: data, extensions: extensions }); },
|
|
18373
|
+
error: reject,
|
|
18374
|
+
complete: function () { return resolve(result); },
|
|
18375
|
+
}, variables);
|
|
15877
18376
|
});
|
|
15878
18377
|
};
|
|
15879
|
-
|
|
15880
|
-
|
|
18378
|
+
GraphQLWebSocketClient.prototype.request = function (document, variables) {
|
|
18379
|
+
var _this = this;
|
|
18380
|
+
return new Promise(function (resolve, reject) {
|
|
18381
|
+
var result;
|
|
18382
|
+
_this.subscribe(document, {
|
|
18383
|
+
next: function (data) { return (result = data); },
|
|
18384
|
+
error: reject,
|
|
18385
|
+
complete: function () { return resolve(result); },
|
|
18386
|
+
}, variables);
|
|
18387
|
+
});
|
|
15881
18388
|
};
|
|
15882
|
-
|
|
18389
|
+
GraphQLWebSocketClient.prototype.subscribe = function (document, subscriber, variables) {
|
|
18390
|
+
var _a = dist.resolveRequestDocument(document), query = _a.query, operationName = _a.operationName;
|
|
18391
|
+
return this.makeSubscribe(query, operationName, variables, subscriber);
|
|
18392
|
+
};
|
|
18393
|
+
GraphQLWebSocketClient.prototype.rawSubscribe = function (query, subscriber, variables) {
|
|
18394
|
+
return this.makeSubscribe(query, undefined, variables, subscriber);
|
|
18395
|
+
};
|
|
18396
|
+
GraphQLWebSocketClient.prototype.ping = function (payload) {
|
|
18397
|
+
this.socket.send(Ping(payload).text);
|
|
18398
|
+
};
|
|
18399
|
+
GraphQLWebSocketClient.prototype.close = function () {
|
|
18400
|
+
this.socket.close(1000);
|
|
18401
|
+
};
|
|
18402
|
+
GraphQLWebSocketClient.PROTOCOL = "graphql-transport-ws";
|
|
18403
|
+
return GraphQLWebSocketClient;
|
|
15883
18404
|
}());
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
}
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
18405
|
+
exports.GraphQLWebSocketClient = GraphQLWebSocketClient;
|
|
18406
|
+
// Helper functions
|
|
18407
|
+
function parseMessage(data, f) {
|
|
18408
|
+
if (f === void 0) { f = function (a) { return a; }; }
|
|
18409
|
+
var m = GraphQLWebSocketMessage.parse(data, f);
|
|
18410
|
+
return m;
|
|
18411
|
+
}
|
|
18412
|
+
function ConnectionInit(payload) {
|
|
18413
|
+
return new GraphQLWebSocketMessage(CONNECTION_INIT, payload);
|
|
18414
|
+
}
|
|
18415
|
+
function Ping(payload) {
|
|
18416
|
+
return new GraphQLWebSocketMessage(PING, payload, undefined);
|
|
18417
|
+
}
|
|
18418
|
+
function Pong(payload) {
|
|
18419
|
+
return new GraphQLWebSocketMessage(PONG, payload, undefined);
|
|
18420
|
+
}
|
|
18421
|
+
function Subscribe(id, payload) {
|
|
18422
|
+
return new GraphQLWebSocketMessage(SUBSCRIBE, payload, id);
|
|
18423
|
+
}
|
|
18424
|
+
function Complete(id) {
|
|
18425
|
+
return new GraphQLWebSocketMessage(COMPLETE, undefined, id);
|
|
15892
18426
|
}
|
|
15893
18427
|
|
|
15894
|
-
|
|
15895
|
-
function ActionCableClient(url) {
|
|
15896
|
-
var _this = this;
|
|
18428
|
+
});
|
|
15897
18429
|
|
|
15898
|
-
|
|
15899
|
-
this.subscriptions = new Map();
|
|
18430
|
+
unwrapExports(graphqlWs);
|
|
15900
18431
|
|
|
15901
|
-
|
|
15902
|
-
_this.subscriptions.set(id, subscription);
|
|
15903
|
-
};
|
|
18432
|
+
var parser_1 = getCjsExportFromNamespace(parser);
|
|
15904
18433
|
|
|
15905
|
-
|
|
15906
|
-
}
|
|
18434
|
+
var printer_1 = getCjsExportFromNamespace(printer);
|
|
15907
18435
|
|
|
15908
|
-
|
|
18436
|
+
var dist = createCommonjsModule(function (module, exports) {
|
|
18437
|
+
var __assign = (commonjsGlobal$1 && commonjsGlobal$1.__assign) || function () {
|
|
18438
|
+
__assign = Object.assign || function(t) {
|
|
18439
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18440
|
+
s = arguments[i];
|
|
18441
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
18442
|
+
t[p] = s[p];
|
|
18443
|
+
}
|
|
18444
|
+
return t;
|
|
18445
|
+
};
|
|
18446
|
+
return __assign.apply(this, arguments);
|
|
18447
|
+
};
|
|
18448
|
+
var __createBinding = (commonjsGlobal$1 && commonjsGlobal$1.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18449
|
+
if (k2 === undefined) k2 = k;
|
|
18450
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
18451
|
+
}) : (function(o, m, k, k2) {
|
|
18452
|
+
if (k2 === undefined) k2 = k;
|
|
18453
|
+
o[k2] = m[k];
|
|
18454
|
+
}));
|
|
18455
|
+
var __setModuleDefault = (commonjsGlobal$1 && commonjsGlobal$1.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18456
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18457
|
+
}) : function(o, v) {
|
|
18458
|
+
o["default"] = v;
|
|
18459
|
+
});
|
|
18460
|
+
var __importStar = (commonjsGlobal$1 && commonjsGlobal$1.__importStar) || function (mod) {
|
|
18461
|
+
if (mod && mod.__esModule) return mod;
|
|
18462
|
+
var result = {};
|
|
18463
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18464
|
+
__setModuleDefault(result, mod);
|
|
18465
|
+
return result;
|
|
18466
|
+
};
|
|
18467
|
+
var __awaiter = (commonjsGlobal$1 && commonjsGlobal$1.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18468
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18469
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18470
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18471
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18472
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18473
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18474
|
+
});
|
|
18475
|
+
};
|
|
18476
|
+
var __generator = (commonjsGlobal$1 && commonjsGlobal$1.__generator) || function (thisArg, body) {
|
|
18477
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
18478
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18479
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
18480
|
+
function step(op) {
|
|
18481
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18482
|
+
while (_) try {
|
|
18483
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18484
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
18485
|
+
switch (op[0]) {
|
|
18486
|
+
case 0: case 1: t = op; break;
|
|
18487
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
18488
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
18489
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
18490
|
+
default:
|
|
18491
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18492
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
18493
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
18494
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
18495
|
+
if (t[2]) _.ops.pop();
|
|
18496
|
+
_.trys.pop(); continue;
|
|
18497
|
+
}
|
|
18498
|
+
op = body.call(thisArg, _);
|
|
18499
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
18500
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
18501
|
+
}
|
|
18502
|
+
};
|
|
18503
|
+
var __rest = (commonjsGlobal$1 && commonjsGlobal$1.__rest) || function (s, e) {
|
|
18504
|
+
var t = {};
|
|
18505
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
18506
|
+
t[p] = s[p];
|
|
18507
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18508
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18509
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18510
|
+
t[p[i]] = s[p[i]];
|
|
18511
|
+
}
|
|
18512
|
+
return t;
|
|
18513
|
+
};
|
|
18514
|
+
var __importDefault = (commonjsGlobal$1 && commonjsGlobal$1.__importDefault) || function (mod) {
|
|
18515
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18516
|
+
};
|
|
18517
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18518
|
+
exports.GraphQLWebSocketClient = exports.gql = exports.resolveRequestDocument = exports.batchRequests = exports.request = exports.rawRequest = exports.GraphQLClient = exports.ClientError = void 0;
|
|
18519
|
+
var cross_fetch_1 = __importStar(browserPonyfill), CrossFetch = cross_fetch_1;
|
|
15909
18520
|
|
|
15910
|
-
_proto.connect = function connect(token, lang) {
|
|
15911
|
-
this.cable = action_cable.createConsumer(this.wsURL + "?token=" + token + "&lang=" + lang);
|
|
15912
|
-
};
|
|
15913
18521
|
|
|
15914
|
-
|
|
15915
|
-
var cable = this.cable,
|
|
15916
|
-
subscriptions = this.subscriptions,
|
|
15917
|
-
addSubscription = this.addSubscription;
|
|
15918
|
-
var subscription;
|
|
15919
|
-
return new Observable(function (observer) {
|
|
15920
|
-
if (cable) {
|
|
15921
|
-
var _request$variables;
|
|
18522
|
+
var createRequestBody_1$1 = __importDefault(createRequestBody_1);
|
|
15922
18523
|
|
|
15923
|
-
var subscriptionId = ((_request$variables = _request.variables) === null || _request$variables === void 0 ? void 0 : _request$variables.id) || 'company';
|
|
15924
18524
|
|
|
15925
|
-
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
|
|
15929
|
-
|
|
15930
|
-
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
15934
|
-
|
|
15935
|
-
|
|
15936
|
-
|
|
18525
|
+
|
|
18526
|
+
Object.defineProperty(exports, "ClientError", { enumerable: true, get: function () { return types.ClientError; } });
|
|
18527
|
+
/**
|
|
18528
|
+
* Convert the given headers configuration into a plain object.
|
|
18529
|
+
*/
|
|
18530
|
+
var resolveHeaders = function (headers) {
|
|
18531
|
+
var oHeaders = {};
|
|
18532
|
+
if (headers) {
|
|
18533
|
+
if ((typeof Headers !== 'undefined' && headers instanceof Headers) ||
|
|
18534
|
+
headers instanceof CrossFetch.Headers) {
|
|
18535
|
+
oHeaders = HeadersInstanceToPlainObject(headers);
|
|
18536
|
+
}
|
|
18537
|
+
else if (Array.isArray(headers)) {
|
|
18538
|
+
headers.forEach(function (_a) {
|
|
18539
|
+
var name = _a[0], value = _a[1];
|
|
18540
|
+
oHeaders[name] = value;
|
|
18541
|
+
});
|
|
18542
|
+
}
|
|
18543
|
+
else {
|
|
18544
|
+
oHeaders = headers;
|
|
18545
|
+
}
|
|
18546
|
+
}
|
|
18547
|
+
return oHeaders;
|
|
18548
|
+
};
|
|
18549
|
+
/**
|
|
18550
|
+
* Clean a GraphQL document to send it via a GET query
|
|
18551
|
+
*
|
|
18552
|
+
* @param {string} str GraphQL query
|
|
18553
|
+
* @returns {string} Cleaned query
|
|
18554
|
+
*/
|
|
18555
|
+
var queryCleanner = function (str) { return str.replace(/([\s,]|#[^\n\r]+)+/g, ' ').trim(); };
|
|
18556
|
+
/**
|
|
18557
|
+
* Create query string for GraphQL request
|
|
18558
|
+
*
|
|
18559
|
+
* @param {object} param0 -
|
|
18560
|
+
*
|
|
18561
|
+
* @param {string|string[]} param0.query the GraphQL document or array of document if it's a batch request
|
|
18562
|
+
* @param {string|undefined} param0.operationName the GraphQL operation name
|
|
18563
|
+
* @param {any|any[]} param0.variables the GraphQL variables to use
|
|
18564
|
+
*/
|
|
18565
|
+
var buildGetQueryParams = function (_a) {
|
|
18566
|
+
var query = _a.query, variables = _a.variables, operationName = _a.operationName, jsonSerializer = _a.jsonSerializer;
|
|
18567
|
+
if (!Array.isArray(query)) {
|
|
18568
|
+
var search = ["query=" + encodeURIComponent(queryCleanner(query))];
|
|
18569
|
+
if (variables) {
|
|
18570
|
+
search.push("variables=" + encodeURIComponent(jsonSerializer.stringify(variables)));
|
|
18571
|
+
}
|
|
18572
|
+
if (operationName) {
|
|
18573
|
+
search.push("operationName=" + encodeURIComponent(operationName));
|
|
18574
|
+
}
|
|
18575
|
+
return search.join('&');
|
|
18576
|
+
}
|
|
18577
|
+
if (typeof variables !== 'undefined' && !Array.isArray(variables)) {
|
|
18578
|
+
throw new Error('Cannot create query with given variable type, array expected');
|
|
18579
|
+
}
|
|
18580
|
+
// Batch support
|
|
18581
|
+
var payload = query.reduce(function (accu, currentQuery, index) {
|
|
18582
|
+
accu.push({
|
|
18583
|
+
query: queryCleanner(currentQuery),
|
|
18584
|
+
variables: variables ? jsonSerializer.stringify(variables[index]) : undefined,
|
|
18585
|
+
});
|
|
18586
|
+
return accu;
|
|
18587
|
+
}, []);
|
|
18588
|
+
return "query=" + encodeURIComponent(jsonSerializer.stringify(payload));
|
|
18589
|
+
};
|
|
18590
|
+
/**
|
|
18591
|
+
* Fetch data using POST method
|
|
18592
|
+
*/
|
|
18593
|
+
var post = function (_a) {
|
|
18594
|
+
var url = _a.url, query = _a.query, variables = _a.variables, operationName = _a.operationName, headers = _a.headers, fetch = _a.fetch, fetchOptions = _a.fetchOptions;
|
|
18595
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
18596
|
+
var body;
|
|
18597
|
+
return __generator(this, function (_b) {
|
|
18598
|
+
switch (_b.label) {
|
|
18599
|
+
case 0:
|
|
18600
|
+
body = createRequestBody_1$1.default(query, variables, operationName, fetchOptions.jsonSerializer);
|
|
18601
|
+
return [4 /*yield*/, fetch(url, __assign({ method: 'POST', headers: __assign(__assign({}, (typeof body === 'string' ? { 'Content-Type': 'application/json' } : {})), headers), body: body }, fetchOptions))];
|
|
18602
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
18603
|
+
}
|
|
18604
|
+
});
|
|
18605
|
+
});
|
|
18606
|
+
};
|
|
18607
|
+
/**
|
|
18608
|
+
* Fetch data using GET method
|
|
18609
|
+
*/
|
|
18610
|
+
var get = function (_a) {
|
|
18611
|
+
var url = _a.url, query = _a.query, variables = _a.variables, operationName = _a.operationName, headers = _a.headers, fetch = _a.fetch, fetchOptions = _a.fetchOptions;
|
|
18612
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
18613
|
+
var queryParams;
|
|
18614
|
+
return __generator(this, function (_b) {
|
|
18615
|
+
switch (_b.label) {
|
|
18616
|
+
case 0:
|
|
18617
|
+
queryParams = buildGetQueryParams({
|
|
18618
|
+
query: query,
|
|
18619
|
+
variables: variables,
|
|
18620
|
+
operationName: operationName,
|
|
18621
|
+
jsonSerializer: fetchOptions.jsonSerializer
|
|
18622
|
+
});
|
|
18623
|
+
return [4 /*yield*/, fetch(url + "?" + queryParams, __assign({ method: 'GET', headers: headers }, fetchOptions))];
|
|
18624
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
18625
|
+
}
|
|
18626
|
+
});
|
|
18627
|
+
});
|
|
18628
|
+
};
|
|
18629
|
+
/**
|
|
18630
|
+
* GraphQL Client.
|
|
18631
|
+
*/
|
|
18632
|
+
var GraphQLClient = /** @class */ (function () {
|
|
18633
|
+
function GraphQLClient(url, options) {
|
|
18634
|
+
this.url = url;
|
|
18635
|
+
this.options = options || {};
|
|
18636
|
+
}
|
|
18637
|
+
GraphQLClient.prototype.rawRequest = function (queryOrOptions, variables, requestHeaders) {
|
|
18638
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18639
|
+
var rawRequestOptions, _a, headers, _b, fetch, _c, method, fetchOptions, url, operationName;
|
|
18640
|
+
return __generator(this, function (_d) {
|
|
18641
|
+
rawRequestOptions = parseArgs.parseRawRequestArgs(queryOrOptions, variables, requestHeaders);
|
|
18642
|
+
_a = this.options, headers = _a.headers, _b = _a.fetch, fetch = _b === void 0 ? cross_fetch_1.default : _b, _c = _a.method, method = _c === void 0 ? 'POST' : _c, fetchOptions = __rest(_a, ["headers", "fetch", "method"]);
|
|
18643
|
+
url = this.url;
|
|
18644
|
+
if (rawRequestOptions.signal !== undefined) {
|
|
18645
|
+
fetchOptions.signal = rawRequestOptions.signal;
|
|
15937
18646
|
}
|
|
15938
|
-
|
|
15939
|
-
|
|
15940
|
-
|
|
18647
|
+
operationName = resolveRequestDocument(rawRequestOptions.query).operationName;
|
|
18648
|
+
return [2 /*return*/, makeRequest({
|
|
18649
|
+
url: url,
|
|
18650
|
+
query: rawRequestOptions.query,
|
|
18651
|
+
variables: rawRequestOptions.variables,
|
|
18652
|
+
headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(rawRequestOptions.requestHeaders)),
|
|
18653
|
+
operationName: operationName,
|
|
18654
|
+
fetch: fetch,
|
|
18655
|
+
method: method,
|
|
18656
|
+
fetchOptions: fetchOptions,
|
|
18657
|
+
})];
|
|
18658
|
+
});
|
|
18659
|
+
});
|
|
18660
|
+
};
|
|
18661
|
+
GraphQLClient.prototype.request = function (documentOrOptions, variables, requestHeaders) {
|
|
18662
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18663
|
+
var requestOptions, _a, headers, _b, fetch, _c, method, fetchOptions, url, _d, query, operationName, data;
|
|
18664
|
+
return __generator(this, function (_e) {
|
|
18665
|
+
switch (_e.label) {
|
|
18666
|
+
case 0:
|
|
18667
|
+
requestOptions = parseArgs.parseRequestArgs(documentOrOptions, variables, requestHeaders);
|
|
18668
|
+
_a = this.options, headers = _a.headers, _b = _a.fetch, fetch = _b === void 0 ? cross_fetch_1.default : _b, _c = _a.method, method = _c === void 0 ? 'POST' : _c, fetchOptions = __rest(_a, ["headers", "fetch", "method"]);
|
|
18669
|
+
url = this.url;
|
|
18670
|
+
if (requestOptions.signal !== undefined) {
|
|
18671
|
+
fetchOptions.signal = requestOptions.signal;
|
|
18672
|
+
}
|
|
18673
|
+
_d = resolveRequestDocument(requestOptions.document), query = _d.query, operationName = _d.operationName;
|
|
18674
|
+
return [4 /*yield*/, makeRequest({
|
|
18675
|
+
url: url,
|
|
18676
|
+
query: query,
|
|
18677
|
+
variables: requestOptions.variables,
|
|
18678
|
+
headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(requestOptions.requestHeaders)),
|
|
18679
|
+
operationName: operationName,
|
|
18680
|
+
fetch: fetch,
|
|
18681
|
+
method: method,
|
|
18682
|
+
fetchOptions: fetchOptions,
|
|
18683
|
+
})];
|
|
18684
|
+
case 1:
|
|
18685
|
+
data = (_e.sent()).data;
|
|
18686
|
+
return [2 /*return*/, data];
|
|
15941
18687
|
}
|
|
15942
|
-
|
|
15943
|
-
|
|
15944
|
-
|
|
15945
|
-
|
|
15946
|
-
|
|
18688
|
+
});
|
|
18689
|
+
});
|
|
18690
|
+
};
|
|
18691
|
+
GraphQLClient.prototype.batchRequests = function (documentsOrOptions, requestHeaders) {
|
|
18692
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18693
|
+
var batchRequestOptions, _a, headers, _b, fetch, _c, method, fetchOptions, url, queries, variables, data;
|
|
18694
|
+
return __generator(this, function (_d) {
|
|
18695
|
+
switch (_d.label) {
|
|
18696
|
+
case 0:
|
|
18697
|
+
batchRequestOptions = parseArgs.parseBatchRequestArgs(documentsOrOptions, requestHeaders);
|
|
18698
|
+
_a = this.options, headers = _a.headers, _b = _a.fetch, fetch = _b === void 0 ? cross_fetch_1.default : _b, _c = _a.method, method = _c === void 0 ? 'POST' : _c, fetchOptions = __rest(_a, ["headers", "fetch", "method"]);
|
|
18699
|
+
url = this.url;
|
|
18700
|
+
if (batchRequestOptions.signal !== undefined) {
|
|
18701
|
+
fetchOptions.signal = batchRequestOptions.signal;
|
|
18702
|
+
}
|
|
18703
|
+
queries = batchRequestOptions.documents.map(function (_a) {
|
|
18704
|
+
var document = _a.document;
|
|
18705
|
+
return resolveRequestDocument(document).query;
|
|
18706
|
+
});
|
|
18707
|
+
variables = batchRequestOptions.documents.map(function (_a) {
|
|
18708
|
+
var variables = _a.variables;
|
|
18709
|
+
return variables;
|
|
18710
|
+
});
|
|
18711
|
+
return [4 /*yield*/, makeRequest({
|
|
18712
|
+
url: url,
|
|
18713
|
+
query: queries,
|
|
18714
|
+
variables: variables,
|
|
18715
|
+
headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(batchRequestOptions.requestHeaders)),
|
|
18716
|
+
operationName: undefined,
|
|
18717
|
+
fetch: fetch,
|
|
18718
|
+
method: method,
|
|
18719
|
+
fetchOptions: fetchOptions,
|
|
18720
|
+
})];
|
|
18721
|
+
case 1:
|
|
18722
|
+
data = (_d.sent()).data;
|
|
18723
|
+
return [2 /*return*/, data];
|
|
15947
18724
|
}
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
18725
|
+
});
|
|
18726
|
+
});
|
|
18727
|
+
};
|
|
18728
|
+
GraphQLClient.prototype.setHeaders = function (headers) {
|
|
18729
|
+
this.options.headers = headers;
|
|
18730
|
+
return this;
|
|
18731
|
+
};
|
|
18732
|
+
/**
|
|
18733
|
+
* Attach a header to the client. All subsequent requests will have this header.
|
|
18734
|
+
*/
|
|
18735
|
+
GraphQLClient.prototype.setHeader = function (key, value) {
|
|
18736
|
+
var _a;
|
|
18737
|
+
var headers = this.options.headers;
|
|
18738
|
+
if (headers) {
|
|
18739
|
+
// todo what if headers is in nested array form... ?
|
|
18740
|
+
//@ts-ignore
|
|
18741
|
+
headers[key] = value;
|
|
15952
18742
|
}
|
|
15953
|
-
|
|
18743
|
+
else {
|
|
18744
|
+
this.options.headers = (_a = {}, _a[key] = value, _a);
|
|
18745
|
+
}
|
|
18746
|
+
return this;
|
|
18747
|
+
};
|
|
18748
|
+
/**
|
|
18749
|
+
* Change the client endpoint. All subsequent requests will send to this endpoint.
|
|
18750
|
+
*/
|
|
18751
|
+
GraphQLClient.prototype.setEndpoint = function (value) {
|
|
18752
|
+
this.url = value;
|
|
18753
|
+
return this;
|
|
18754
|
+
};
|
|
18755
|
+
return GraphQLClient;
|
|
18756
|
+
}());
|
|
18757
|
+
exports.GraphQLClient = GraphQLClient;
|
|
18758
|
+
function makeRequest(_a) {
|
|
18759
|
+
var url = _a.url, query = _a.query, variables = _a.variables, headers = _a.headers, operationName = _a.operationName, fetch = _a.fetch, _b = _a.method, method = _b === void 0 ? 'POST' : _b, fetchOptions = _a.fetchOptions;
|
|
18760
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18761
|
+
var fetcher, isBathchingQuery, response, result, successfullyReceivedData, successfullyPassedErrorPolicy, headers_1, status_1, rest, data, errorResult;
|
|
18762
|
+
return __generator(this, function (_c) {
|
|
18763
|
+
switch (_c.label) {
|
|
18764
|
+
case 0:
|
|
18765
|
+
fetcher = method.toUpperCase() === 'POST' ? post : get;
|
|
18766
|
+
isBathchingQuery = Array.isArray(query);
|
|
18767
|
+
return [4 /*yield*/, fetcher({
|
|
18768
|
+
url: url,
|
|
18769
|
+
query: query,
|
|
18770
|
+
variables: variables,
|
|
18771
|
+
operationName: operationName,
|
|
18772
|
+
headers: headers,
|
|
18773
|
+
fetch: fetch,
|
|
18774
|
+
fetchOptions: fetchOptions,
|
|
18775
|
+
})];
|
|
18776
|
+
case 1:
|
|
18777
|
+
response = _c.sent();
|
|
18778
|
+
return [4 /*yield*/, getResult(response, fetchOptions.jsonSerializer)];
|
|
18779
|
+
case 2:
|
|
18780
|
+
result = _c.sent();
|
|
18781
|
+
successfullyReceivedData = isBathchingQuery && Array.isArray(result) ? !result.some(function (_a) {
|
|
18782
|
+
var data = _a.data;
|
|
18783
|
+
return !data;
|
|
18784
|
+
}) : !!result.data;
|
|
18785
|
+
successfullyPassedErrorPolicy = !result.errors || fetchOptions.errorPolicy === 'all' || fetchOptions.errorPolicy === 'ignore';
|
|
18786
|
+
if (response.ok && successfullyPassedErrorPolicy && successfullyReceivedData) {
|
|
18787
|
+
headers_1 = response.headers, status_1 = response.status;
|
|
18788
|
+
rest = __rest(result, ["errors"]);
|
|
18789
|
+
data = fetchOptions.errorPolicy === 'ignore' ? rest : result;
|
|
18790
|
+
return [2 /*return*/, __assign(__assign({}, (isBathchingQuery ? { data: data } : data)), { headers: headers_1, status: status_1 })];
|
|
18791
|
+
}
|
|
18792
|
+
else {
|
|
18793
|
+
errorResult = typeof result === 'string' ? { error: result } : result;
|
|
18794
|
+
throw new types.ClientError(__assign(__assign({}, errorResult), { status: response.status, headers: response.headers }), { query: query, variables: variables });
|
|
18795
|
+
}
|
|
18796
|
+
}
|
|
18797
|
+
});
|
|
15954
18798
|
});
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
}
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
this
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
18799
|
+
}
|
|
18800
|
+
function rawRequest(urlOrOptions, query, variables, requestHeaders) {
|
|
18801
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18802
|
+
var requestOptions, client;
|
|
18803
|
+
return __generator(this, function (_a) {
|
|
18804
|
+
requestOptions = parseArgs.parseRawRequestExtendedArgs(urlOrOptions, query, variables, requestHeaders);
|
|
18805
|
+
client = new GraphQLClient(requestOptions.url);
|
|
18806
|
+
return [2 /*return*/, client.rawRequest(__assign({}, requestOptions))];
|
|
18807
|
+
});
|
|
18808
|
+
});
|
|
18809
|
+
}
|
|
18810
|
+
exports.rawRequest = rawRequest;
|
|
18811
|
+
function request(urlOrOptions, document, variables, requestHeaders) {
|
|
18812
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18813
|
+
var requestOptions, client;
|
|
18814
|
+
return __generator(this, function (_a) {
|
|
18815
|
+
requestOptions = parseArgs.parseRequestExtendedArgs(urlOrOptions, document, variables, requestHeaders);
|
|
18816
|
+
client = new GraphQLClient(requestOptions.url);
|
|
18817
|
+
return [2 /*return*/, client.request(__assign({}, requestOptions))];
|
|
18818
|
+
});
|
|
18819
|
+
});
|
|
18820
|
+
}
|
|
18821
|
+
exports.request = request;
|
|
18822
|
+
function batchRequests(urlOrOptions, documents, requestHeaders) {
|
|
18823
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18824
|
+
var requestOptions, client;
|
|
18825
|
+
return __generator(this, function (_a) {
|
|
18826
|
+
requestOptions = parseArgs.parseBatchRequestsExtendedArgs(urlOrOptions, documents, requestHeaders);
|
|
18827
|
+
client = new GraphQLClient(requestOptions.url);
|
|
18828
|
+
return [2 /*return*/, client.batchRequests(__assign({}, requestOptions))];
|
|
18829
|
+
});
|
|
18830
|
+
});
|
|
18831
|
+
}
|
|
18832
|
+
exports.batchRequests = batchRequests;
|
|
18833
|
+
exports.default = request;
|
|
18834
|
+
/**
|
|
18835
|
+
* todo
|
|
18836
|
+
*/
|
|
18837
|
+
function getResult(response, jsonSerializer) {
|
|
18838
|
+
if (jsonSerializer === void 0) { jsonSerializer = defaultJsonSerializer.defaultJsonSerializer; }
|
|
18839
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18840
|
+
var contentType, _a, _b;
|
|
18841
|
+
return __generator(this, function (_c) {
|
|
18842
|
+
switch (_c.label) {
|
|
18843
|
+
case 0:
|
|
18844
|
+
response.headers.forEach(function (value, key) {
|
|
18845
|
+
if (key.toLowerCase() === 'content-type') {
|
|
18846
|
+
contentType = value;
|
|
18847
|
+
}
|
|
18848
|
+
});
|
|
18849
|
+
if (!(contentType && contentType.toLowerCase().startsWith('application/json'))) return [3 /*break*/, 2];
|
|
18850
|
+
_b = (_a = jsonSerializer).parse;
|
|
18851
|
+
return [4 /*yield*/, response.text()];
|
|
18852
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
|
|
18853
|
+
case 2: return [2 /*return*/, response.text()];
|
|
18854
|
+
}
|
|
18855
|
+
});
|
|
18856
|
+
});
|
|
18857
|
+
}
|
|
18858
|
+
/**
|
|
18859
|
+
* helpers
|
|
18860
|
+
*/
|
|
18861
|
+
function extractOperationName(document) {
|
|
18862
|
+
var _a;
|
|
18863
|
+
var operationName = undefined;
|
|
18864
|
+
var operationDefinitions = document.definitions.filter(function (definition) { return definition.kind === 'OperationDefinition'; });
|
|
18865
|
+
if (operationDefinitions.length === 1) {
|
|
18866
|
+
operationName = (_a = operationDefinitions[0].name) === null || _a === void 0 ? void 0 : _a.value;
|
|
18867
|
+
}
|
|
18868
|
+
return operationName;
|
|
18869
|
+
}
|
|
18870
|
+
function resolveRequestDocument(document) {
|
|
18871
|
+
if (typeof document === 'string') {
|
|
18872
|
+
var operationName_1 = undefined;
|
|
18873
|
+
try {
|
|
18874
|
+
var parsedDocument = parser_1.parse(document);
|
|
18875
|
+
operationName_1 = extractOperationName(parsedDocument);
|
|
18876
|
+
}
|
|
18877
|
+
catch (err) {
|
|
18878
|
+
// Failed parsing the document, the operationName will be undefined
|
|
18879
|
+
}
|
|
18880
|
+
return { query: document, operationName: operationName_1 };
|
|
15978
18881
|
}
|
|
18882
|
+
var operationName = extractOperationName(document);
|
|
18883
|
+
return { query: printer_1.print(document), operationName: operationName };
|
|
18884
|
+
}
|
|
18885
|
+
exports.resolveRequestDocument = resolveRequestDocument;
|
|
18886
|
+
function callOrIdentity(value) {
|
|
18887
|
+
return typeof value === 'function' ? value() : value;
|
|
18888
|
+
}
|
|
18889
|
+
/**
|
|
18890
|
+
* Convenience passthrough template tag to get the benefits of tooling for the gql template tag. This does not actually parse the input into a GraphQL DocumentNode like graphql-tag package does. It just returns the string with any variables given interpolated. Can save you a bit of performance and having to install another package.
|
|
18891
|
+
*
|
|
18892
|
+
* @example
|
|
18893
|
+
*
|
|
18894
|
+
* import { gql } from 'graphql-request'
|
|
18895
|
+
*
|
|
18896
|
+
* await request('https://foo.bar/graphql', gql`...`)
|
|
18897
|
+
*
|
|
18898
|
+
* @remarks
|
|
18899
|
+
*
|
|
18900
|
+
* Several tools in the Node GraphQL ecosystem are hardcoded to specially treat any template tag named "gql". For example see this prettier issue: https://github.com/prettier/prettier/issues/4360. Using this template tag has no runtime effect beyond variable interpolation.
|
|
18901
|
+
*/
|
|
18902
|
+
function gql(chunks) {
|
|
18903
|
+
var variables = [];
|
|
18904
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
18905
|
+
variables[_i - 1] = arguments[_i];
|
|
18906
|
+
}
|
|
18907
|
+
return chunks.reduce(function (accumulator, chunk, index) { return "" + accumulator + chunk + (index in variables ? variables[index] : ''); }, '');
|
|
18908
|
+
}
|
|
18909
|
+
exports.gql = gql;
|
|
18910
|
+
/**
|
|
18911
|
+
* Convert Headers instance into regular object
|
|
18912
|
+
*/
|
|
18913
|
+
function HeadersInstanceToPlainObject(headers) {
|
|
18914
|
+
var o = {};
|
|
18915
|
+
headers.forEach(function (v, k) {
|
|
18916
|
+
o[k] = v;
|
|
18917
|
+
});
|
|
18918
|
+
return o;
|
|
18919
|
+
}
|
|
15979
18920
|
|
|
15980
|
-
|
|
15981
|
-
var keys = Object.keys(data);
|
|
15982
|
-
if (keys.length !== 1) throw new Error("Expected exactly one response key, got: " + keys.join(', '));
|
|
15983
|
-
return data[keys[0]];
|
|
15984
|
-
};
|
|
15985
|
-
|
|
15986
|
-
if (!this.actionCableClient) throw new Error('No WS client available');
|
|
15987
|
-
var subscription = this.actionCableClient.request({
|
|
15988
|
-
query: query,
|
|
15989
|
-
variables: variables
|
|
15990
|
-
}).subscribe({
|
|
15991
|
-
next: function next(_ref) {
|
|
15992
|
-
var data = _ref.data,
|
|
15993
|
-
errors = _ref.errors;
|
|
15994
|
-
|
|
15995
|
-
if (errors) {
|
|
15996
|
-
return onError(new Error(JSON.stringify(errors)));
|
|
15997
|
-
}
|
|
18921
|
+
Object.defineProperty(exports, "GraphQLWebSocketClient", { enumerable: true, get: function () { return graphqlWs.GraphQLWebSocketClient; } });
|
|
15998
18922
|
|
|
15999
|
-
|
|
16000
|
-
}
|
|
16001
|
-
});
|
|
16002
|
-
return function () {
|
|
16003
|
-
return subscription.unsubscribe();
|
|
16004
|
-
};
|
|
16005
|
-
};
|
|
18923
|
+
});
|
|
16006
18924
|
|
|
16007
|
-
|
|
16008
|
-
|
|
18925
|
+
unwrapExports(dist);
|
|
18926
|
+
var dist_7 = dist.GraphQLClient;
|
|
16009
18927
|
|
|
16010
|
-
var
|
|
16011
|
-
|
|
18928
|
+
var getGraphqlSdk = function getGraphqlSdk(url, token) {
|
|
18929
|
+
var graphqlClient = new dist_7(url);
|
|
18930
|
+
graphqlClient.setHeader('Authorization', "Bearer " + token);
|
|
18931
|
+
return getSdk(graphqlClient);
|
|
16012
18932
|
};
|
|
16013
18933
|
|
|
16014
18934
|
var moment = createCommonjsModule(function (module, exports) {
|
|
@@ -18459,7 +21379,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
18459
21379
|
function preprocessRFC2822(s) {
|
|
18460
21380
|
// Remove comments and folding whitespace and replace multiple-spaces with a single space
|
|
18461
21381
|
return s
|
|
18462
|
-
.replace(/\([^)]*\)|[\n\t]/g, ' ')
|
|
21382
|
+
.replace(/\([^()]*\)|[\n\t]/g, ' ')
|
|
18463
21383
|
.replace(/(\s\s+)/g, ' ')
|
|
18464
21384
|
.replace(/^\s\s*/, '')
|
|
18465
21385
|
.replace(/\s\s*$/, '');
|
|
@@ -21640,7 +24560,7 @@ var moment = createCommonjsModule(function (module, exports) {
|
|
|
21640
24560
|
|
|
21641
24561
|
//! moment.js
|
|
21642
24562
|
|
|
21643
|
-
hooks.version = '2.29.
|
|
24563
|
+
hooks.version = '2.29.4';
|
|
21644
24564
|
|
|
21645
24565
|
setHookCallback(createLocal);
|
|
21646
24566
|
|
|
@@ -21743,6 +24663,7 @@ var getRecentShift = function getRecentShift(date, shifts) {
|
|
|
21743
24663
|
};
|
|
21744
24664
|
|
|
21745
24665
|
exports.CompanyConfigDocument = CompanyConfigDocument;
|
|
24666
|
+
exports.ConfirmTooltip = ConfirmTooltip;
|
|
21746
24667
|
exports.CounterDirectoriesDocument = CounterDirectoriesDocument;
|
|
21747
24668
|
exports.CountersDocument = CountersDocument;
|
|
21748
24669
|
exports.CreateDashboardDocument = CreateDashboardDocument;
|
|
@@ -21778,12 +24699,13 @@ exports.UpdateOrderExecutionDocument = UpdateOrderExecutionDocument;
|
|
|
21778
24699
|
exports.UpdateWidgetDocument = UpdateWidgetDocument;
|
|
21779
24700
|
exports.UsersDocument = UsersDocument;
|
|
21780
24701
|
exports.UsersPresencesDocument = UsersPresencesDocument;
|
|
24702
|
+
exports.WidgetCard = WidgetCard;
|
|
21781
24703
|
exports.WidgetDocument = WidgetDocument;
|
|
21782
|
-
exports.WidgetSettingsButton = WidgetSettingsButton;
|
|
21783
24704
|
exports.WorkplaceEventDocument = WorkplaceEventDocument;
|
|
21784
24705
|
exports.WorkplacesDocument = WorkplacesDocument;
|
|
21785
24706
|
exports.getCurrentShift = getCurrentShift;
|
|
21786
24707
|
exports.getGqlWsClient = getGqlWsClient;
|
|
24708
|
+
exports.getGraphqlSdk = getGraphqlSdk;
|
|
21787
24709
|
exports.getRecentShift = getRecentShift;
|
|
21788
24710
|
exports.getSdk = getSdk;
|
|
21789
24711
|
exports.normalizeShifts = normalizeShifts;
|
|
@@ -23014,6 +25936,7 @@ var GRAPHQL_API_URL = process.env.REACT_APP_WIDGET_GRAPHQL_API_URL;
|
|
|
23014
25936
|
var Dashboard = function Dashboard(_ref) {
|
|
23015
25937
|
var lang = _ref.lang,
|
|
23016
25938
|
widgetName = _ref.widgetName,
|
|
25939
|
+
widgetDisplayName = _ref.widgetDisplayName,
|
|
23017
25940
|
widgetWidth = _ref.widgetWidth,
|
|
23018
25941
|
widgetHeight = _ref.widgetHeight,
|
|
23019
25942
|
Widget = _ref.Widget,
|
|
@@ -23033,18 +25956,14 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
23033
25956
|
i: widgetId,
|
|
23034
25957
|
x: 0,
|
|
23035
25958
|
y: 0,
|
|
23036
|
-
w: widgetWidth ||
|
|
23037
|
-
h: widgetHeight ||
|
|
23038
|
-
}]
|
|
23039
|
-
|
|
23040
|
-
|
|
23041
|
-
|
|
23042
|
-
|
|
23043
|
-
|
|
23044
|
-
return !current;
|
|
23045
|
-
});
|
|
23046
|
-
}
|
|
23047
|
-
}), React__default["default"].createElement(Widget, {
|
|
25959
|
+
w: widgetWidth || 3,
|
|
25960
|
+
h: widgetHeight || 4
|
|
25961
|
+
}],
|
|
25962
|
+
draggableHandle: ".draggable-handle"
|
|
25963
|
+
}, (authResponse == null ? void 0 : authResponse.accessToken) && React__default["default"].createElement(dist_1.WidgetCard, {
|
|
25964
|
+
key: widgetId,
|
|
25965
|
+
Widget: Widget,
|
|
25966
|
+
title: widgetDisplayName(lang),
|
|
23048
25967
|
id: widgetId,
|
|
23049
25968
|
url: GRAPHQL_API_URL,
|
|
23050
25969
|
token: authResponse.accessToken,
|
|
@@ -23057,7 +25976,7 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
23057
25976
|
return setSettingsModalOpened(false);
|
|
23058
25977
|
},
|
|
23059
25978
|
editMode: editMode
|
|
23060
|
-
}))
|
|
25979
|
+
}));
|
|
23061
25980
|
};
|
|
23062
25981
|
|
|
23063
25982
|
var routes = function routes(isLoggedIn, _ref) {
|
|
@@ -23136,12 +26055,9 @@ var WidgetPreview = function WidgetPreview(_ref) {
|
|
|
23136
26055
|
clientId: 'sample-app-client-id',
|
|
23137
26056
|
grantType: 'password'
|
|
23138
26057
|
};
|
|
23139
|
-
var containerStyles = {
|
|
23140
|
-
height: '100vh'
|
|
23141
|
-
};
|
|
23142
26058
|
var headerProps = {
|
|
23143
26059
|
position: 'static',
|
|
23144
|
-
leadingText: widgetDisplayName,
|
|
26060
|
+
leadingText: widgetDisplayName(lang),
|
|
23145
26061
|
menuProps: {
|
|
23146
26062
|
items: menuItems,
|
|
23147
26063
|
buttonColor: 'white'
|
|
@@ -23151,8 +26067,7 @@ var WidgetPreview = function WidgetPreview(_ref) {
|
|
|
23151
26067
|
baseUrl: OAUTH2_BASE_URL,
|
|
23152
26068
|
authProps: authProps
|
|
23153
26069
|
}, React__default["default"].createElement(andoncloudSdk.Container, {
|
|
23154
|
-
headerProps: headerProps
|
|
23155
|
-
styles: containerStyles
|
|
26070
|
+
headerProps: headerProps
|
|
23156
26071
|
}, React__default["default"].createElement(Routing, {
|
|
23157
26072
|
lang: lang,
|
|
23158
26073
|
widgetName: widgetName,
|