andoncloud-dashboard-toolkit 1.2.15 → 1.2.16
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/index.js +37 -2344
- package/dist/index.js.map +1 -1
- package/dist/locales/index.d.ts +17 -0
- package/package.json +16 -8
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var reactDom = require('react-dom');
|
|
|
8
8
|
var reactIs = _interopDefault(require('react-is'));
|
|
9
9
|
var reactI18next = require('react-i18next');
|
|
10
10
|
var iconsMaterial = require('@mui/icons-material');
|
|
11
|
+
var graphqlRequest = require('graphql-request');
|
|
11
12
|
var andoncloudSdk = require('andoncloud-sdk');
|
|
12
13
|
|
|
13
14
|
function _extends() {
|
|
@@ -4702,10 +4703,6 @@ function createCommonjsModule(fn, module) {
|
|
|
4702
4703
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
4703
4704
|
}
|
|
4704
4705
|
|
|
4705
|
-
function getCjsExportFromNamespace (n) {
|
|
4706
|
-
return n && n['default'] || n;
|
|
4707
|
-
}
|
|
4708
|
-
|
|
4709
4706
|
function commonjsRequire () {
|
|
4710
4707
|
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
4711
4708
|
}
|
|
@@ -7715,6 +7712,31 @@ var SortableSelect = function SortableSelect(_ref) {
|
|
|
7715
7712
|
});
|
|
7716
7713
|
};
|
|
7717
7714
|
|
|
7715
|
+
var Cancel = "Cancel";
|
|
7716
|
+
var Delete = "Delete";
|
|
7717
|
+
var en = {
|
|
7718
|
+
"Are you sure you want to delete this widget?": "Are you sure you want to delete this widget?",
|
|
7719
|
+
Cancel: Cancel,
|
|
7720
|
+
Delete: Delete
|
|
7721
|
+
};
|
|
7722
|
+
|
|
7723
|
+
var Cancel$1 = "Anuluj";
|
|
7724
|
+
var Delete$1 = "Usuń";
|
|
7725
|
+
var pl = {
|
|
7726
|
+
"Are you sure you want to delete this widget?": "Czy na pewno chcesz usunąć ten widżet?",
|
|
7727
|
+
Cancel: Cancel$1,
|
|
7728
|
+
Delete: Delete$1
|
|
7729
|
+
};
|
|
7730
|
+
|
|
7731
|
+
var resources = {
|
|
7732
|
+
en: {
|
|
7733
|
+
translation: en
|
|
7734
|
+
},
|
|
7735
|
+
pl: {
|
|
7736
|
+
translation: pl
|
|
7737
|
+
}
|
|
7738
|
+
};
|
|
7739
|
+
|
|
7718
7740
|
var _path;
|
|
7719
7741
|
function _extends$2() {
|
|
7720
7742
|
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -7849,7 +7871,17 @@ var WidgetCard = React__default.forwardRef(function (_ref, ref) {
|
|
|
7849
7871
|
removeTooltipOpened = _useState2[0],
|
|
7850
7872
|
setRemoveTooltipOpened = _useState2[1];
|
|
7851
7873
|
var _useTranslation = reactI18next.useTranslation(),
|
|
7874
|
+
i18n = _useTranslation.i18n,
|
|
7852
7875
|
t = _useTranslation.t;
|
|
7876
|
+
React.useEffect(function () {
|
|
7877
|
+
var ns = 'translation';
|
|
7878
|
+
for (var _i = 0, _Object$entries = Object.entries(resources); _i < _Object$entries.length; _i++) {
|
|
7879
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
7880
|
+
_lang = _Object$entries$_i[0],
|
|
7881
|
+
trans = _Object$entries$_i[1];
|
|
7882
|
+
i18n.addResources(_lang, ns, trans[ns]);
|
|
7883
|
+
}
|
|
7884
|
+
}, [i18n]);
|
|
7853
7885
|
var handleOpenSettingsModal = function handleOpenSettingsModal() {
|
|
7854
7886
|
if (onSettingsModalOpened) onSettingsModalOpened();
|
|
7855
7887
|
};
|
|
@@ -8492,13 +8524,6 @@ var Token = /*#__PURE__*/function () {
|
|
|
8492
8524
|
}(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
|
|
8493
8525
|
|
|
8494
8526
|
defineInspect(Token);
|
|
8495
|
-
/**
|
|
8496
|
-
* @internal
|
|
8497
|
-
*/
|
|
8498
|
-
|
|
8499
|
-
function isNode$1(maybeNode) {
|
|
8500
|
-
return maybeNode != null && typeof maybeNode.kind === 'string';
|
|
8501
|
-
}
|
|
8502
8527
|
/**
|
|
8503
8528
|
* The list of all possible AST node types.
|
|
8504
8529
|
*/
|
|
@@ -8870,36 +8895,6 @@ function getBlockStringIndentation(value) {
|
|
|
8870
8895
|
|
|
8871
8896
|
return (_commonIndent = commonIndent) !== null && _commonIndent !== void 0 ? _commonIndent : 0;
|
|
8872
8897
|
}
|
|
8873
|
-
/**
|
|
8874
|
-
* Print a block string in the indented block form by adding a leading and
|
|
8875
|
-
* trailing blank line. However, if a block string starts with whitespace and is
|
|
8876
|
-
* a single-line, adding a leading blank line would strip that whitespace.
|
|
8877
|
-
*
|
|
8878
|
-
* @internal
|
|
8879
|
-
*/
|
|
8880
|
-
|
|
8881
|
-
function printBlockString(value) {
|
|
8882
|
-
var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
8883
|
-
var preferMultipleLines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
8884
|
-
var isSingleLine = value.indexOf('\n') === -1;
|
|
8885
|
-
var hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
|
|
8886
|
-
var hasTrailingQuote = value[value.length - 1] === '"';
|
|
8887
|
-
var hasTrailingSlash = value[value.length - 1] === '\\';
|
|
8888
|
-
var printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;
|
|
8889
|
-
var result = ''; // Format a multi-line block quote to account for leading space.
|
|
8890
|
-
|
|
8891
|
-
if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {
|
|
8892
|
-
result += '\n' + indentation;
|
|
8893
|
-
}
|
|
8894
|
-
|
|
8895
|
-
result += indentation ? value.replace(/\n/g, '\n' + indentation) : value;
|
|
8896
|
-
|
|
8897
|
-
if (printAsMultipleLines) {
|
|
8898
|
-
result += '\n';
|
|
8899
|
-
}
|
|
8900
|
-
|
|
8901
|
-
return '"""' + result.replace(/"""/g, '\\"""') + '"""';
|
|
8902
|
-
}
|
|
8903
8898
|
|
|
8904
8899
|
/**
|
|
8905
8900
|
* Given a Source object, creates a Lexer for that source.
|
|
@@ -9586,42 +9581,6 @@ function parse(source, options) {
|
|
|
9586
9581
|
var parser = new Parser(source, options);
|
|
9587
9582
|
return parser.parseDocument();
|
|
9588
9583
|
}
|
|
9589
|
-
/**
|
|
9590
|
-
* Given a string containing a GraphQL value (ex. `[42]`), parse the AST for
|
|
9591
|
-
* that value.
|
|
9592
|
-
* Throws GraphQLError if a syntax error is encountered.
|
|
9593
|
-
*
|
|
9594
|
-
* This is useful within tools that operate upon GraphQL Values directly and
|
|
9595
|
-
* in isolation of complete GraphQL documents.
|
|
9596
|
-
*
|
|
9597
|
-
* Consider providing the results to the utility function: valueFromAST().
|
|
9598
|
-
*/
|
|
9599
|
-
|
|
9600
|
-
function parseValue(source, options) {
|
|
9601
|
-
var parser = new Parser(source, options);
|
|
9602
|
-
parser.expectToken(TokenKind.SOF);
|
|
9603
|
-
var value = parser.parseValueLiteral(false);
|
|
9604
|
-
parser.expectToken(TokenKind.EOF);
|
|
9605
|
-
return value;
|
|
9606
|
-
}
|
|
9607
|
-
/**
|
|
9608
|
-
* Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
|
|
9609
|
-
* that type.
|
|
9610
|
-
* Throws GraphQLError if a syntax error is encountered.
|
|
9611
|
-
*
|
|
9612
|
-
* This is useful within tools that operate upon GraphQL Types directly and
|
|
9613
|
-
* in isolation of complete GraphQL documents.
|
|
9614
|
-
*
|
|
9615
|
-
* Consider providing the results to the utility function: typeFromAST().
|
|
9616
|
-
*/
|
|
9617
|
-
|
|
9618
|
-
function parseType(source, options) {
|
|
9619
|
-
var parser = new Parser(source, options);
|
|
9620
|
-
parser.expectToken(TokenKind.SOF);
|
|
9621
|
-
var type = parser.parseTypeReference();
|
|
9622
|
-
parser.expectToken(TokenKind.EOF);
|
|
9623
|
-
return type;
|
|
9624
|
-
}
|
|
9625
9584
|
/**
|
|
9626
9585
|
* This class is exported only to assist people in implementing their own parsers
|
|
9627
9586
|
* without duplicating too much code and should be used only as last resort for cases
|
|
@@ -11115,659 +11074,6 @@ function getTokenKindDesc(kind) {
|
|
|
11115
11074
|
return isPunctuatorTokenKind(kind) ? "\"".concat(kind, "\"") : kind;
|
|
11116
11075
|
}
|
|
11117
11076
|
|
|
11118
|
-
var parser = {
|
|
11119
|
-
__proto__: null,
|
|
11120
|
-
parse: parse,
|
|
11121
|
-
parseValue: parseValue,
|
|
11122
|
-
parseType: parseType,
|
|
11123
|
-
Parser: Parser
|
|
11124
|
-
};
|
|
11125
|
-
|
|
11126
|
-
/**
|
|
11127
|
-
* A visitor is provided to visit, it contains the collection of
|
|
11128
|
-
* relevant functions to be called during the visitor's traversal.
|
|
11129
|
-
*/
|
|
11130
|
-
|
|
11131
|
-
var QueryDocumentKeys = {
|
|
11132
|
-
Name: [],
|
|
11133
|
-
Document: ['definitions'],
|
|
11134
|
-
OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],
|
|
11135
|
-
VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],
|
|
11136
|
-
Variable: ['name'],
|
|
11137
|
-
SelectionSet: ['selections'],
|
|
11138
|
-
Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
|
|
11139
|
-
Argument: ['name', 'value'],
|
|
11140
|
-
FragmentSpread: ['name', 'directives'],
|
|
11141
|
-
InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
|
|
11142
|
-
FragmentDefinition: ['name', // Note: fragment variable definitions are experimental and may be changed
|
|
11143
|
-
// or removed in the future.
|
|
11144
|
-
'variableDefinitions', 'typeCondition', 'directives', 'selectionSet'],
|
|
11145
|
-
IntValue: [],
|
|
11146
|
-
FloatValue: [],
|
|
11147
|
-
StringValue: [],
|
|
11148
|
-
BooleanValue: [],
|
|
11149
|
-
NullValue: [],
|
|
11150
|
-
EnumValue: [],
|
|
11151
|
-
ListValue: ['values'],
|
|
11152
|
-
ObjectValue: ['fields'],
|
|
11153
|
-
ObjectField: ['name', 'value'],
|
|
11154
|
-
Directive: ['name', 'arguments'],
|
|
11155
|
-
NamedType: ['name'],
|
|
11156
|
-
ListType: ['type'],
|
|
11157
|
-
NonNullType: ['type'],
|
|
11158
|
-
SchemaDefinition: ['description', 'directives', 'operationTypes'],
|
|
11159
|
-
OperationTypeDefinition: ['type'],
|
|
11160
|
-
ScalarTypeDefinition: ['description', 'name', 'directives'],
|
|
11161
|
-
ObjectTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],
|
|
11162
|
-
FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],
|
|
11163
|
-
InputValueDefinition: ['description', 'name', 'type', 'defaultValue', 'directives'],
|
|
11164
|
-
InterfaceTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],
|
|
11165
|
-
UnionTypeDefinition: ['description', 'name', 'directives', 'types'],
|
|
11166
|
-
EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
|
|
11167
|
-
EnumValueDefinition: ['description', 'name', 'directives'],
|
|
11168
|
-
InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
|
|
11169
|
-
DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
|
|
11170
|
-
SchemaExtension: ['directives', 'operationTypes'],
|
|
11171
|
-
ScalarTypeExtension: ['name', 'directives'],
|
|
11172
|
-
ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
|
|
11173
|
-
InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
|
|
11174
|
-
UnionTypeExtension: ['name', 'directives', 'types'],
|
|
11175
|
-
EnumTypeExtension: ['name', 'directives', 'values'],
|
|
11176
|
-
InputObjectTypeExtension: ['name', 'directives', 'fields']
|
|
11177
|
-
};
|
|
11178
|
-
var BREAK = Object.freeze({});
|
|
11179
|
-
/**
|
|
11180
|
-
* visit() will walk through an AST using a depth-first traversal, calling
|
|
11181
|
-
* the visitor's enter function at each node in the traversal, and calling the
|
|
11182
|
-
* leave function after visiting that node and all of its child nodes.
|
|
11183
|
-
*
|
|
11184
|
-
* By returning different values from the enter and leave functions, the
|
|
11185
|
-
* behavior of the visitor can be altered, including skipping over a sub-tree of
|
|
11186
|
-
* the AST (by returning false), editing the AST by returning a value or null
|
|
11187
|
-
* to remove the value, or to stop the whole traversal by returning BREAK.
|
|
11188
|
-
*
|
|
11189
|
-
* When using visit() to edit an AST, the original AST will not be modified, and
|
|
11190
|
-
* a new version of the AST with the changes applied will be returned from the
|
|
11191
|
-
* visit function.
|
|
11192
|
-
*
|
|
11193
|
-
* const editedAST = visit(ast, {
|
|
11194
|
-
* enter(node, key, parent, path, ancestors) {
|
|
11195
|
-
* // @return
|
|
11196
|
-
* // undefined: no action
|
|
11197
|
-
* // false: skip visiting this node
|
|
11198
|
-
* // visitor.BREAK: stop visiting altogether
|
|
11199
|
-
* // null: delete this node
|
|
11200
|
-
* // any value: replace this node with the returned value
|
|
11201
|
-
* },
|
|
11202
|
-
* leave(node, key, parent, path, ancestors) {
|
|
11203
|
-
* // @return
|
|
11204
|
-
* // undefined: no action
|
|
11205
|
-
* // false: no action
|
|
11206
|
-
* // visitor.BREAK: stop visiting altogether
|
|
11207
|
-
* // null: delete this node
|
|
11208
|
-
* // any value: replace this node with the returned value
|
|
11209
|
-
* }
|
|
11210
|
-
* });
|
|
11211
|
-
*
|
|
11212
|
-
* Alternatively to providing enter() and leave() functions, a visitor can
|
|
11213
|
-
* instead provide functions named the same as the kinds of AST nodes, or
|
|
11214
|
-
* enter/leave visitors at a named key, leading to four permutations of the
|
|
11215
|
-
* visitor API:
|
|
11216
|
-
*
|
|
11217
|
-
* 1) Named visitors triggered when entering a node of a specific kind.
|
|
11218
|
-
*
|
|
11219
|
-
* visit(ast, {
|
|
11220
|
-
* Kind(node) {
|
|
11221
|
-
* // enter the "Kind" node
|
|
11222
|
-
* }
|
|
11223
|
-
* })
|
|
11224
|
-
*
|
|
11225
|
-
* 2) Named visitors that trigger upon entering and leaving a node of
|
|
11226
|
-
* a specific kind.
|
|
11227
|
-
*
|
|
11228
|
-
* visit(ast, {
|
|
11229
|
-
* Kind: {
|
|
11230
|
-
* enter(node) {
|
|
11231
|
-
* // enter the "Kind" node
|
|
11232
|
-
* }
|
|
11233
|
-
* leave(node) {
|
|
11234
|
-
* // leave the "Kind" node
|
|
11235
|
-
* }
|
|
11236
|
-
* }
|
|
11237
|
-
* })
|
|
11238
|
-
*
|
|
11239
|
-
* 3) Generic visitors that trigger upon entering and leaving any node.
|
|
11240
|
-
*
|
|
11241
|
-
* visit(ast, {
|
|
11242
|
-
* enter(node) {
|
|
11243
|
-
* // enter any node
|
|
11244
|
-
* },
|
|
11245
|
-
* leave(node) {
|
|
11246
|
-
* // leave any node
|
|
11247
|
-
* }
|
|
11248
|
-
* })
|
|
11249
|
-
*
|
|
11250
|
-
* 4) Parallel visitors for entering and leaving nodes of a specific kind.
|
|
11251
|
-
*
|
|
11252
|
-
* visit(ast, {
|
|
11253
|
-
* enter: {
|
|
11254
|
-
* Kind(node) {
|
|
11255
|
-
* // enter the "Kind" node
|
|
11256
|
-
* }
|
|
11257
|
-
* },
|
|
11258
|
-
* leave: {
|
|
11259
|
-
* Kind(node) {
|
|
11260
|
-
* // leave the "Kind" node
|
|
11261
|
-
* }
|
|
11262
|
-
* }
|
|
11263
|
-
* })
|
|
11264
|
-
*/
|
|
11265
|
-
|
|
11266
|
-
function visit(root, visitor) {
|
|
11267
|
-
var visitorKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QueryDocumentKeys;
|
|
11268
|
-
|
|
11269
|
-
/* eslint-disable no-undef-init */
|
|
11270
|
-
var stack = undefined;
|
|
11271
|
-
var inArray = Array.isArray(root);
|
|
11272
|
-
var keys = [root];
|
|
11273
|
-
var index = -1;
|
|
11274
|
-
var edits = [];
|
|
11275
|
-
var node = undefined;
|
|
11276
|
-
var key = undefined;
|
|
11277
|
-
var parent = undefined;
|
|
11278
|
-
var path = [];
|
|
11279
|
-
var ancestors = [];
|
|
11280
|
-
var newRoot = root;
|
|
11281
|
-
/* eslint-enable no-undef-init */
|
|
11282
|
-
|
|
11283
|
-
do {
|
|
11284
|
-
index++;
|
|
11285
|
-
var isLeaving = index === keys.length;
|
|
11286
|
-
var isEdited = isLeaving && edits.length !== 0;
|
|
11287
|
-
|
|
11288
|
-
if (isLeaving) {
|
|
11289
|
-
key = ancestors.length === 0 ? undefined : path[path.length - 1];
|
|
11290
|
-
node = parent;
|
|
11291
|
-
parent = ancestors.pop();
|
|
11292
|
-
|
|
11293
|
-
if (isEdited) {
|
|
11294
|
-
if (inArray) {
|
|
11295
|
-
node = node.slice();
|
|
11296
|
-
} else {
|
|
11297
|
-
var clone = {};
|
|
11298
|
-
|
|
11299
|
-
for (var _i2 = 0, _Object$keys2 = Object.keys(node); _i2 < _Object$keys2.length; _i2++) {
|
|
11300
|
-
var k = _Object$keys2[_i2];
|
|
11301
|
-
clone[k] = node[k];
|
|
11302
|
-
}
|
|
11303
|
-
|
|
11304
|
-
node = clone;
|
|
11305
|
-
}
|
|
11306
|
-
|
|
11307
|
-
var editOffset = 0;
|
|
11308
|
-
|
|
11309
|
-
for (var ii = 0; ii < edits.length; ii++) {
|
|
11310
|
-
var editKey = edits[ii][0];
|
|
11311
|
-
var editValue = edits[ii][1];
|
|
11312
|
-
|
|
11313
|
-
if (inArray) {
|
|
11314
|
-
editKey -= editOffset;
|
|
11315
|
-
}
|
|
11316
|
-
|
|
11317
|
-
if (inArray && editValue === null) {
|
|
11318
|
-
node.splice(editKey, 1);
|
|
11319
|
-
editOffset++;
|
|
11320
|
-
} else {
|
|
11321
|
-
node[editKey] = editValue;
|
|
11322
|
-
}
|
|
11323
|
-
}
|
|
11324
|
-
}
|
|
11325
|
-
|
|
11326
|
-
index = stack.index;
|
|
11327
|
-
keys = stack.keys;
|
|
11328
|
-
edits = stack.edits;
|
|
11329
|
-
inArray = stack.inArray;
|
|
11330
|
-
stack = stack.prev;
|
|
11331
|
-
} else {
|
|
11332
|
-
key = parent ? inArray ? index : keys[index] : undefined;
|
|
11333
|
-
node = parent ? parent[key] : newRoot;
|
|
11334
|
-
|
|
11335
|
-
if (node === null || node === undefined) {
|
|
11336
|
-
continue;
|
|
11337
|
-
}
|
|
11338
|
-
|
|
11339
|
-
if (parent) {
|
|
11340
|
-
path.push(key);
|
|
11341
|
-
}
|
|
11342
|
-
}
|
|
11343
|
-
|
|
11344
|
-
var result = void 0;
|
|
11345
|
-
|
|
11346
|
-
if (!Array.isArray(node)) {
|
|
11347
|
-
if (!isNode$1(node)) {
|
|
11348
|
-
throw new Error("Invalid AST Node: ".concat(inspect(node), "."));
|
|
11349
|
-
}
|
|
11350
|
-
|
|
11351
|
-
var visitFn = getVisitFn(visitor, node.kind, isLeaving);
|
|
11352
|
-
|
|
11353
|
-
if (visitFn) {
|
|
11354
|
-
result = visitFn.call(visitor, node, key, parent, path, ancestors);
|
|
11355
|
-
|
|
11356
|
-
if (result === BREAK) {
|
|
11357
|
-
break;
|
|
11358
|
-
}
|
|
11359
|
-
|
|
11360
|
-
if (result === false) {
|
|
11361
|
-
if (!isLeaving) {
|
|
11362
|
-
path.pop();
|
|
11363
|
-
continue;
|
|
11364
|
-
}
|
|
11365
|
-
} else if (result !== undefined) {
|
|
11366
|
-
edits.push([key, result]);
|
|
11367
|
-
|
|
11368
|
-
if (!isLeaving) {
|
|
11369
|
-
if (isNode$1(result)) {
|
|
11370
|
-
node = result;
|
|
11371
|
-
} else {
|
|
11372
|
-
path.pop();
|
|
11373
|
-
continue;
|
|
11374
|
-
}
|
|
11375
|
-
}
|
|
11376
|
-
}
|
|
11377
|
-
}
|
|
11378
|
-
}
|
|
11379
|
-
|
|
11380
|
-
if (result === undefined && isEdited) {
|
|
11381
|
-
edits.push([key, node]);
|
|
11382
|
-
}
|
|
11383
|
-
|
|
11384
|
-
if (isLeaving) {
|
|
11385
|
-
path.pop();
|
|
11386
|
-
} else {
|
|
11387
|
-
var _visitorKeys$node$kin;
|
|
11388
|
-
|
|
11389
|
-
stack = {
|
|
11390
|
-
inArray: inArray,
|
|
11391
|
-
index: index,
|
|
11392
|
-
keys: keys,
|
|
11393
|
-
edits: edits,
|
|
11394
|
-
prev: stack
|
|
11395
|
-
};
|
|
11396
|
-
inArray = Array.isArray(node);
|
|
11397
|
-
keys = inArray ? node : (_visitorKeys$node$kin = visitorKeys[node.kind]) !== null && _visitorKeys$node$kin !== void 0 ? _visitorKeys$node$kin : [];
|
|
11398
|
-
index = -1;
|
|
11399
|
-
edits = [];
|
|
11400
|
-
|
|
11401
|
-
if (parent) {
|
|
11402
|
-
ancestors.push(parent);
|
|
11403
|
-
}
|
|
11404
|
-
|
|
11405
|
-
parent = node;
|
|
11406
|
-
}
|
|
11407
|
-
} while (stack !== undefined);
|
|
11408
|
-
|
|
11409
|
-
if (edits.length !== 0) {
|
|
11410
|
-
newRoot = edits[edits.length - 1][1];
|
|
11411
|
-
}
|
|
11412
|
-
|
|
11413
|
-
return newRoot;
|
|
11414
|
-
}
|
|
11415
|
-
/**
|
|
11416
|
-
* Given a visitor instance, if it is leaving or not, and a node kind, return
|
|
11417
|
-
* the function the visitor runtime should call.
|
|
11418
|
-
*/
|
|
11419
|
-
|
|
11420
|
-
function getVisitFn(visitor, kind, isLeaving) {
|
|
11421
|
-
var kindVisitor = visitor[kind];
|
|
11422
|
-
|
|
11423
|
-
if (kindVisitor) {
|
|
11424
|
-
if (!isLeaving && typeof kindVisitor === 'function') {
|
|
11425
|
-
// { Kind() {} }
|
|
11426
|
-
return kindVisitor;
|
|
11427
|
-
}
|
|
11428
|
-
|
|
11429
|
-
var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;
|
|
11430
|
-
|
|
11431
|
-
if (typeof kindSpecificVisitor === 'function') {
|
|
11432
|
-
// { Kind: { enter() {}, leave() {} } }
|
|
11433
|
-
return kindSpecificVisitor;
|
|
11434
|
-
}
|
|
11435
|
-
} else {
|
|
11436
|
-
var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
|
|
11437
|
-
|
|
11438
|
-
if (specificVisitor) {
|
|
11439
|
-
if (typeof specificVisitor === 'function') {
|
|
11440
|
-
// { enter() {}, leave() {} }
|
|
11441
|
-
return specificVisitor;
|
|
11442
|
-
}
|
|
11443
|
-
|
|
11444
|
-
var specificKindVisitor = specificVisitor[kind];
|
|
11445
|
-
|
|
11446
|
-
if (typeof specificKindVisitor === 'function') {
|
|
11447
|
-
// { enter: { Kind() {} }, leave: { Kind() {} } }
|
|
11448
|
-
return specificKindVisitor;
|
|
11449
|
-
}
|
|
11450
|
-
}
|
|
11451
|
-
}
|
|
11452
|
-
}
|
|
11453
|
-
|
|
11454
|
-
/**
|
|
11455
|
-
* Converts an AST into a string, using one set of reasonable
|
|
11456
|
-
* formatting rules.
|
|
11457
|
-
*/
|
|
11458
|
-
|
|
11459
|
-
function print(ast) {
|
|
11460
|
-
return visit(ast, {
|
|
11461
|
-
leave: printDocASTReducer
|
|
11462
|
-
});
|
|
11463
|
-
}
|
|
11464
|
-
var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future
|
|
11465
|
-
|
|
11466
|
-
var printDocASTReducer = {
|
|
11467
|
-
Name: function Name(node) {
|
|
11468
|
-
return node.value;
|
|
11469
|
-
},
|
|
11470
|
-
Variable: function Variable(node) {
|
|
11471
|
-
return '$' + node.name;
|
|
11472
|
-
},
|
|
11473
|
-
// Document
|
|
11474
|
-
Document: function Document(node) {
|
|
11475
|
-
return join(node.definitions, '\n\n') + '\n';
|
|
11476
|
-
},
|
|
11477
|
-
OperationDefinition: function OperationDefinition(node) {
|
|
11478
|
-
var op = node.operation;
|
|
11479
|
-
var name = node.name;
|
|
11480
|
-
var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
|
|
11481
|
-
var directives = join(node.directives, ' ');
|
|
11482
|
-
var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
|
|
11483
|
-
// the query short form.
|
|
11484
|
-
|
|
11485
|
-
return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
|
|
11486
|
-
},
|
|
11487
|
-
VariableDefinition: function VariableDefinition(_ref) {
|
|
11488
|
-
var variable = _ref.variable,
|
|
11489
|
-
type = _ref.type,
|
|
11490
|
-
defaultValue = _ref.defaultValue,
|
|
11491
|
-
directives = _ref.directives;
|
|
11492
|
-
return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
|
|
11493
|
-
},
|
|
11494
|
-
SelectionSet: function SelectionSet(_ref2) {
|
|
11495
|
-
var selections = _ref2.selections;
|
|
11496
|
-
return block(selections);
|
|
11497
|
-
},
|
|
11498
|
-
Field: function Field(_ref3) {
|
|
11499
|
-
var alias = _ref3.alias,
|
|
11500
|
-
name = _ref3.name,
|
|
11501
|
-
args = _ref3.arguments,
|
|
11502
|
-
directives = _ref3.directives,
|
|
11503
|
-
selectionSet = _ref3.selectionSet;
|
|
11504
|
-
var prefix = wrap('', alias, ': ') + name;
|
|
11505
|
-
var argsLine = prefix + wrap('(', join(args, ', '), ')');
|
|
11506
|
-
|
|
11507
|
-
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
11508
|
-
argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
|
|
11509
|
-
}
|
|
11510
|
-
|
|
11511
|
-
return join([argsLine, join(directives, ' '), selectionSet], ' ');
|
|
11512
|
-
},
|
|
11513
|
-
Argument: function Argument(_ref4) {
|
|
11514
|
-
var name = _ref4.name,
|
|
11515
|
-
value = _ref4.value;
|
|
11516
|
-
return name + ': ' + value;
|
|
11517
|
-
},
|
|
11518
|
-
// Fragments
|
|
11519
|
-
FragmentSpread: function FragmentSpread(_ref5) {
|
|
11520
|
-
var name = _ref5.name,
|
|
11521
|
-
directives = _ref5.directives;
|
|
11522
|
-
return '...' + name + wrap(' ', join(directives, ' '));
|
|
11523
|
-
},
|
|
11524
|
-
InlineFragment: function InlineFragment(_ref6) {
|
|
11525
|
-
var typeCondition = _ref6.typeCondition,
|
|
11526
|
-
directives = _ref6.directives,
|
|
11527
|
-
selectionSet = _ref6.selectionSet;
|
|
11528
|
-
return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
|
|
11529
|
-
},
|
|
11530
|
-
FragmentDefinition: function FragmentDefinition(_ref7) {
|
|
11531
|
-
var name = _ref7.name,
|
|
11532
|
-
typeCondition = _ref7.typeCondition,
|
|
11533
|
-
variableDefinitions = _ref7.variableDefinitions,
|
|
11534
|
-
directives = _ref7.directives,
|
|
11535
|
-
selectionSet = _ref7.selectionSet;
|
|
11536
|
-
return (// Note: fragment variable definitions are experimental and may be changed
|
|
11537
|
-
// or removed in the future.
|
|
11538
|
-
"fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
|
|
11539
|
-
);
|
|
11540
|
-
},
|
|
11541
|
-
// Value
|
|
11542
|
-
IntValue: function IntValue(_ref8) {
|
|
11543
|
-
var value = _ref8.value;
|
|
11544
|
-
return value;
|
|
11545
|
-
},
|
|
11546
|
-
FloatValue: function FloatValue(_ref9) {
|
|
11547
|
-
var value = _ref9.value;
|
|
11548
|
-
return value;
|
|
11549
|
-
},
|
|
11550
|
-
StringValue: function StringValue(_ref10, key) {
|
|
11551
|
-
var value = _ref10.value,
|
|
11552
|
-
isBlockString = _ref10.block;
|
|
11553
|
-
return isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
|
|
11554
|
-
},
|
|
11555
|
-
BooleanValue: function BooleanValue(_ref11) {
|
|
11556
|
-
var value = _ref11.value;
|
|
11557
|
-
return value ? 'true' : 'false';
|
|
11558
|
-
},
|
|
11559
|
-
NullValue: function NullValue() {
|
|
11560
|
-
return 'null';
|
|
11561
|
-
},
|
|
11562
|
-
EnumValue: function EnumValue(_ref12) {
|
|
11563
|
-
var value = _ref12.value;
|
|
11564
|
-
return value;
|
|
11565
|
-
},
|
|
11566
|
-
ListValue: function ListValue(_ref13) {
|
|
11567
|
-
var values = _ref13.values;
|
|
11568
|
-
return '[' + join(values, ', ') + ']';
|
|
11569
|
-
},
|
|
11570
|
-
ObjectValue: function ObjectValue(_ref14) {
|
|
11571
|
-
var fields = _ref14.fields;
|
|
11572
|
-
return '{' + join(fields, ', ') + '}';
|
|
11573
|
-
},
|
|
11574
|
-
ObjectField: function ObjectField(_ref15) {
|
|
11575
|
-
var name = _ref15.name,
|
|
11576
|
-
value = _ref15.value;
|
|
11577
|
-
return name + ': ' + value;
|
|
11578
|
-
},
|
|
11579
|
-
// Directive
|
|
11580
|
-
Directive: function Directive(_ref16) {
|
|
11581
|
-
var name = _ref16.name,
|
|
11582
|
-
args = _ref16.arguments;
|
|
11583
|
-
return '@' + name + wrap('(', join(args, ', '), ')');
|
|
11584
|
-
},
|
|
11585
|
-
// Type
|
|
11586
|
-
NamedType: function NamedType(_ref17) {
|
|
11587
|
-
var name = _ref17.name;
|
|
11588
|
-
return name;
|
|
11589
|
-
},
|
|
11590
|
-
ListType: function ListType(_ref18) {
|
|
11591
|
-
var type = _ref18.type;
|
|
11592
|
-
return '[' + type + ']';
|
|
11593
|
-
},
|
|
11594
|
-
NonNullType: function NonNullType(_ref19) {
|
|
11595
|
-
var type = _ref19.type;
|
|
11596
|
-
return type + '!';
|
|
11597
|
-
},
|
|
11598
|
-
// Type System Definitions
|
|
11599
|
-
SchemaDefinition: addDescription(function (_ref20) {
|
|
11600
|
-
var directives = _ref20.directives,
|
|
11601
|
-
operationTypes = _ref20.operationTypes;
|
|
11602
|
-
return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
11603
|
-
}),
|
|
11604
|
-
OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
|
|
11605
|
-
var operation = _ref21.operation,
|
|
11606
|
-
type = _ref21.type;
|
|
11607
|
-
return operation + ': ' + type;
|
|
11608
|
-
},
|
|
11609
|
-
ScalarTypeDefinition: addDescription(function (_ref22) {
|
|
11610
|
-
var name = _ref22.name,
|
|
11611
|
-
directives = _ref22.directives;
|
|
11612
|
-
return join(['scalar', name, join(directives, ' ')], ' ');
|
|
11613
|
-
}),
|
|
11614
|
-
ObjectTypeDefinition: addDescription(function (_ref23) {
|
|
11615
|
-
var name = _ref23.name,
|
|
11616
|
-
interfaces = _ref23.interfaces,
|
|
11617
|
-
directives = _ref23.directives,
|
|
11618
|
-
fields = _ref23.fields;
|
|
11619
|
-
return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
11620
|
-
}),
|
|
11621
|
-
FieldDefinition: addDescription(function (_ref24) {
|
|
11622
|
-
var name = _ref24.name,
|
|
11623
|
-
args = _ref24.arguments,
|
|
11624
|
-
type = _ref24.type,
|
|
11625
|
-
directives = _ref24.directives;
|
|
11626
|
-
return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
|
|
11627
|
-
}),
|
|
11628
|
-
InputValueDefinition: addDescription(function (_ref25) {
|
|
11629
|
-
var name = _ref25.name,
|
|
11630
|
-
type = _ref25.type,
|
|
11631
|
-
defaultValue = _ref25.defaultValue,
|
|
11632
|
-
directives = _ref25.directives;
|
|
11633
|
-
return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
|
|
11634
|
-
}),
|
|
11635
|
-
InterfaceTypeDefinition: addDescription(function (_ref26) {
|
|
11636
|
-
var name = _ref26.name,
|
|
11637
|
-
interfaces = _ref26.interfaces,
|
|
11638
|
-
directives = _ref26.directives,
|
|
11639
|
-
fields = _ref26.fields;
|
|
11640
|
-
return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
11641
|
-
}),
|
|
11642
|
-
UnionTypeDefinition: addDescription(function (_ref27) {
|
|
11643
|
-
var name = _ref27.name,
|
|
11644
|
-
directives = _ref27.directives,
|
|
11645
|
-
types = _ref27.types;
|
|
11646
|
-
return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
|
|
11647
|
-
}),
|
|
11648
|
-
EnumTypeDefinition: addDescription(function (_ref28) {
|
|
11649
|
-
var name = _ref28.name,
|
|
11650
|
-
directives = _ref28.directives,
|
|
11651
|
-
values = _ref28.values;
|
|
11652
|
-
return join(['enum', name, join(directives, ' '), block(values)], ' ');
|
|
11653
|
-
}),
|
|
11654
|
-
EnumValueDefinition: addDescription(function (_ref29) {
|
|
11655
|
-
var name = _ref29.name,
|
|
11656
|
-
directives = _ref29.directives;
|
|
11657
|
-
return join([name, join(directives, ' ')], ' ');
|
|
11658
|
-
}),
|
|
11659
|
-
InputObjectTypeDefinition: addDescription(function (_ref30) {
|
|
11660
|
-
var name = _ref30.name,
|
|
11661
|
-
directives = _ref30.directives,
|
|
11662
|
-
fields = _ref30.fields;
|
|
11663
|
-
return join(['input', name, join(directives, ' '), block(fields)], ' ');
|
|
11664
|
-
}),
|
|
11665
|
-
DirectiveDefinition: addDescription(function (_ref31) {
|
|
11666
|
-
var name = _ref31.name,
|
|
11667
|
-
args = _ref31.arguments,
|
|
11668
|
-
repeatable = _ref31.repeatable,
|
|
11669
|
-
locations = _ref31.locations;
|
|
11670
|
-
return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ');
|
|
11671
|
-
}),
|
|
11672
|
-
SchemaExtension: function SchemaExtension(_ref32) {
|
|
11673
|
-
var directives = _ref32.directives,
|
|
11674
|
-
operationTypes = _ref32.operationTypes;
|
|
11675
|
-
return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
11676
|
-
},
|
|
11677
|
-
ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
|
|
11678
|
-
var name = _ref33.name,
|
|
11679
|
-
directives = _ref33.directives;
|
|
11680
|
-
return join(['extend scalar', name, join(directives, ' ')], ' ');
|
|
11681
|
-
},
|
|
11682
|
-
ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
|
|
11683
|
-
var name = _ref34.name,
|
|
11684
|
-
interfaces = _ref34.interfaces,
|
|
11685
|
-
directives = _ref34.directives,
|
|
11686
|
-
fields = _ref34.fields;
|
|
11687
|
-
return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
11688
|
-
},
|
|
11689
|
-
InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
|
|
11690
|
-
var name = _ref35.name,
|
|
11691
|
-
interfaces = _ref35.interfaces,
|
|
11692
|
-
directives = _ref35.directives,
|
|
11693
|
-
fields = _ref35.fields;
|
|
11694
|
-
return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
11695
|
-
},
|
|
11696
|
-
UnionTypeExtension: function UnionTypeExtension(_ref36) {
|
|
11697
|
-
var name = _ref36.name,
|
|
11698
|
-
directives = _ref36.directives,
|
|
11699
|
-
types = _ref36.types;
|
|
11700
|
-
return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
|
|
11701
|
-
},
|
|
11702
|
-
EnumTypeExtension: function EnumTypeExtension(_ref37) {
|
|
11703
|
-
var name = _ref37.name,
|
|
11704
|
-
directives = _ref37.directives,
|
|
11705
|
-
values = _ref37.values;
|
|
11706
|
-
return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
|
|
11707
|
-
},
|
|
11708
|
-
InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
|
|
11709
|
-
var name = _ref38.name,
|
|
11710
|
-
directives = _ref38.directives,
|
|
11711
|
-
fields = _ref38.fields;
|
|
11712
|
-
return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
|
|
11713
|
-
}
|
|
11714
|
-
};
|
|
11715
|
-
|
|
11716
|
-
function addDescription(cb) {
|
|
11717
|
-
return function (node) {
|
|
11718
|
-
return join([node.description, cb(node)], '\n');
|
|
11719
|
-
};
|
|
11720
|
-
}
|
|
11721
|
-
/**
|
|
11722
|
-
* Given maybeArray, print an empty string if it is null or empty, otherwise
|
|
11723
|
-
* print all items together separated by separator if provided
|
|
11724
|
-
*/
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
function join(maybeArray) {
|
|
11728
|
-
var _maybeArray$filter$jo;
|
|
11729
|
-
|
|
11730
|
-
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
11731
|
-
return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter(function (x) {
|
|
11732
|
-
return x;
|
|
11733
|
-
}).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : '';
|
|
11734
|
-
}
|
|
11735
|
-
/**
|
|
11736
|
-
* Given array, print each item on its own line, wrapped in an
|
|
11737
|
-
* indented "{ }" block.
|
|
11738
|
-
*/
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
function block(array) {
|
|
11742
|
-
return wrap('{\n', indent(join(array, '\n')), '\n}');
|
|
11743
|
-
}
|
|
11744
|
-
/**
|
|
11745
|
-
* If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
|
|
11746
|
-
*/
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
function wrap(start, maybeString) {
|
|
11750
|
-
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
11751
|
-
return maybeString != null && maybeString !== '' ? start + maybeString + end : '';
|
|
11752
|
-
}
|
|
11753
|
-
|
|
11754
|
-
function indent(str) {
|
|
11755
|
-
return wrap(' ', str.replace(/\n/g, '\n '));
|
|
11756
|
-
}
|
|
11757
|
-
|
|
11758
|
-
function isMultiline(str) {
|
|
11759
|
-
return str.indexOf('\n') !== -1;
|
|
11760
|
-
}
|
|
11761
|
-
|
|
11762
|
-
function hasMultilineItems(maybeArray) {
|
|
11763
|
-
return maybeArray != null && maybeArray.some(isMultiline);
|
|
11764
|
-
}
|
|
11765
|
-
|
|
11766
|
-
var printer = {
|
|
11767
|
-
__proto__: null,
|
|
11768
|
-
print: print
|
|
11769
|
-
};
|
|
11770
|
-
|
|
11771
11077
|
var docCache = new Map();
|
|
11772
11078
|
var fragmentSourceMap = new Map();
|
|
11773
11079
|
var printFragmentWarnings = true;
|
|
@@ -14103,1621 +13409,8 @@ var getGqlWsClient = function getGqlWsClient(url, token, lang) {
|
|
|
14103
13409
|
return new GraphqlWsClient(url, token, lang);
|
|
14104
13410
|
};
|
|
14105
13411
|
|
|
14106
|
-
var browserPonyfill = createCommonjsModule(function (module, exports) {
|
|
14107
|
-
var global = typeof self !== 'undefined' ? self : commonjsGlobal;
|
|
14108
|
-
var __self__ = (function () {
|
|
14109
|
-
function F() {
|
|
14110
|
-
this.fetch = false;
|
|
14111
|
-
this.DOMException = global.DOMException;
|
|
14112
|
-
}
|
|
14113
|
-
F.prototype = global;
|
|
14114
|
-
return new F();
|
|
14115
|
-
})();
|
|
14116
|
-
(function(self) {
|
|
14117
|
-
|
|
14118
|
-
var irrelevant = (function (exports) {
|
|
14119
|
-
|
|
14120
|
-
var support = {
|
|
14121
|
-
searchParams: 'URLSearchParams' in self,
|
|
14122
|
-
iterable: 'Symbol' in self && 'iterator' in Symbol,
|
|
14123
|
-
blob:
|
|
14124
|
-
'FileReader' in self &&
|
|
14125
|
-
'Blob' in self &&
|
|
14126
|
-
(function() {
|
|
14127
|
-
try {
|
|
14128
|
-
new Blob();
|
|
14129
|
-
return true
|
|
14130
|
-
} catch (e) {
|
|
14131
|
-
return false
|
|
14132
|
-
}
|
|
14133
|
-
})(),
|
|
14134
|
-
formData: 'FormData' in self,
|
|
14135
|
-
arrayBuffer: 'ArrayBuffer' in self
|
|
14136
|
-
};
|
|
14137
|
-
|
|
14138
|
-
function isDataView(obj) {
|
|
14139
|
-
return obj && DataView.prototype.isPrototypeOf(obj)
|
|
14140
|
-
}
|
|
14141
|
-
|
|
14142
|
-
if (support.arrayBuffer) {
|
|
14143
|
-
var viewClasses = [
|
|
14144
|
-
'[object Int8Array]',
|
|
14145
|
-
'[object Uint8Array]',
|
|
14146
|
-
'[object Uint8ClampedArray]',
|
|
14147
|
-
'[object Int16Array]',
|
|
14148
|
-
'[object Uint16Array]',
|
|
14149
|
-
'[object Int32Array]',
|
|
14150
|
-
'[object Uint32Array]',
|
|
14151
|
-
'[object Float32Array]',
|
|
14152
|
-
'[object Float64Array]'
|
|
14153
|
-
];
|
|
14154
|
-
|
|
14155
|
-
var isArrayBufferView =
|
|
14156
|
-
ArrayBuffer.isView ||
|
|
14157
|
-
function(obj) {
|
|
14158
|
-
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
|
14159
|
-
};
|
|
14160
|
-
}
|
|
14161
|
-
|
|
14162
|
-
function normalizeName(name) {
|
|
14163
|
-
if (typeof name !== 'string') {
|
|
14164
|
-
name = String(name);
|
|
14165
|
-
}
|
|
14166
|
-
if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
|
|
14167
|
-
throw new TypeError('Invalid character in header field name')
|
|
14168
|
-
}
|
|
14169
|
-
return name.toLowerCase()
|
|
14170
|
-
}
|
|
14171
|
-
|
|
14172
|
-
function normalizeValue(value) {
|
|
14173
|
-
if (typeof value !== 'string') {
|
|
14174
|
-
value = String(value);
|
|
14175
|
-
}
|
|
14176
|
-
return value
|
|
14177
|
-
}
|
|
14178
|
-
|
|
14179
|
-
// Build a destructive iterator for the value list
|
|
14180
|
-
function iteratorFor(items) {
|
|
14181
|
-
var iterator = {
|
|
14182
|
-
next: function() {
|
|
14183
|
-
var value = items.shift();
|
|
14184
|
-
return {done: value === undefined, value: value}
|
|
14185
|
-
}
|
|
14186
|
-
};
|
|
14187
|
-
|
|
14188
|
-
if (support.iterable) {
|
|
14189
|
-
iterator[Symbol.iterator] = function() {
|
|
14190
|
-
return iterator
|
|
14191
|
-
};
|
|
14192
|
-
}
|
|
14193
|
-
|
|
14194
|
-
return iterator
|
|
14195
|
-
}
|
|
14196
|
-
|
|
14197
|
-
function Headers(headers) {
|
|
14198
|
-
this.map = {};
|
|
14199
|
-
|
|
14200
|
-
if (headers instanceof Headers) {
|
|
14201
|
-
headers.forEach(function(value, name) {
|
|
14202
|
-
this.append(name, value);
|
|
14203
|
-
}, this);
|
|
14204
|
-
} else if (Array.isArray(headers)) {
|
|
14205
|
-
headers.forEach(function(header) {
|
|
14206
|
-
this.append(header[0], header[1]);
|
|
14207
|
-
}, this);
|
|
14208
|
-
} else if (headers) {
|
|
14209
|
-
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
14210
|
-
this.append(name, headers[name]);
|
|
14211
|
-
}, this);
|
|
14212
|
-
}
|
|
14213
|
-
}
|
|
14214
|
-
|
|
14215
|
-
Headers.prototype.append = function(name, value) {
|
|
14216
|
-
name = normalizeName(name);
|
|
14217
|
-
value = normalizeValue(value);
|
|
14218
|
-
var oldValue = this.map[name];
|
|
14219
|
-
this.map[name] = oldValue ? oldValue + ', ' + value : value;
|
|
14220
|
-
};
|
|
14221
|
-
|
|
14222
|
-
Headers.prototype['delete'] = function(name) {
|
|
14223
|
-
delete this.map[normalizeName(name)];
|
|
14224
|
-
};
|
|
14225
|
-
|
|
14226
|
-
Headers.prototype.get = function(name) {
|
|
14227
|
-
name = normalizeName(name);
|
|
14228
|
-
return this.has(name) ? this.map[name] : null
|
|
14229
|
-
};
|
|
14230
|
-
|
|
14231
|
-
Headers.prototype.has = function(name) {
|
|
14232
|
-
return this.map.hasOwnProperty(normalizeName(name))
|
|
14233
|
-
};
|
|
14234
|
-
|
|
14235
|
-
Headers.prototype.set = function(name, value) {
|
|
14236
|
-
this.map[normalizeName(name)] = normalizeValue(value);
|
|
14237
|
-
};
|
|
14238
|
-
|
|
14239
|
-
Headers.prototype.forEach = function(callback, thisArg) {
|
|
14240
|
-
for (var name in this.map) {
|
|
14241
|
-
if (this.map.hasOwnProperty(name)) {
|
|
14242
|
-
callback.call(thisArg, this.map[name], name, this);
|
|
14243
|
-
}
|
|
14244
|
-
}
|
|
14245
|
-
};
|
|
14246
|
-
|
|
14247
|
-
Headers.prototype.keys = function() {
|
|
14248
|
-
var items = [];
|
|
14249
|
-
this.forEach(function(value, name) {
|
|
14250
|
-
items.push(name);
|
|
14251
|
-
});
|
|
14252
|
-
return iteratorFor(items)
|
|
14253
|
-
};
|
|
14254
|
-
|
|
14255
|
-
Headers.prototype.values = function() {
|
|
14256
|
-
var items = [];
|
|
14257
|
-
this.forEach(function(value) {
|
|
14258
|
-
items.push(value);
|
|
14259
|
-
});
|
|
14260
|
-
return iteratorFor(items)
|
|
14261
|
-
};
|
|
14262
|
-
|
|
14263
|
-
Headers.prototype.entries = function() {
|
|
14264
|
-
var items = [];
|
|
14265
|
-
this.forEach(function(value, name) {
|
|
14266
|
-
items.push([name, value]);
|
|
14267
|
-
});
|
|
14268
|
-
return iteratorFor(items)
|
|
14269
|
-
};
|
|
14270
|
-
|
|
14271
|
-
if (support.iterable) {
|
|
14272
|
-
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
|
|
14273
|
-
}
|
|
14274
|
-
|
|
14275
|
-
function consumed(body) {
|
|
14276
|
-
if (body.bodyUsed) {
|
|
14277
|
-
return Promise.reject(new TypeError('Already read'))
|
|
14278
|
-
}
|
|
14279
|
-
body.bodyUsed = true;
|
|
14280
|
-
}
|
|
14281
|
-
|
|
14282
|
-
function fileReaderReady(reader) {
|
|
14283
|
-
return new Promise(function(resolve, reject) {
|
|
14284
|
-
reader.onload = function() {
|
|
14285
|
-
resolve(reader.result);
|
|
14286
|
-
};
|
|
14287
|
-
reader.onerror = function() {
|
|
14288
|
-
reject(reader.error);
|
|
14289
|
-
};
|
|
14290
|
-
})
|
|
14291
|
-
}
|
|
14292
|
-
|
|
14293
|
-
function readBlobAsArrayBuffer(blob) {
|
|
14294
|
-
var reader = new FileReader();
|
|
14295
|
-
var promise = fileReaderReady(reader);
|
|
14296
|
-
reader.readAsArrayBuffer(blob);
|
|
14297
|
-
return promise
|
|
14298
|
-
}
|
|
14299
|
-
|
|
14300
|
-
function readBlobAsText(blob) {
|
|
14301
|
-
var reader = new FileReader();
|
|
14302
|
-
var promise = fileReaderReady(reader);
|
|
14303
|
-
reader.readAsText(blob);
|
|
14304
|
-
return promise
|
|
14305
|
-
}
|
|
14306
|
-
|
|
14307
|
-
function readArrayBufferAsText(buf) {
|
|
14308
|
-
var view = new Uint8Array(buf);
|
|
14309
|
-
var chars = new Array(view.length);
|
|
14310
|
-
|
|
14311
|
-
for (var i = 0; i < view.length; i++) {
|
|
14312
|
-
chars[i] = String.fromCharCode(view[i]);
|
|
14313
|
-
}
|
|
14314
|
-
return chars.join('')
|
|
14315
|
-
}
|
|
14316
|
-
|
|
14317
|
-
function bufferClone(buf) {
|
|
14318
|
-
if (buf.slice) {
|
|
14319
|
-
return buf.slice(0)
|
|
14320
|
-
} else {
|
|
14321
|
-
var view = new Uint8Array(buf.byteLength);
|
|
14322
|
-
view.set(new Uint8Array(buf));
|
|
14323
|
-
return view.buffer
|
|
14324
|
-
}
|
|
14325
|
-
}
|
|
14326
|
-
|
|
14327
|
-
function Body() {
|
|
14328
|
-
this.bodyUsed = false;
|
|
14329
|
-
|
|
14330
|
-
this._initBody = function(body) {
|
|
14331
|
-
this._bodyInit = body;
|
|
14332
|
-
if (!body) {
|
|
14333
|
-
this._bodyText = '';
|
|
14334
|
-
} else if (typeof body === 'string') {
|
|
14335
|
-
this._bodyText = body;
|
|
14336
|
-
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
14337
|
-
this._bodyBlob = body;
|
|
14338
|
-
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
14339
|
-
this._bodyFormData = body;
|
|
14340
|
-
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
14341
|
-
this._bodyText = body.toString();
|
|
14342
|
-
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
14343
|
-
this._bodyArrayBuffer = bufferClone(body.buffer);
|
|
14344
|
-
// IE 10-11 can't handle a DataView body.
|
|
14345
|
-
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
|
14346
|
-
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
14347
|
-
this._bodyArrayBuffer = bufferClone(body);
|
|
14348
|
-
} else {
|
|
14349
|
-
this._bodyText = body = Object.prototype.toString.call(body);
|
|
14350
|
-
}
|
|
14351
|
-
|
|
14352
|
-
if (!this.headers.get('content-type')) {
|
|
14353
|
-
if (typeof body === 'string') {
|
|
14354
|
-
this.headers.set('content-type', 'text/plain;charset=UTF-8');
|
|
14355
|
-
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
14356
|
-
this.headers.set('content-type', this._bodyBlob.type);
|
|
14357
|
-
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
14358
|
-
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
|
14359
|
-
}
|
|
14360
|
-
}
|
|
14361
|
-
};
|
|
14362
|
-
|
|
14363
|
-
if (support.blob) {
|
|
14364
|
-
this.blob = function() {
|
|
14365
|
-
var rejected = consumed(this);
|
|
14366
|
-
if (rejected) {
|
|
14367
|
-
return rejected
|
|
14368
|
-
}
|
|
14369
|
-
|
|
14370
|
-
if (this._bodyBlob) {
|
|
14371
|
-
return Promise.resolve(this._bodyBlob)
|
|
14372
|
-
} else if (this._bodyArrayBuffer) {
|
|
14373
|
-
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
|
14374
|
-
} else if (this._bodyFormData) {
|
|
14375
|
-
throw new Error('could not read FormData body as blob')
|
|
14376
|
-
} else {
|
|
14377
|
-
return Promise.resolve(new Blob([this._bodyText]))
|
|
14378
|
-
}
|
|
14379
|
-
};
|
|
14380
|
-
|
|
14381
|
-
this.arrayBuffer = function() {
|
|
14382
|
-
if (this._bodyArrayBuffer) {
|
|
14383
|
-
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
|
|
14384
|
-
} else {
|
|
14385
|
-
return this.blob().then(readBlobAsArrayBuffer)
|
|
14386
|
-
}
|
|
14387
|
-
};
|
|
14388
|
-
}
|
|
14389
|
-
|
|
14390
|
-
this.text = function() {
|
|
14391
|
-
var rejected = consumed(this);
|
|
14392
|
-
if (rejected) {
|
|
14393
|
-
return rejected
|
|
14394
|
-
}
|
|
14395
|
-
|
|
14396
|
-
if (this._bodyBlob) {
|
|
14397
|
-
return readBlobAsText(this._bodyBlob)
|
|
14398
|
-
} else if (this._bodyArrayBuffer) {
|
|
14399
|
-
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
|
14400
|
-
} else if (this._bodyFormData) {
|
|
14401
|
-
throw new Error('could not read FormData body as text')
|
|
14402
|
-
} else {
|
|
14403
|
-
return Promise.resolve(this._bodyText)
|
|
14404
|
-
}
|
|
14405
|
-
};
|
|
14406
|
-
|
|
14407
|
-
if (support.formData) {
|
|
14408
|
-
this.formData = function() {
|
|
14409
|
-
return this.text().then(decode)
|
|
14410
|
-
};
|
|
14411
|
-
}
|
|
14412
|
-
|
|
14413
|
-
this.json = function() {
|
|
14414
|
-
return this.text().then(JSON.parse)
|
|
14415
|
-
};
|
|
14416
|
-
|
|
14417
|
-
return this
|
|
14418
|
-
}
|
|
14419
|
-
|
|
14420
|
-
// HTTP methods whose capitalization should be normalized
|
|
14421
|
-
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
|
|
14422
|
-
|
|
14423
|
-
function normalizeMethod(method) {
|
|
14424
|
-
var upcased = method.toUpperCase();
|
|
14425
|
-
return methods.indexOf(upcased) > -1 ? upcased : method
|
|
14426
|
-
}
|
|
14427
|
-
|
|
14428
|
-
function Request(input, options) {
|
|
14429
|
-
options = options || {};
|
|
14430
|
-
var body = options.body;
|
|
14431
|
-
|
|
14432
|
-
if (input instanceof Request) {
|
|
14433
|
-
if (input.bodyUsed) {
|
|
14434
|
-
throw new TypeError('Already read')
|
|
14435
|
-
}
|
|
14436
|
-
this.url = input.url;
|
|
14437
|
-
this.credentials = input.credentials;
|
|
14438
|
-
if (!options.headers) {
|
|
14439
|
-
this.headers = new Headers(input.headers);
|
|
14440
|
-
}
|
|
14441
|
-
this.method = input.method;
|
|
14442
|
-
this.mode = input.mode;
|
|
14443
|
-
this.signal = input.signal;
|
|
14444
|
-
if (!body && input._bodyInit != null) {
|
|
14445
|
-
body = input._bodyInit;
|
|
14446
|
-
input.bodyUsed = true;
|
|
14447
|
-
}
|
|
14448
|
-
} else {
|
|
14449
|
-
this.url = String(input);
|
|
14450
|
-
}
|
|
14451
|
-
|
|
14452
|
-
this.credentials = options.credentials || this.credentials || 'same-origin';
|
|
14453
|
-
if (options.headers || !this.headers) {
|
|
14454
|
-
this.headers = new Headers(options.headers);
|
|
14455
|
-
}
|
|
14456
|
-
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
14457
|
-
this.mode = options.mode || this.mode || null;
|
|
14458
|
-
this.signal = options.signal || this.signal;
|
|
14459
|
-
this.referrer = null;
|
|
14460
|
-
|
|
14461
|
-
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
14462
|
-
throw new TypeError('Body not allowed for GET or HEAD requests')
|
|
14463
|
-
}
|
|
14464
|
-
this._initBody(body);
|
|
14465
|
-
}
|
|
14466
|
-
|
|
14467
|
-
Request.prototype.clone = function() {
|
|
14468
|
-
return new Request(this, {body: this._bodyInit})
|
|
14469
|
-
};
|
|
14470
|
-
|
|
14471
|
-
function decode(body) {
|
|
14472
|
-
var form = new FormData();
|
|
14473
|
-
body
|
|
14474
|
-
.trim()
|
|
14475
|
-
.split('&')
|
|
14476
|
-
.forEach(function(bytes) {
|
|
14477
|
-
if (bytes) {
|
|
14478
|
-
var split = bytes.split('=');
|
|
14479
|
-
var name = split.shift().replace(/\+/g, ' ');
|
|
14480
|
-
var value = split.join('=').replace(/\+/g, ' ');
|
|
14481
|
-
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
14482
|
-
}
|
|
14483
|
-
});
|
|
14484
|
-
return form
|
|
14485
|
-
}
|
|
14486
|
-
|
|
14487
|
-
function parseHeaders(rawHeaders) {
|
|
14488
|
-
var headers = new Headers();
|
|
14489
|
-
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
|
14490
|
-
// https://tools.ietf.org/html/rfc7230#section-3.2
|
|
14491
|
-
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
|
14492
|
-
preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
|
|
14493
|
-
var parts = line.split(':');
|
|
14494
|
-
var key = parts.shift().trim();
|
|
14495
|
-
if (key) {
|
|
14496
|
-
var value = parts.join(':').trim();
|
|
14497
|
-
headers.append(key, value);
|
|
14498
|
-
}
|
|
14499
|
-
});
|
|
14500
|
-
return headers
|
|
14501
|
-
}
|
|
14502
|
-
|
|
14503
|
-
Body.call(Request.prototype);
|
|
14504
|
-
|
|
14505
|
-
function Response(bodyInit, options) {
|
|
14506
|
-
if (!options) {
|
|
14507
|
-
options = {};
|
|
14508
|
-
}
|
|
14509
|
-
|
|
14510
|
-
this.type = 'default';
|
|
14511
|
-
this.status = options.status === undefined ? 200 : options.status;
|
|
14512
|
-
this.ok = this.status >= 200 && this.status < 300;
|
|
14513
|
-
this.statusText = 'statusText' in options ? options.statusText : 'OK';
|
|
14514
|
-
this.headers = new Headers(options.headers);
|
|
14515
|
-
this.url = options.url || '';
|
|
14516
|
-
this._initBody(bodyInit);
|
|
14517
|
-
}
|
|
14518
|
-
|
|
14519
|
-
Body.call(Response.prototype);
|
|
14520
|
-
|
|
14521
|
-
Response.prototype.clone = function() {
|
|
14522
|
-
return new Response(this._bodyInit, {
|
|
14523
|
-
status: this.status,
|
|
14524
|
-
statusText: this.statusText,
|
|
14525
|
-
headers: new Headers(this.headers),
|
|
14526
|
-
url: this.url
|
|
14527
|
-
})
|
|
14528
|
-
};
|
|
14529
|
-
|
|
14530
|
-
Response.error = function() {
|
|
14531
|
-
var response = new Response(null, {status: 0, statusText: ''});
|
|
14532
|
-
response.type = 'error';
|
|
14533
|
-
return response
|
|
14534
|
-
};
|
|
14535
|
-
|
|
14536
|
-
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
14537
|
-
|
|
14538
|
-
Response.redirect = function(url, status) {
|
|
14539
|
-
if (redirectStatuses.indexOf(status) === -1) {
|
|
14540
|
-
throw new RangeError('Invalid status code')
|
|
14541
|
-
}
|
|
14542
|
-
|
|
14543
|
-
return new Response(null, {status: status, headers: {location: url}})
|
|
14544
|
-
};
|
|
14545
|
-
|
|
14546
|
-
exports.DOMException = self.DOMException;
|
|
14547
|
-
try {
|
|
14548
|
-
new exports.DOMException();
|
|
14549
|
-
} catch (err) {
|
|
14550
|
-
exports.DOMException = function(message, name) {
|
|
14551
|
-
this.message = message;
|
|
14552
|
-
this.name = name;
|
|
14553
|
-
var error = Error(message);
|
|
14554
|
-
this.stack = error.stack;
|
|
14555
|
-
};
|
|
14556
|
-
exports.DOMException.prototype = Object.create(Error.prototype);
|
|
14557
|
-
exports.DOMException.prototype.constructor = exports.DOMException;
|
|
14558
|
-
}
|
|
14559
|
-
|
|
14560
|
-
function fetch(input, init) {
|
|
14561
|
-
return new Promise(function(resolve, reject) {
|
|
14562
|
-
var request = new Request(input, init);
|
|
14563
|
-
|
|
14564
|
-
if (request.signal && request.signal.aborted) {
|
|
14565
|
-
return reject(new exports.DOMException('Aborted', 'AbortError'))
|
|
14566
|
-
}
|
|
14567
|
-
|
|
14568
|
-
var xhr = new XMLHttpRequest();
|
|
14569
|
-
|
|
14570
|
-
function abortXhr() {
|
|
14571
|
-
xhr.abort();
|
|
14572
|
-
}
|
|
14573
|
-
|
|
14574
|
-
xhr.onload = function() {
|
|
14575
|
-
var options = {
|
|
14576
|
-
status: xhr.status,
|
|
14577
|
-
statusText: xhr.statusText,
|
|
14578
|
-
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
14579
|
-
};
|
|
14580
|
-
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
14581
|
-
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
14582
|
-
resolve(new Response(body, options));
|
|
14583
|
-
};
|
|
14584
|
-
|
|
14585
|
-
xhr.onerror = function() {
|
|
14586
|
-
reject(new TypeError('Network request failed'));
|
|
14587
|
-
};
|
|
14588
|
-
|
|
14589
|
-
xhr.ontimeout = function() {
|
|
14590
|
-
reject(new TypeError('Network request failed'));
|
|
14591
|
-
};
|
|
14592
|
-
|
|
14593
|
-
xhr.onabort = function() {
|
|
14594
|
-
reject(new exports.DOMException('Aborted', 'AbortError'));
|
|
14595
|
-
};
|
|
14596
|
-
|
|
14597
|
-
xhr.open(request.method, request.url, true);
|
|
14598
|
-
|
|
14599
|
-
if (request.credentials === 'include') {
|
|
14600
|
-
xhr.withCredentials = true;
|
|
14601
|
-
} else if (request.credentials === 'omit') {
|
|
14602
|
-
xhr.withCredentials = false;
|
|
14603
|
-
}
|
|
14604
|
-
|
|
14605
|
-
if ('responseType' in xhr && support.blob) {
|
|
14606
|
-
xhr.responseType = 'blob';
|
|
14607
|
-
}
|
|
14608
|
-
|
|
14609
|
-
request.headers.forEach(function(value, name) {
|
|
14610
|
-
xhr.setRequestHeader(name, value);
|
|
14611
|
-
});
|
|
14612
|
-
|
|
14613
|
-
if (request.signal) {
|
|
14614
|
-
request.signal.addEventListener('abort', abortXhr);
|
|
14615
|
-
|
|
14616
|
-
xhr.onreadystatechange = function() {
|
|
14617
|
-
// DONE (success or failure)
|
|
14618
|
-
if (xhr.readyState === 4) {
|
|
14619
|
-
request.signal.removeEventListener('abort', abortXhr);
|
|
14620
|
-
}
|
|
14621
|
-
};
|
|
14622
|
-
}
|
|
14623
|
-
|
|
14624
|
-
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
|
|
14625
|
-
})
|
|
14626
|
-
}
|
|
14627
|
-
|
|
14628
|
-
fetch.polyfill = true;
|
|
14629
|
-
|
|
14630
|
-
if (!self.fetch) {
|
|
14631
|
-
self.fetch = fetch;
|
|
14632
|
-
self.Headers = Headers;
|
|
14633
|
-
self.Request = Request;
|
|
14634
|
-
self.Response = Response;
|
|
14635
|
-
}
|
|
14636
|
-
|
|
14637
|
-
exports.Headers = Headers;
|
|
14638
|
-
exports.Request = Request;
|
|
14639
|
-
exports.Response = Response;
|
|
14640
|
-
exports.fetch = fetch;
|
|
14641
|
-
|
|
14642
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14643
|
-
|
|
14644
|
-
return exports;
|
|
14645
|
-
|
|
14646
|
-
})({});
|
|
14647
|
-
})(__self__);
|
|
14648
|
-
__self__.fetch.ponyfill = true;
|
|
14649
|
-
// Remove "polyfill" property added by whatwg-fetch
|
|
14650
|
-
delete __self__.fetch.polyfill;
|
|
14651
|
-
// Choose between native implementation (global) or custom implementation (__self__)
|
|
14652
|
-
// var ctx = global.fetch ? global : __self__;
|
|
14653
|
-
var ctx = __self__; // this line disable service worker support temporarily
|
|
14654
|
-
exports = ctx.fetch; // To enable: import fetch from 'cross-fetch'
|
|
14655
|
-
exports.default = ctx.fetch; // For TypeScript consumers without esModuleInterop.
|
|
14656
|
-
exports.fetch = ctx.fetch; // To enable: import {fetch} from 'cross-fetch'
|
|
14657
|
-
exports.Headers = ctx.Headers;
|
|
14658
|
-
exports.Request = ctx.Request;
|
|
14659
|
-
exports.Response = ctx.Response;
|
|
14660
|
-
module.exports = exports;
|
|
14661
|
-
});
|
|
14662
|
-
|
|
14663
|
-
unwrapExports(browserPonyfill);
|
|
14664
|
-
|
|
14665
|
-
var ReactNativeFile = function ReactNativeFile(_ref) {
|
|
14666
|
-
var uri = _ref.uri,
|
|
14667
|
-
name = _ref.name,
|
|
14668
|
-
type = _ref.type;
|
|
14669
|
-
this.uri = uri;
|
|
14670
|
-
this.name = name;
|
|
14671
|
-
this.type = type;
|
|
14672
|
-
};
|
|
14673
|
-
|
|
14674
|
-
var isExtractableFile = function isExtractableFile(value) {
|
|
14675
|
-
return (
|
|
14676
|
-
(typeof File !== 'undefined' && value instanceof File) ||
|
|
14677
|
-
(typeof Blob !== 'undefined' && value instanceof Blob) ||
|
|
14678
|
-
value instanceof ReactNativeFile
|
|
14679
|
-
);
|
|
14680
|
-
};
|
|
14681
|
-
|
|
14682
|
-
var extractFiles = function extractFiles(value, path, isExtractableFile$1) {
|
|
14683
|
-
if (path === void 0) {
|
|
14684
|
-
path = '';
|
|
14685
|
-
}
|
|
14686
|
-
|
|
14687
|
-
if (isExtractableFile$1 === void 0) {
|
|
14688
|
-
isExtractableFile$1 = isExtractableFile;
|
|
14689
|
-
}
|
|
14690
|
-
|
|
14691
|
-
var clone;
|
|
14692
|
-
var files = new Map();
|
|
14693
|
-
|
|
14694
|
-
function addFile(paths, file) {
|
|
14695
|
-
var storedPaths = files.get(file);
|
|
14696
|
-
if (storedPaths) storedPaths.push.apply(storedPaths, paths);
|
|
14697
|
-
else files.set(file, paths);
|
|
14698
|
-
}
|
|
14699
|
-
|
|
14700
|
-
if (isExtractableFile$1(value)) {
|
|
14701
|
-
clone = null;
|
|
14702
|
-
addFile([path], value);
|
|
14703
|
-
} else {
|
|
14704
|
-
var prefix = path ? path + '.' : '';
|
|
14705
|
-
if (typeof FileList !== 'undefined' && value instanceof FileList)
|
|
14706
|
-
clone = Array.prototype.map.call(value, function (file, i) {
|
|
14707
|
-
addFile(['' + prefix + i], file);
|
|
14708
|
-
return null;
|
|
14709
|
-
});
|
|
14710
|
-
else if (Array.isArray(value))
|
|
14711
|
-
clone = value.map(function (child, i) {
|
|
14712
|
-
var result = extractFiles(child, '' + prefix + i, isExtractableFile$1);
|
|
14713
|
-
result.files.forEach(addFile);
|
|
14714
|
-
return result.clone;
|
|
14715
|
-
});
|
|
14716
|
-
else if (value && value.constructor === Object) {
|
|
14717
|
-
clone = {};
|
|
14718
|
-
|
|
14719
|
-
for (var i in value) {
|
|
14720
|
-
var result = extractFiles(value[i], '' + prefix + i, isExtractableFile$1);
|
|
14721
|
-
result.files.forEach(addFile);
|
|
14722
|
-
clone[i] = result.clone;
|
|
14723
|
-
}
|
|
14724
|
-
} else clone = value;
|
|
14725
|
-
}
|
|
14726
|
-
|
|
14727
|
-
return {
|
|
14728
|
-
clone: clone,
|
|
14729
|
-
files: files,
|
|
14730
|
-
};
|
|
14731
|
-
};
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
var _public = {
|
|
14736
|
-
__proto__: null,
|
|
14737
|
-
ReactNativeFile: ReactNativeFile,
|
|
14738
|
-
extractFiles: extractFiles,
|
|
14739
|
-
isExtractableFile: isExtractableFile
|
|
14740
|
-
};
|
|
14741
|
-
|
|
14742
|
-
/* eslint-env browser */
|
|
14743
|
-
var browser$1 = typeof self == 'object' ? self.FormData : window.FormData;
|
|
14744
|
-
|
|
14745
|
-
var defaultJsonSerializer = createCommonjsModule(function (module, exports) {
|
|
14746
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14747
|
-
exports.defaultJsonSerializer = void 0;
|
|
14748
|
-
exports.defaultJsonSerializer = {
|
|
14749
|
-
parse: JSON.parse,
|
|
14750
|
-
stringify: JSON.stringify
|
|
14751
|
-
};
|
|
14752
|
-
|
|
14753
|
-
});
|
|
14754
|
-
|
|
14755
|
-
unwrapExports(defaultJsonSerializer);
|
|
14756
|
-
|
|
14757
|
-
var extract_files_1 = getCjsExportFromNamespace(_public);
|
|
14758
|
-
|
|
14759
|
-
var createRequestBody_1 = createCommonjsModule(function (module, exports) {
|
|
14760
|
-
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
14761
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14762
|
-
};
|
|
14763
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14764
|
-
|
|
14765
|
-
var form_data_1 = __importDefault(browser$1);
|
|
14766
|
-
|
|
14767
|
-
/**
|
|
14768
|
-
* Duck type if NodeJS stream
|
|
14769
|
-
* https://github.com/sindresorhus/is-stream/blob/3750505b0727f6df54324784fe369365ef78841e/index.js#L3
|
|
14770
|
-
*/
|
|
14771
|
-
var isExtractableFileEnhanced = function (value) {
|
|
14772
|
-
return extract_files_1.isExtractableFile(value) ||
|
|
14773
|
-
(value !== null && typeof value === 'object' && typeof value.pipe === 'function');
|
|
14774
|
-
};
|
|
14775
|
-
/**
|
|
14776
|
-
* Returns Multipart Form if body contains files
|
|
14777
|
-
* (https://github.com/jaydenseric/graphql-multipart-request-spec)
|
|
14778
|
-
* Otherwise returns JSON
|
|
14779
|
-
*/
|
|
14780
|
-
function createRequestBody(query, variables, operationName, jsonSerializer) {
|
|
14781
|
-
if (jsonSerializer === void 0) { jsonSerializer = defaultJsonSerializer.defaultJsonSerializer; }
|
|
14782
|
-
var _a = extract_files_1.extractFiles({ query: query, variables: variables, operationName: operationName }, '', isExtractableFileEnhanced), clone = _a.clone, files = _a.files;
|
|
14783
|
-
if (files.size === 0) {
|
|
14784
|
-
if (!Array.isArray(query)) {
|
|
14785
|
-
return jsonSerializer.stringify(clone);
|
|
14786
|
-
}
|
|
14787
|
-
if (typeof variables !== 'undefined' && !Array.isArray(variables)) {
|
|
14788
|
-
throw new Error('Cannot create request body with given variable type, array expected');
|
|
14789
|
-
}
|
|
14790
|
-
// Batch support
|
|
14791
|
-
var payload = query.reduce(function (accu, currentQuery, index) {
|
|
14792
|
-
accu.push({ query: currentQuery, variables: variables ? variables[index] : undefined });
|
|
14793
|
-
return accu;
|
|
14794
|
-
}, []);
|
|
14795
|
-
return jsonSerializer.stringify(payload);
|
|
14796
|
-
}
|
|
14797
|
-
var Form = typeof FormData === 'undefined' ? form_data_1.default : FormData;
|
|
14798
|
-
var form = new Form();
|
|
14799
|
-
form.append('operations', jsonSerializer.stringify(clone));
|
|
14800
|
-
var map = {};
|
|
14801
|
-
var i = 0;
|
|
14802
|
-
files.forEach(function (paths) {
|
|
14803
|
-
map[++i] = paths;
|
|
14804
|
-
});
|
|
14805
|
-
form.append('map', jsonSerializer.stringify(map));
|
|
14806
|
-
i = 0;
|
|
14807
|
-
files.forEach(function (paths, file) {
|
|
14808
|
-
form.append("" + ++i, file);
|
|
14809
|
-
});
|
|
14810
|
-
return form;
|
|
14811
|
-
}
|
|
14812
|
-
exports.default = createRequestBody;
|
|
14813
|
-
|
|
14814
|
-
});
|
|
14815
|
-
|
|
14816
|
-
unwrapExports(createRequestBody_1);
|
|
14817
|
-
|
|
14818
|
-
var parseArgs = createCommonjsModule(function (module, exports) {
|
|
14819
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14820
|
-
exports.parseBatchRequestsExtendedArgs = exports.parseRawRequestExtendedArgs = exports.parseRequestExtendedArgs = exports.parseBatchRequestArgs = exports.parseRawRequestArgs = exports.parseRequestArgs = void 0;
|
|
14821
|
-
function parseRequestArgs(documentOrOptions, variables, requestHeaders) {
|
|
14822
|
-
return documentOrOptions.document
|
|
14823
|
-
? documentOrOptions
|
|
14824
|
-
: {
|
|
14825
|
-
document: documentOrOptions,
|
|
14826
|
-
variables: variables,
|
|
14827
|
-
requestHeaders: requestHeaders,
|
|
14828
|
-
signal: undefined,
|
|
14829
|
-
};
|
|
14830
|
-
}
|
|
14831
|
-
exports.parseRequestArgs = parseRequestArgs;
|
|
14832
|
-
function parseRawRequestArgs(queryOrOptions, variables, requestHeaders) {
|
|
14833
|
-
return queryOrOptions.query
|
|
14834
|
-
? queryOrOptions
|
|
14835
|
-
: {
|
|
14836
|
-
query: queryOrOptions,
|
|
14837
|
-
variables: variables,
|
|
14838
|
-
requestHeaders: requestHeaders,
|
|
14839
|
-
signal: undefined,
|
|
14840
|
-
};
|
|
14841
|
-
}
|
|
14842
|
-
exports.parseRawRequestArgs = parseRawRequestArgs;
|
|
14843
|
-
function parseBatchRequestArgs(documentsOrOptions, requestHeaders) {
|
|
14844
|
-
return documentsOrOptions.documents
|
|
14845
|
-
? documentsOrOptions
|
|
14846
|
-
: {
|
|
14847
|
-
documents: documentsOrOptions,
|
|
14848
|
-
requestHeaders: requestHeaders,
|
|
14849
|
-
signal: undefined,
|
|
14850
|
-
};
|
|
14851
|
-
}
|
|
14852
|
-
exports.parseBatchRequestArgs = parseBatchRequestArgs;
|
|
14853
|
-
function parseRequestExtendedArgs(urlOrOptions, document, variables, requestHeaders) {
|
|
14854
|
-
return urlOrOptions.document
|
|
14855
|
-
? urlOrOptions
|
|
14856
|
-
: {
|
|
14857
|
-
url: urlOrOptions,
|
|
14858
|
-
document: document,
|
|
14859
|
-
variables: variables,
|
|
14860
|
-
requestHeaders: requestHeaders,
|
|
14861
|
-
signal: undefined,
|
|
14862
|
-
};
|
|
14863
|
-
}
|
|
14864
|
-
exports.parseRequestExtendedArgs = parseRequestExtendedArgs;
|
|
14865
|
-
function parseRawRequestExtendedArgs(urlOrOptions, query, variables, requestHeaders) {
|
|
14866
|
-
return urlOrOptions.query
|
|
14867
|
-
? urlOrOptions
|
|
14868
|
-
: {
|
|
14869
|
-
url: urlOrOptions,
|
|
14870
|
-
query: query,
|
|
14871
|
-
variables: variables,
|
|
14872
|
-
requestHeaders: requestHeaders,
|
|
14873
|
-
signal: undefined,
|
|
14874
|
-
};
|
|
14875
|
-
}
|
|
14876
|
-
exports.parseRawRequestExtendedArgs = parseRawRequestExtendedArgs;
|
|
14877
|
-
function parseBatchRequestsExtendedArgs(urlOrOptions, documents, requestHeaders) {
|
|
14878
|
-
return urlOrOptions.documents
|
|
14879
|
-
? urlOrOptions
|
|
14880
|
-
: {
|
|
14881
|
-
url: urlOrOptions,
|
|
14882
|
-
documents: documents,
|
|
14883
|
-
requestHeaders: requestHeaders,
|
|
14884
|
-
signal: undefined,
|
|
14885
|
-
};
|
|
14886
|
-
}
|
|
14887
|
-
exports.parseBatchRequestsExtendedArgs = parseBatchRequestsExtendedArgs;
|
|
14888
|
-
|
|
14889
|
-
});
|
|
14890
|
-
|
|
14891
|
-
unwrapExports(parseArgs);
|
|
14892
|
-
|
|
14893
|
-
var types = createCommonjsModule(function (module, exports) {
|
|
14894
|
-
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
14895
|
-
var extendStatics = function (d, b) {
|
|
14896
|
-
extendStatics = Object.setPrototypeOf ||
|
|
14897
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
14898
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
14899
|
-
return extendStatics(d, b);
|
|
14900
|
-
};
|
|
14901
|
-
return function (d, b) {
|
|
14902
|
-
if (typeof b !== "function" && b !== null)
|
|
14903
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14904
|
-
extendStatics(d, b);
|
|
14905
|
-
function __() { this.constructor = d; }
|
|
14906
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14907
|
-
};
|
|
14908
|
-
})();
|
|
14909
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14910
|
-
exports.ClientError = void 0;
|
|
14911
|
-
var ClientError = /** @class */ (function (_super) {
|
|
14912
|
-
__extends(ClientError, _super);
|
|
14913
|
-
function ClientError(response, request) {
|
|
14914
|
-
var _this = this;
|
|
14915
|
-
var message = ClientError.extractMessage(response) + ": " + JSON.stringify({
|
|
14916
|
-
response: response,
|
|
14917
|
-
request: request,
|
|
14918
|
-
});
|
|
14919
|
-
_this = _super.call(this, message) || this;
|
|
14920
|
-
Object.setPrototypeOf(_this, ClientError.prototype);
|
|
14921
|
-
_this.response = response;
|
|
14922
|
-
_this.request = request;
|
|
14923
|
-
// this is needed as Safari doesn't support .captureStackTrace
|
|
14924
|
-
if (typeof Error.captureStackTrace === 'function') {
|
|
14925
|
-
Error.captureStackTrace(_this, ClientError);
|
|
14926
|
-
}
|
|
14927
|
-
return _this;
|
|
14928
|
-
}
|
|
14929
|
-
ClientError.extractMessage = function (response) {
|
|
14930
|
-
try {
|
|
14931
|
-
return response.errors[0].message;
|
|
14932
|
-
}
|
|
14933
|
-
catch (e) {
|
|
14934
|
-
return "GraphQL Error (Code: " + response.status + ")";
|
|
14935
|
-
}
|
|
14936
|
-
};
|
|
14937
|
-
return ClientError;
|
|
14938
|
-
}(Error));
|
|
14939
|
-
exports.ClientError = ClientError;
|
|
14940
|
-
|
|
14941
|
-
});
|
|
14942
|
-
|
|
14943
|
-
unwrapExports(types);
|
|
14944
|
-
|
|
14945
|
-
var graphqlWs = createCommonjsModule(function (module, exports) {
|
|
14946
|
-
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
14947
|
-
__assign = Object.assign || function(t) {
|
|
14948
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
14949
|
-
s = arguments[i];
|
|
14950
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
14951
|
-
t[p] = s[p];
|
|
14952
|
-
}
|
|
14953
|
-
return t;
|
|
14954
|
-
};
|
|
14955
|
-
return __assign.apply(this, arguments);
|
|
14956
|
-
};
|
|
14957
|
-
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14958
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14959
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14960
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14961
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
14962
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14963
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14964
|
-
});
|
|
14965
|
-
};
|
|
14966
|
-
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
14967
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14968
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14969
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14970
|
-
function step(op) {
|
|
14971
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
14972
|
-
while (_) try {
|
|
14973
|
-
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;
|
|
14974
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
14975
|
-
switch (op[0]) {
|
|
14976
|
-
case 0: case 1: t = op; break;
|
|
14977
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
14978
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
14979
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
14980
|
-
default:
|
|
14981
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
14982
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
14983
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
14984
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
14985
|
-
if (t[2]) _.ops.pop();
|
|
14986
|
-
_.trys.pop(); continue;
|
|
14987
|
-
}
|
|
14988
|
-
op = body.call(thisArg, _);
|
|
14989
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
14990
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
14991
|
-
}
|
|
14992
|
-
};
|
|
14993
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14994
|
-
exports.GraphQLWebSocketClient = void 0;
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
var CONNECTION_INIT = 'connection_init';
|
|
14998
|
-
var CONNECTION_ACK = 'connection_ack';
|
|
14999
|
-
var PING = 'ping';
|
|
15000
|
-
var PONG = 'pong';
|
|
15001
|
-
var SUBSCRIBE = 'subscribe';
|
|
15002
|
-
var NEXT = 'next';
|
|
15003
|
-
var ERROR = 'error';
|
|
15004
|
-
var COMPLETE = 'complete';
|
|
15005
|
-
var GraphQLWebSocketMessage = /** @class */ (function () {
|
|
15006
|
-
function GraphQLWebSocketMessage(type, payload, id) {
|
|
15007
|
-
this._type = type;
|
|
15008
|
-
this._payload = payload;
|
|
15009
|
-
this._id = id;
|
|
15010
|
-
}
|
|
15011
|
-
Object.defineProperty(GraphQLWebSocketMessage.prototype, "type", {
|
|
15012
|
-
get: function () { return this._type; },
|
|
15013
|
-
enumerable: false,
|
|
15014
|
-
configurable: true
|
|
15015
|
-
});
|
|
15016
|
-
Object.defineProperty(GraphQLWebSocketMessage.prototype, "id", {
|
|
15017
|
-
get: function () { return this._id; },
|
|
15018
|
-
enumerable: false,
|
|
15019
|
-
configurable: true
|
|
15020
|
-
});
|
|
15021
|
-
Object.defineProperty(GraphQLWebSocketMessage.prototype, "payload", {
|
|
15022
|
-
get: function () { return this._payload; },
|
|
15023
|
-
enumerable: false,
|
|
15024
|
-
configurable: true
|
|
15025
|
-
});
|
|
15026
|
-
Object.defineProperty(GraphQLWebSocketMessage.prototype, "text", {
|
|
15027
|
-
get: function () {
|
|
15028
|
-
var result = { type: this.type };
|
|
15029
|
-
if (this.id != null && this.id != undefined)
|
|
15030
|
-
result.id = this.id;
|
|
15031
|
-
if (this.payload != null && this.payload != undefined)
|
|
15032
|
-
result.payload = this.payload;
|
|
15033
|
-
return JSON.stringify(result);
|
|
15034
|
-
},
|
|
15035
|
-
enumerable: false,
|
|
15036
|
-
configurable: true
|
|
15037
|
-
});
|
|
15038
|
-
GraphQLWebSocketMessage.parse = function (data, f) {
|
|
15039
|
-
var _a = JSON.parse(data), type = _a.type, payload = _a.payload, id = _a.id;
|
|
15040
|
-
return new GraphQLWebSocketMessage(type, f(payload), id);
|
|
15041
|
-
};
|
|
15042
|
-
return GraphQLWebSocketMessage;
|
|
15043
|
-
}());
|
|
15044
|
-
var GraphQLWebSocketClient = /** @class */ (function () {
|
|
15045
|
-
function GraphQLWebSocketClient(socket, _a) {
|
|
15046
|
-
var _this = this;
|
|
15047
|
-
var onInit = _a.onInit, onAcknowledged = _a.onAcknowledged, onPing = _a.onPing, onPong = _a.onPong;
|
|
15048
|
-
this.socketState = { acknowledged: false, lastRequestId: 0, subscriptions: {} };
|
|
15049
|
-
this.socket = socket;
|
|
15050
|
-
socket.onopen = function (e) { return __awaiter(_this, void 0, void 0, function () {
|
|
15051
|
-
var _a, _b, _c, _d;
|
|
15052
|
-
return __generator(this, function (_e) {
|
|
15053
|
-
switch (_e.label) {
|
|
15054
|
-
case 0:
|
|
15055
|
-
this.socketState.acknowledged = false;
|
|
15056
|
-
this.socketState.subscriptions = {};
|
|
15057
|
-
_b = (_a = socket).send;
|
|
15058
|
-
_c = ConnectionInit;
|
|
15059
|
-
if (!onInit) return [3 /*break*/, 2];
|
|
15060
|
-
return [4 /*yield*/, onInit()];
|
|
15061
|
-
case 1:
|
|
15062
|
-
_d = _e.sent();
|
|
15063
|
-
return [3 /*break*/, 3];
|
|
15064
|
-
case 2:
|
|
15065
|
-
_d = null;
|
|
15066
|
-
_e.label = 3;
|
|
15067
|
-
case 3:
|
|
15068
|
-
_b.apply(_a, [_c.apply(void 0, [_d]).text]);
|
|
15069
|
-
return [2 /*return*/];
|
|
15070
|
-
}
|
|
15071
|
-
});
|
|
15072
|
-
}); };
|
|
15073
|
-
socket.onclose = function (e) {
|
|
15074
|
-
_this.socketState.acknowledged = false;
|
|
15075
|
-
_this.socketState.subscriptions = {};
|
|
15076
|
-
};
|
|
15077
|
-
socket.onerror = function (e) {
|
|
15078
|
-
console.error(e);
|
|
15079
|
-
};
|
|
15080
|
-
socket.onmessage = function (e) {
|
|
15081
|
-
try {
|
|
15082
|
-
var message = parseMessage(e.data);
|
|
15083
|
-
switch (message.type) {
|
|
15084
|
-
case CONNECTION_ACK: {
|
|
15085
|
-
if (_this.socketState.acknowledged) {
|
|
15086
|
-
console.warn("Duplicate CONNECTION_ACK message ignored");
|
|
15087
|
-
}
|
|
15088
|
-
else {
|
|
15089
|
-
_this.socketState.acknowledged = true;
|
|
15090
|
-
if (onAcknowledged)
|
|
15091
|
-
onAcknowledged(message.payload);
|
|
15092
|
-
}
|
|
15093
|
-
return;
|
|
15094
|
-
}
|
|
15095
|
-
case PING: {
|
|
15096
|
-
if (onPing)
|
|
15097
|
-
onPing(message.payload).then(function (r) { return socket.send(Pong(r).text); });
|
|
15098
|
-
else
|
|
15099
|
-
socket.send(Pong(null).text);
|
|
15100
|
-
return;
|
|
15101
|
-
}
|
|
15102
|
-
case PONG: {
|
|
15103
|
-
if (onPong)
|
|
15104
|
-
onPong(message.payload);
|
|
15105
|
-
return;
|
|
15106
|
-
}
|
|
15107
|
-
}
|
|
15108
|
-
if (!_this.socketState.acknowledged) {
|
|
15109
|
-
// Web-socket connection not acknowledged
|
|
15110
|
-
return;
|
|
15111
|
-
}
|
|
15112
|
-
if (message.id === undefined || message.id === null || !_this.socketState.subscriptions[message.id]) {
|
|
15113
|
-
// No subscription identifer or subscription indentifier is not found
|
|
15114
|
-
return;
|
|
15115
|
-
}
|
|
15116
|
-
var _a = _this.socketState.subscriptions[message.id], query = _a.query, variables = _a.variables, subscriber = _a.subscriber;
|
|
15117
|
-
switch (message.type) {
|
|
15118
|
-
case NEXT: {
|
|
15119
|
-
if (!message.payload.errors && message.payload.data) {
|
|
15120
|
-
subscriber.next && subscriber.next(message.payload.data);
|
|
15121
|
-
}
|
|
15122
|
-
if (message.payload.errors) {
|
|
15123
|
-
subscriber.error && subscriber.error(new types.ClientError(__assign(__assign({}, message.payload), { status: 200 }), { query: query, variables: variables }));
|
|
15124
|
-
}
|
|
15125
|
-
else {
|
|
15126
|
-
}
|
|
15127
|
-
return;
|
|
15128
|
-
}
|
|
15129
|
-
case ERROR: {
|
|
15130
|
-
subscriber.error && subscriber.error(new types.ClientError({ errors: message.payload, status: 200 }, { query: query, variables: variables }));
|
|
15131
|
-
return;
|
|
15132
|
-
}
|
|
15133
|
-
case COMPLETE: {
|
|
15134
|
-
subscriber.complete && subscriber.complete();
|
|
15135
|
-
delete _this.socketState.subscriptions[message.id];
|
|
15136
|
-
return;
|
|
15137
|
-
}
|
|
15138
|
-
}
|
|
15139
|
-
}
|
|
15140
|
-
catch (e) {
|
|
15141
|
-
// Unexpected errors while handling graphql-ws message
|
|
15142
|
-
console.error(e);
|
|
15143
|
-
socket.close(1006);
|
|
15144
|
-
}
|
|
15145
|
-
socket.close(4400, "Unknown graphql-ws message.");
|
|
15146
|
-
};
|
|
15147
|
-
}
|
|
15148
|
-
GraphQLWebSocketClient.prototype.makeSubscribe = function (query, operationName, variables, subscriber) {
|
|
15149
|
-
var _this = this;
|
|
15150
|
-
var subscriptionId = (this.socketState.lastRequestId++).toString();
|
|
15151
|
-
this.socketState.subscriptions[subscriptionId] = { query: query, variables: variables, subscriber: subscriber };
|
|
15152
|
-
this.socket.send(Subscribe(subscriptionId, { query: query, operationName: operationName, variables: variables }).text);
|
|
15153
|
-
return function () {
|
|
15154
|
-
_this.socket.send(Complete(subscriptionId).text);
|
|
15155
|
-
delete _this.socketState.subscriptions[subscriptionId];
|
|
15156
|
-
};
|
|
15157
|
-
};
|
|
15158
|
-
GraphQLWebSocketClient.prototype.rawRequest = function (query, variables) {
|
|
15159
|
-
var _this = this;
|
|
15160
|
-
return new Promise(function (resolve, reject) {
|
|
15161
|
-
var result;
|
|
15162
|
-
_this.rawSubscribe(query, {
|
|
15163
|
-
next: function (data, extensions) { return (result = { data: data, extensions: extensions }); },
|
|
15164
|
-
error: reject,
|
|
15165
|
-
complete: function () { return resolve(result); },
|
|
15166
|
-
}, variables);
|
|
15167
|
-
});
|
|
15168
|
-
};
|
|
15169
|
-
GraphQLWebSocketClient.prototype.request = function (document, variables) {
|
|
15170
|
-
var _this = this;
|
|
15171
|
-
return new Promise(function (resolve, reject) {
|
|
15172
|
-
var result;
|
|
15173
|
-
_this.subscribe(document, {
|
|
15174
|
-
next: function (data) { return (result = data); },
|
|
15175
|
-
error: reject,
|
|
15176
|
-
complete: function () { return resolve(result); },
|
|
15177
|
-
}, variables);
|
|
15178
|
-
});
|
|
15179
|
-
};
|
|
15180
|
-
GraphQLWebSocketClient.prototype.subscribe = function (document, subscriber, variables) {
|
|
15181
|
-
var _a = dist.resolveRequestDocument(document), query = _a.query, operationName = _a.operationName;
|
|
15182
|
-
return this.makeSubscribe(query, operationName, variables, subscriber);
|
|
15183
|
-
};
|
|
15184
|
-
GraphQLWebSocketClient.prototype.rawSubscribe = function (query, subscriber, variables) {
|
|
15185
|
-
return this.makeSubscribe(query, undefined, variables, subscriber);
|
|
15186
|
-
};
|
|
15187
|
-
GraphQLWebSocketClient.prototype.ping = function (payload) {
|
|
15188
|
-
this.socket.send(Ping(payload).text);
|
|
15189
|
-
};
|
|
15190
|
-
GraphQLWebSocketClient.prototype.close = function () {
|
|
15191
|
-
this.socket.close(1000);
|
|
15192
|
-
};
|
|
15193
|
-
GraphQLWebSocketClient.PROTOCOL = "graphql-transport-ws";
|
|
15194
|
-
return GraphQLWebSocketClient;
|
|
15195
|
-
}());
|
|
15196
|
-
exports.GraphQLWebSocketClient = GraphQLWebSocketClient;
|
|
15197
|
-
// Helper functions
|
|
15198
|
-
function parseMessage(data, f) {
|
|
15199
|
-
if (f === void 0) { f = function (a) { return a; }; }
|
|
15200
|
-
var m = GraphQLWebSocketMessage.parse(data, f);
|
|
15201
|
-
return m;
|
|
15202
|
-
}
|
|
15203
|
-
function ConnectionInit(payload) {
|
|
15204
|
-
return new GraphQLWebSocketMessage(CONNECTION_INIT, payload);
|
|
15205
|
-
}
|
|
15206
|
-
function Ping(payload) {
|
|
15207
|
-
return new GraphQLWebSocketMessage(PING, payload, undefined);
|
|
15208
|
-
}
|
|
15209
|
-
function Pong(payload) {
|
|
15210
|
-
return new GraphQLWebSocketMessage(PONG, payload, undefined);
|
|
15211
|
-
}
|
|
15212
|
-
function Subscribe(id, payload) {
|
|
15213
|
-
return new GraphQLWebSocketMessage(SUBSCRIBE, payload, id);
|
|
15214
|
-
}
|
|
15215
|
-
function Complete(id) {
|
|
15216
|
-
return new GraphQLWebSocketMessage(COMPLETE, undefined, id);
|
|
15217
|
-
}
|
|
15218
|
-
|
|
15219
|
-
});
|
|
15220
|
-
|
|
15221
|
-
unwrapExports(graphqlWs);
|
|
15222
|
-
|
|
15223
|
-
var parser_1 = getCjsExportFromNamespace(parser);
|
|
15224
|
-
|
|
15225
|
-
var printer_1 = getCjsExportFromNamespace(printer);
|
|
15226
|
-
|
|
15227
|
-
var dist = createCommonjsModule(function (module, exports) {
|
|
15228
|
-
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
15229
|
-
__assign = Object.assign || function(t) {
|
|
15230
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15231
|
-
s = arguments[i];
|
|
15232
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
15233
|
-
t[p] = s[p];
|
|
15234
|
-
}
|
|
15235
|
-
return t;
|
|
15236
|
-
};
|
|
15237
|
-
return __assign.apply(this, arguments);
|
|
15238
|
-
};
|
|
15239
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15240
|
-
if (k2 === undefined) k2 = k;
|
|
15241
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
15242
|
-
}) : (function(o, m, k, k2) {
|
|
15243
|
-
if (k2 === undefined) k2 = k;
|
|
15244
|
-
o[k2] = m[k];
|
|
15245
|
-
}));
|
|
15246
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15247
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15248
|
-
}) : function(o, v) {
|
|
15249
|
-
o["default"] = v;
|
|
15250
|
-
});
|
|
15251
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
15252
|
-
if (mod && mod.__esModule) return mod;
|
|
15253
|
-
var result = {};
|
|
15254
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
15255
|
-
__setModuleDefault(result, mod);
|
|
15256
|
-
return result;
|
|
15257
|
-
};
|
|
15258
|
-
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15259
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15260
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15261
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15262
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15263
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
15264
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15265
|
-
});
|
|
15266
|
-
};
|
|
15267
|
-
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
15268
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
15269
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15270
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15271
|
-
function step(op) {
|
|
15272
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
15273
|
-
while (_) try {
|
|
15274
|
-
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;
|
|
15275
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
15276
|
-
switch (op[0]) {
|
|
15277
|
-
case 0: case 1: t = op; break;
|
|
15278
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
15279
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
15280
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
15281
|
-
default:
|
|
15282
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
15283
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
15284
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
15285
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
15286
|
-
if (t[2]) _.ops.pop();
|
|
15287
|
-
_.trys.pop(); continue;
|
|
15288
|
-
}
|
|
15289
|
-
op = body.call(thisArg, _);
|
|
15290
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
15291
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
15292
|
-
}
|
|
15293
|
-
};
|
|
15294
|
-
var __rest = (commonjsGlobal && commonjsGlobal.__rest) || function (s, e) {
|
|
15295
|
-
var t = {};
|
|
15296
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15297
|
-
t[p] = s[p];
|
|
15298
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15299
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
15300
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
15301
|
-
t[p[i]] = s[p[i]];
|
|
15302
|
-
}
|
|
15303
|
-
return t;
|
|
15304
|
-
};
|
|
15305
|
-
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
15306
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15307
|
-
};
|
|
15308
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15309
|
-
exports.GraphQLWebSocketClient = exports.gql = exports.resolveRequestDocument = exports.batchRequests = exports.request = exports.rawRequest = exports.GraphQLClient = exports.ClientError = void 0;
|
|
15310
|
-
var cross_fetch_1 = __importStar(browserPonyfill), CrossFetch = cross_fetch_1;
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
var createRequestBody_1$1 = __importDefault(createRequestBody_1);
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
Object.defineProperty(exports, "ClientError", { enumerable: true, get: function () { return types.ClientError; } });
|
|
15318
|
-
/**
|
|
15319
|
-
* Convert the given headers configuration into a plain object.
|
|
15320
|
-
*/
|
|
15321
|
-
var resolveHeaders = function (headers) {
|
|
15322
|
-
var oHeaders = {};
|
|
15323
|
-
if (headers) {
|
|
15324
|
-
if ((typeof Headers !== 'undefined' && headers instanceof Headers) ||
|
|
15325
|
-
headers instanceof CrossFetch.Headers) {
|
|
15326
|
-
oHeaders = HeadersInstanceToPlainObject(headers);
|
|
15327
|
-
}
|
|
15328
|
-
else if (Array.isArray(headers)) {
|
|
15329
|
-
headers.forEach(function (_a) {
|
|
15330
|
-
var name = _a[0], value = _a[1];
|
|
15331
|
-
oHeaders[name] = value;
|
|
15332
|
-
});
|
|
15333
|
-
}
|
|
15334
|
-
else {
|
|
15335
|
-
oHeaders = headers;
|
|
15336
|
-
}
|
|
15337
|
-
}
|
|
15338
|
-
return oHeaders;
|
|
15339
|
-
};
|
|
15340
|
-
/**
|
|
15341
|
-
* Clean a GraphQL document to send it via a GET query
|
|
15342
|
-
*
|
|
15343
|
-
* @param {string} str GraphQL query
|
|
15344
|
-
* @returns {string} Cleaned query
|
|
15345
|
-
*/
|
|
15346
|
-
var queryCleanner = function (str) { return str.replace(/([\s,]|#[^\n\r]+)+/g, ' ').trim(); };
|
|
15347
|
-
/**
|
|
15348
|
-
* Create query string for GraphQL request
|
|
15349
|
-
*
|
|
15350
|
-
* @param {object} param0 -
|
|
15351
|
-
*
|
|
15352
|
-
* @param {string|string[]} param0.query the GraphQL document or array of document if it's a batch request
|
|
15353
|
-
* @param {string|undefined} param0.operationName the GraphQL operation name
|
|
15354
|
-
* @param {any|any[]} param0.variables the GraphQL variables to use
|
|
15355
|
-
*/
|
|
15356
|
-
var buildGetQueryParams = function (_a) {
|
|
15357
|
-
var query = _a.query, variables = _a.variables, operationName = _a.operationName, jsonSerializer = _a.jsonSerializer;
|
|
15358
|
-
if (!Array.isArray(query)) {
|
|
15359
|
-
var search = ["query=" + encodeURIComponent(queryCleanner(query))];
|
|
15360
|
-
if (variables) {
|
|
15361
|
-
search.push("variables=" + encodeURIComponent(jsonSerializer.stringify(variables)));
|
|
15362
|
-
}
|
|
15363
|
-
if (operationName) {
|
|
15364
|
-
search.push("operationName=" + encodeURIComponent(operationName));
|
|
15365
|
-
}
|
|
15366
|
-
return search.join('&');
|
|
15367
|
-
}
|
|
15368
|
-
if (typeof variables !== 'undefined' && !Array.isArray(variables)) {
|
|
15369
|
-
throw new Error('Cannot create query with given variable type, array expected');
|
|
15370
|
-
}
|
|
15371
|
-
// Batch support
|
|
15372
|
-
var payload = query.reduce(function (accu, currentQuery, index) {
|
|
15373
|
-
accu.push({
|
|
15374
|
-
query: queryCleanner(currentQuery),
|
|
15375
|
-
variables: variables ? jsonSerializer.stringify(variables[index]) : undefined,
|
|
15376
|
-
});
|
|
15377
|
-
return accu;
|
|
15378
|
-
}, []);
|
|
15379
|
-
return "query=" + encodeURIComponent(jsonSerializer.stringify(payload));
|
|
15380
|
-
};
|
|
15381
|
-
/**
|
|
15382
|
-
* Fetch data using POST method
|
|
15383
|
-
*/
|
|
15384
|
-
var post = function (_a) {
|
|
15385
|
-
var url = _a.url, query = _a.query, variables = _a.variables, operationName = _a.operationName, headers = _a.headers, fetch = _a.fetch, fetchOptions = _a.fetchOptions;
|
|
15386
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
15387
|
-
var body;
|
|
15388
|
-
return __generator(this, function (_b) {
|
|
15389
|
-
switch (_b.label) {
|
|
15390
|
-
case 0:
|
|
15391
|
-
body = createRequestBody_1$1.default(query, variables, operationName, fetchOptions.jsonSerializer);
|
|
15392
|
-
return [4 /*yield*/, fetch(url, __assign({ method: 'POST', headers: __assign(__assign({}, (typeof body === 'string' ? { 'Content-Type': 'application/json' } : {})), headers), body: body }, fetchOptions))];
|
|
15393
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
15394
|
-
}
|
|
15395
|
-
});
|
|
15396
|
-
});
|
|
15397
|
-
};
|
|
15398
|
-
/**
|
|
15399
|
-
* Fetch data using GET method
|
|
15400
|
-
*/
|
|
15401
|
-
var get = function (_a) {
|
|
15402
|
-
var url = _a.url, query = _a.query, variables = _a.variables, operationName = _a.operationName, headers = _a.headers, fetch = _a.fetch, fetchOptions = _a.fetchOptions;
|
|
15403
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
15404
|
-
var queryParams;
|
|
15405
|
-
return __generator(this, function (_b) {
|
|
15406
|
-
switch (_b.label) {
|
|
15407
|
-
case 0:
|
|
15408
|
-
queryParams = buildGetQueryParams({
|
|
15409
|
-
query: query,
|
|
15410
|
-
variables: variables,
|
|
15411
|
-
operationName: operationName,
|
|
15412
|
-
jsonSerializer: fetchOptions.jsonSerializer
|
|
15413
|
-
});
|
|
15414
|
-
return [4 /*yield*/, fetch(url + "?" + queryParams, __assign({ method: 'GET', headers: headers }, fetchOptions))];
|
|
15415
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
15416
|
-
}
|
|
15417
|
-
});
|
|
15418
|
-
});
|
|
15419
|
-
};
|
|
15420
|
-
/**
|
|
15421
|
-
* GraphQL Client.
|
|
15422
|
-
*/
|
|
15423
|
-
var GraphQLClient = /** @class */ (function () {
|
|
15424
|
-
function GraphQLClient(url, options) {
|
|
15425
|
-
this.url = url;
|
|
15426
|
-
this.options = options || {};
|
|
15427
|
-
}
|
|
15428
|
-
GraphQLClient.prototype.rawRequest = function (queryOrOptions, variables, requestHeaders) {
|
|
15429
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15430
|
-
var rawRequestOptions, _a, headers, _b, fetch, _c, method, fetchOptions, url, operationName;
|
|
15431
|
-
return __generator(this, function (_d) {
|
|
15432
|
-
rawRequestOptions = parseArgs.parseRawRequestArgs(queryOrOptions, variables, requestHeaders);
|
|
15433
|
-
_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"]);
|
|
15434
|
-
url = this.url;
|
|
15435
|
-
if (rawRequestOptions.signal !== undefined) {
|
|
15436
|
-
fetchOptions.signal = rawRequestOptions.signal;
|
|
15437
|
-
}
|
|
15438
|
-
operationName = resolveRequestDocument(rawRequestOptions.query).operationName;
|
|
15439
|
-
return [2 /*return*/, makeRequest({
|
|
15440
|
-
url: url,
|
|
15441
|
-
query: rawRequestOptions.query,
|
|
15442
|
-
variables: rawRequestOptions.variables,
|
|
15443
|
-
headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(rawRequestOptions.requestHeaders)),
|
|
15444
|
-
operationName: operationName,
|
|
15445
|
-
fetch: fetch,
|
|
15446
|
-
method: method,
|
|
15447
|
-
fetchOptions: fetchOptions,
|
|
15448
|
-
})];
|
|
15449
|
-
});
|
|
15450
|
-
});
|
|
15451
|
-
};
|
|
15452
|
-
GraphQLClient.prototype.request = function (documentOrOptions, variables, requestHeaders) {
|
|
15453
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15454
|
-
var requestOptions, _a, headers, _b, fetch, _c, method, fetchOptions, url, _d, query, operationName, data;
|
|
15455
|
-
return __generator(this, function (_e) {
|
|
15456
|
-
switch (_e.label) {
|
|
15457
|
-
case 0:
|
|
15458
|
-
requestOptions = parseArgs.parseRequestArgs(documentOrOptions, variables, requestHeaders);
|
|
15459
|
-
_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"]);
|
|
15460
|
-
url = this.url;
|
|
15461
|
-
if (requestOptions.signal !== undefined) {
|
|
15462
|
-
fetchOptions.signal = requestOptions.signal;
|
|
15463
|
-
}
|
|
15464
|
-
_d = resolveRequestDocument(requestOptions.document), query = _d.query, operationName = _d.operationName;
|
|
15465
|
-
return [4 /*yield*/, makeRequest({
|
|
15466
|
-
url: url,
|
|
15467
|
-
query: query,
|
|
15468
|
-
variables: requestOptions.variables,
|
|
15469
|
-
headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(requestOptions.requestHeaders)),
|
|
15470
|
-
operationName: operationName,
|
|
15471
|
-
fetch: fetch,
|
|
15472
|
-
method: method,
|
|
15473
|
-
fetchOptions: fetchOptions,
|
|
15474
|
-
})];
|
|
15475
|
-
case 1:
|
|
15476
|
-
data = (_e.sent()).data;
|
|
15477
|
-
return [2 /*return*/, data];
|
|
15478
|
-
}
|
|
15479
|
-
});
|
|
15480
|
-
});
|
|
15481
|
-
};
|
|
15482
|
-
GraphQLClient.prototype.batchRequests = function (documentsOrOptions, requestHeaders) {
|
|
15483
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15484
|
-
var batchRequestOptions, _a, headers, _b, fetch, _c, method, fetchOptions, url, queries, variables, data;
|
|
15485
|
-
return __generator(this, function (_d) {
|
|
15486
|
-
switch (_d.label) {
|
|
15487
|
-
case 0:
|
|
15488
|
-
batchRequestOptions = parseArgs.parseBatchRequestArgs(documentsOrOptions, requestHeaders);
|
|
15489
|
-
_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"]);
|
|
15490
|
-
url = this.url;
|
|
15491
|
-
if (batchRequestOptions.signal !== undefined) {
|
|
15492
|
-
fetchOptions.signal = batchRequestOptions.signal;
|
|
15493
|
-
}
|
|
15494
|
-
queries = batchRequestOptions.documents.map(function (_a) {
|
|
15495
|
-
var document = _a.document;
|
|
15496
|
-
return resolveRequestDocument(document).query;
|
|
15497
|
-
});
|
|
15498
|
-
variables = batchRequestOptions.documents.map(function (_a) {
|
|
15499
|
-
var variables = _a.variables;
|
|
15500
|
-
return variables;
|
|
15501
|
-
});
|
|
15502
|
-
return [4 /*yield*/, makeRequest({
|
|
15503
|
-
url: url,
|
|
15504
|
-
query: queries,
|
|
15505
|
-
variables: variables,
|
|
15506
|
-
headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(batchRequestOptions.requestHeaders)),
|
|
15507
|
-
operationName: undefined,
|
|
15508
|
-
fetch: fetch,
|
|
15509
|
-
method: method,
|
|
15510
|
-
fetchOptions: fetchOptions,
|
|
15511
|
-
})];
|
|
15512
|
-
case 1:
|
|
15513
|
-
data = (_d.sent()).data;
|
|
15514
|
-
return [2 /*return*/, data];
|
|
15515
|
-
}
|
|
15516
|
-
});
|
|
15517
|
-
});
|
|
15518
|
-
};
|
|
15519
|
-
GraphQLClient.prototype.setHeaders = function (headers) {
|
|
15520
|
-
this.options.headers = headers;
|
|
15521
|
-
return this;
|
|
15522
|
-
};
|
|
15523
|
-
/**
|
|
15524
|
-
* Attach a header to the client. All subsequent requests will have this header.
|
|
15525
|
-
*/
|
|
15526
|
-
GraphQLClient.prototype.setHeader = function (key, value) {
|
|
15527
|
-
var _a;
|
|
15528
|
-
var headers = this.options.headers;
|
|
15529
|
-
if (headers) {
|
|
15530
|
-
// todo what if headers is in nested array form... ?
|
|
15531
|
-
//@ts-ignore
|
|
15532
|
-
headers[key] = value;
|
|
15533
|
-
}
|
|
15534
|
-
else {
|
|
15535
|
-
this.options.headers = (_a = {}, _a[key] = value, _a);
|
|
15536
|
-
}
|
|
15537
|
-
return this;
|
|
15538
|
-
};
|
|
15539
|
-
/**
|
|
15540
|
-
* Change the client endpoint. All subsequent requests will send to this endpoint.
|
|
15541
|
-
*/
|
|
15542
|
-
GraphQLClient.prototype.setEndpoint = function (value) {
|
|
15543
|
-
this.url = value;
|
|
15544
|
-
return this;
|
|
15545
|
-
};
|
|
15546
|
-
return GraphQLClient;
|
|
15547
|
-
}());
|
|
15548
|
-
exports.GraphQLClient = GraphQLClient;
|
|
15549
|
-
function makeRequest(_a) {
|
|
15550
|
-
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;
|
|
15551
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15552
|
-
var fetcher, isBathchingQuery, response, result, successfullyReceivedData, successfullyPassedErrorPolicy, headers_1, status_1, rest, data, errorResult;
|
|
15553
|
-
return __generator(this, function (_c) {
|
|
15554
|
-
switch (_c.label) {
|
|
15555
|
-
case 0:
|
|
15556
|
-
fetcher = method.toUpperCase() === 'POST' ? post : get;
|
|
15557
|
-
isBathchingQuery = Array.isArray(query);
|
|
15558
|
-
return [4 /*yield*/, fetcher({
|
|
15559
|
-
url: url,
|
|
15560
|
-
query: query,
|
|
15561
|
-
variables: variables,
|
|
15562
|
-
operationName: operationName,
|
|
15563
|
-
headers: headers,
|
|
15564
|
-
fetch: fetch,
|
|
15565
|
-
fetchOptions: fetchOptions,
|
|
15566
|
-
})];
|
|
15567
|
-
case 1:
|
|
15568
|
-
response = _c.sent();
|
|
15569
|
-
return [4 /*yield*/, getResult(response, fetchOptions.jsonSerializer)];
|
|
15570
|
-
case 2:
|
|
15571
|
-
result = _c.sent();
|
|
15572
|
-
successfullyReceivedData = isBathchingQuery && Array.isArray(result) ? !result.some(function (_a) {
|
|
15573
|
-
var data = _a.data;
|
|
15574
|
-
return !data;
|
|
15575
|
-
}) : !!result.data;
|
|
15576
|
-
successfullyPassedErrorPolicy = !result.errors || fetchOptions.errorPolicy === 'all' || fetchOptions.errorPolicy === 'ignore';
|
|
15577
|
-
if (response.ok && successfullyPassedErrorPolicy && successfullyReceivedData) {
|
|
15578
|
-
headers_1 = response.headers, status_1 = response.status;
|
|
15579
|
-
rest = __rest(result, ["errors"]);
|
|
15580
|
-
data = fetchOptions.errorPolicy === 'ignore' ? rest : result;
|
|
15581
|
-
return [2 /*return*/, __assign(__assign({}, (isBathchingQuery ? { data: data } : data)), { headers: headers_1, status: status_1 })];
|
|
15582
|
-
}
|
|
15583
|
-
else {
|
|
15584
|
-
errorResult = typeof result === 'string' ? { error: result } : result;
|
|
15585
|
-
throw new types.ClientError(__assign(__assign({}, errorResult), { status: response.status, headers: response.headers }), { query: query, variables: variables });
|
|
15586
|
-
}
|
|
15587
|
-
}
|
|
15588
|
-
});
|
|
15589
|
-
});
|
|
15590
|
-
}
|
|
15591
|
-
function rawRequest(urlOrOptions, query, variables, requestHeaders) {
|
|
15592
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15593
|
-
var requestOptions, client;
|
|
15594
|
-
return __generator(this, function (_a) {
|
|
15595
|
-
requestOptions = parseArgs.parseRawRequestExtendedArgs(urlOrOptions, query, variables, requestHeaders);
|
|
15596
|
-
client = new GraphQLClient(requestOptions.url);
|
|
15597
|
-
return [2 /*return*/, client.rawRequest(__assign({}, requestOptions))];
|
|
15598
|
-
});
|
|
15599
|
-
});
|
|
15600
|
-
}
|
|
15601
|
-
exports.rawRequest = rawRequest;
|
|
15602
|
-
function request(urlOrOptions, document, variables, requestHeaders) {
|
|
15603
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15604
|
-
var requestOptions, client;
|
|
15605
|
-
return __generator(this, function (_a) {
|
|
15606
|
-
requestOptions = parseArgs.parseRequestExtendedArgs(urlOrOptions, document, variables, requestHeaders);
|
|
15607
|
-
client = new GraphQLClient(requestOptions.url);
|
|
15608
|
-
return [2 /*return*/, client.request(__assign({}, requestOptions))];
|
|
15609
|
-
});
|
|
15610
|
-
});
|
|
15611
|
-
}
|
|
15612
|
-
exports.request = request;
|
|
15613
|
-
function batchRequests(urlOrOptions, documents, requestHeaders) {
|
|
15614
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15615
|
-
var requestOptions, client;
|
|
15616
|
-
return __generator(this, function (_a) {
|
|
15617
|
-
requestOptions = parseArgs.parseBatchRequestsExtendedArgs(urlOrOptions, documents, requestHeaders);
|
|
15618
|
-
client = new GraphQLClient(requestOptions.url);
|
|
15619
|
-
return [2 /*return*/, client.batchRequests(__assign({}, requestOptions))];
|
|
15620
|
-
});
|
|
15621
|
-
});
|
|
15622
|
-
}
|
|
15623
|
-
exports.batchRequests = batchRequests;
|
|
15624
|
-
exports.default = request;
|
|
15625
|
-
/**
|
|
15626
|
-
* todo
|
|
15627
|
-
*/
|
|
15628
|
-
function getResult(response, jsonSerializer) {
|
|
15629
|
-
if (jsonSerializer === void 0) { jsonSerializer = defaultJsonSerializer.defaultJsonSerializer; }
|
|
15630
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15631
|
-
var contentType, _a, _b;
|
|
15632
|
-
return __generator(this, function (_c) {
|
|
15633
|
-
switch (_c.label) {
|
|
15634
|
-
case 0:
|
|
15635
|
-
response.headers.forEach(function (value, key) {
|
|
15636
|
-
if (key.toLowerCase() === 'content-type') {
|
|
15637
|
-
contentType = value;
|
|
15638
|
-
}
|
|
15639
|
-
});
|
|
15640
|
-
if (!(contentType && contentType.toLowerCase().startsWith('application/json'))) return [3 /*break*/, 2];
|
|
15641
|
-
_b = (_a = jsonSerializer).parse;
|
|
15642
|
-
return [4 /*yield*/, response.text()];
|
|
15643
|
-
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
|
|
15644
|
-
case 2: return [2 /*return*/, response.text()];
|
|
15645
|
-
}
|
|
15646
|
-
});
|
|
15647
|
-
});
|
|
15648
|
-
}
|
|
15649
|
-
/**
|
|
15650
|
-
* helpers
|
|
15651
|
-
*/
|
|
15652
|
-
function extractOperationName(document) {
|
|
15653
|
-
var _a;
|
|
15654
|
-
var operationName = undefined;
|
|
15655
|
-
var operationDefinitions = document.definitions.filter(function (definition) { return definition.kind === 'OperationDefinition'; });
|
|
15656
|
-
if (operationDefinitions.length === 1) {
|
|
15657
|
-
operationName = (_a = operationDefinitions[0].name) === null || _a === void 0 ? void 0 : _a.value;
|
|
15658
|
-
}
|
|
15659
|
-
return operationName;
|
|
15660
|
-
}
|
|
15661
|
-
function resolveRequestDocument(document) {
|
|
15662
|
-
if (typeof document === 'string') {
|
|
15663
|
-
var operationName_1 = undefined;
|
|
15664
|
-
try {
|
|
15665
|
-
var parsedDocument = parser_1.parse(document);
|
|
15666
|
-
operationName_1 = extractOperationName(parsedDocument);
|
|
15667
|
-
}
|
|
15668
|
-
catch (err) {
|
|
15669
|
-
// Failed parsing the document, the operationName will be undefined
|
|
15670
|
-
}
|
|
15671
|
-
return { query: document, operationName: operationName_1 };
|
|
15672
|
-
}
|
|
15673
|
-
var operationName = extractOperationName(document);
|
|
15674
|
-
return { query: printer_1.print(document), operationName: operationName };
|
|
15675
|
-
}
|
|
15676
|
-
exports.resolveRequestDocument = resolveRequestDocument;
|
|
15677
|
-
function callOrIdentity(value) {
|
|
15678
|
-
return typeof value === 'function' ? value() : value;
|
|
15679
|
-
}
|
|
15680
|
-
/**
|
|
15681
|
-
* 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.
|
|
15682
|
-
*
|
|
15683
|
-
* @example
|
|
15684
|
-
*
|
|
15685
|
-
* import { gql } from 'graphql-request'
|
|
15686
|
-
*
|
|
15687
|
-
* await request('https://foo.bar/graphql', gql`...`)
|
|
15688
|
-
*
|
|
15689
|
-
* @remarks
|
|
15690
|
-
*
|
|
15691
|
-
* 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.
|
|
15692
|
-
*/
|
|
15693
|
-
function gql(chunks) {
|
|
15694
|
-
var variables = [];
|
|
15695
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
15696
|
-
variables[_i - 1] = arguments[_i];
|
|
15697
|
-
}
|
|
15698
|
-
return chunks.reduce(function (accumulator, chunk, index) { return "" + accumulator + chunk + (index in variables ? variables[index] : ''); }, '');
|
|
15699
|
-
}
|
|
15700
|
-
exports.gql = gql;
|
|
15701
|
-
/**
|
|
15702
|
-
* Convert Headers instance into regular object
|
|
15703
|
-
*/
|
|
15704
|
-
function HeadersInstanceToPlainObject(headers) {
|
|
15705
|
-
var o = {};
|
|
15706
|
-
headers.forEach(function (v, k) {
|
|
15707
|
-
o[k] = v;
|
|
15708
|
-
});
|
|
15709
|
-
return o;
|
|
15710
|
-
}
|
|
15711
|
-
|
|
15712
|
-
Object.defineProperty(exports, "GraphQLWebSocketClient", { enumerable: true, get: function () { return graphqlWs.GraphQLWebSocketClient; } });
|
|
15713
|
-
|
|
15714
|
-
});
|
|
15715
|
-
|
|
15716
|
-
unwrapExports(dist);
|
|
15717
|
-
var dist_7 = dist.GraphQLClient;
|
|
15718
|
-
|
|
15719
13412
|
var getGraphqlSdk = function getGraphqlSdk(url, fetch) {
|
|
15720
|
-
var graphqlClient = new
|
|
13413
|
+
var graphqlClient = new graphqlRequest.GraphQLClient(url, {
|
|
15721
13414
|
fetch: fetch
|
|
15722
13415
|
});
|
|
15723
13416
|
return getSdk(graphqlClient);
|