@luvio/graphql-parser 0.103.0 → 0.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gql.d.ts +8 -0
- package/dist/luvioGraphqlParser.js +1059 -1066
- package/dist/luvioGraphqlParser.mjs +1060 -1065
- package/dist/main.d.ts +6 -3
- package/package.json +1 -1
- package/src/__tests__/main.spec.ts +49 -0
- package/src/gql.ts +9 -5
- package/src/main.ts +20 -15
|
@@ -1,223 +1,27 @@
|
|
|
1
|
-
// In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
|
|
2
|
-
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
3
|
-
var SYMBOL_ITERATOR = typeof Symbol === 'function' && Symbol.iterator != null ? Symbol.iterator : '@@iterator'; // In ES2017 (or a polyfilled) environment, this will be Symbol.asyncIterator
|
|
4
|
-
|
|
5
|
-
var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag != null ? Symbol.toStringTag : '@@toStringTag';
|
|
6
|
-
|
|
7
|
-
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
8
|
-
var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
|
|
9
|
-
var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
|
|
10
|
-
|
|
11
|
-
function _typeof$4(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$4 = function _typeof(obj) { return typeof obj; }; } else { _typeof$4 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$4(obj); }
|
|
12
|
-
var MAX_ARRAY_LENGTH = 10;
|
|
13
|
-
var MAX_RECURSIVE_DEPTH = 2;
|
|
14
1
|
/**
|
|
15
|
-
*
|
|
2
|
+
* Returns true if the value acts like a Promise, i.e. has a "then" function,
|
|
3
|
+
* otherwise returns false.
|
|
16
4
|
*/
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function formatValue(value, seenValues) {
|
|
23
|
-
switch (_typeof$4(value)) {
|
|
24
|
-
case 'string':
|
|
25
|
-
return JSON.stringify(value);
|
|
26
|
-
|
|
27
|
-
case 'function':
|
|
28
|
-
return value.name ? "[function ".concat(value.name, "]") : '[function]';
|
|
29
|
-
|
|
30
|
-
case 'object':
|
|
31
|
-
if (value === null) {
|
|
32
|
-
return 'null';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return formatObjectValue(value, seenValues);
|
|
36
|
-
|
|
37
|
-
default:
|
|
38
|
-
return String(value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function formatObjectValue(value, previouslySeenValues) {
|
|
43
|
-
if (previouslySeenValues.indexOf(value) !== -1) {
|
|
44
|
-
return '[Circular]';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var seenValues = [].concat(previouslySeenValues, [value]);
|
|
48
|
-
var customInspectFn = getCustomFn(value);
|
|
49
|
-
|
|
50
|
-
if (customInspectFn !== undefined) {
|
|
51
|
-
var customValue = customInspectFn.call(value); // check for infinite recursion
|
|
52
|
-
|
|
53
|
-
if (customValue !== value) {
|
|
54
|
-
return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
|
|
55
|
-
}
|
|
56
|
-
} else if (Array.isArray(value)) {
|
|
57
|
-
return formatArray(value, seenValues);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return formatObject(value, seenValues);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function formatObject(object, seenValues) {
|
|
64
|
-
var keys = Object.keys(object);
|
|
65
|
-
|
|
66
|
-
if (keys.length === 0) {
|
|
67
|
-
return '{}';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
71
|
-
return '[' + getObjectTag(object) + ']';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
var properties = keys.map(function (key) {
|
|
75
|
-
var value = formatValue(object[key], seenValues);
|
|
76
|
-
return key + ': ' + value;
|
|
77
|
-
});
|
|
78
|
-
return '{ ' + properties.join(', ') + ' }';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function formatArray(array, seenValues) {
|
|
82
|
-
if (array.length === 0) {
|
|
83
|
-
return '[]';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
87
|
-
return '[Array]';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
91
|
-
var remaining = array.length - len;
|
|
92
|
-
var items = [];
|
|
93
|
-
|
|
94
|
-
for (var i = 0; i < len; ++i) {
|
|
95
|
-
items.push(formatValue(array[i], seenValues));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (remaining === 1) {
|
|
99
|
-
items.push('... 1 more item');
|
|
100
|
-
} else if (remaining > 1) {
|
|
101
|
-
items.push("... ".concat(remaining, " more items"));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return '[' + items.join(', ') + ']';
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function getCustomFn(object) {
|
|
108
|
-
var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
|
|
109
|
-
|
|
110
|
-
if (typeof customInspectFn === 'function') {
|
|
111
|
-
return customInspectFn;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (typeof object.inspect === 'function') {
|
|
115
|
-
return object.inspect;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function getObjectTag(object) {
|
|
120
|
-
var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
|
|
121
|
-
|
|
122
|
-
if (tag === 'Object' && typeof object.constructor === 'function') {
|
|
123
|
-
var name = object.constructor.name;
|
|
124
|
-
|
|
125
|
-
if (typeof name === 'string' && name !== '') {
|
|
126
|
-
return name;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return tag;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function devAssert(condition, message) {
|
|
134
|
-
var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
|
|
135
|
-
|
|
136
|
-
if (!booleanCondition) {
|
|
137
|
-
throw new Error(message);
|
|
138
|
-
}
|
|
5
|
+
// eslint-disable-next-line no-redeclare
|
|
6
|
+
function isPromise(value) {
|
|
7
|
+
return typeof (value === null || value === void 0 ? void 0 : value.then) === 'function';
|
|
139
8
|
}
|
|
140
9
|
|
|
141
|
-
function _typeof$
|
|
142
|
-
/**
|
|
143
|
-
* A replacement for instanceof which includes an error warning when multi-realm
|
|
144
|
-
* constructors are detected.
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
|
|
148
|
-
// See: https://webpack.js.org/guides/production/
|
|
149
|
-
var instanceOf = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
150
|
-
// eslint-disable-next-line no-shadow
|
|
151
|
-
function instanceOf(value, constructor) {
|
|
152
|
-
return value instanceof constructor;
|
|
153
|
-
} : // eslint-disable-next-line no-shadow
|
|
154
|
-
function instanceOf(value, constructor) {
|
|
155
|
-
if (value instanceof constructor) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (_typeof$3(value) === 'object' && value !== null) {
|
|
160
|
-
var _value$constructor;
|
|
161
|
-
|
|
162
|
-
var className = constructor.prototype[Symbol.toStringTag];
|
|
163
|
-
var valueClassName = // We still need to support constructor's name to detect conflicts with older versions of this library.
|
|
164
|
-
Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name;
|
|
165
|
-
|
|
166
|
-
if (className === valueClassName) {
|
|
167
|
-
var stringifiedValue = inspect(value);
|
|
168
|
-
throw new Error("Cannot use ".concat(className, " \"").concat(stringifiedValue, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return false;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
function _defineProperties$4(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
176
|
-
|
|
177
|
-
function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
|
|
10
|
+
function _typeof$4(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$4 = function _typeof(obj) { return typeof obj; }; } else { _typeof$4 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$4(obj); }
|
|
178
11
|
|
|
179
12
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
|
|
183
|
-
* be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
|
|
184
|
-
* The `line` and `column` properties in `locationOffset` are 1-indexed.
|
|
13
|
+
* Return true if `value` is object-like. A value is object-like if it's not
|
|
14
|
+
* `null` and has a `typeof` result of "object".
|
|
185
15
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
190
|
-
line: 1,
|
|
191
|
-
column: 1
|
|
192
|
-
};
|
|
193
|
-
typeof body === 'string' || devAssert(0, "Body must be a string. Received: ".concat(inspect(body), "."));
|
|
194
|
-
this.body = body;
|
|
195
|
-
this.name = name;
|
|
196
|
-
this.locationOffset = locationOffset;
|
|
197
|
-
this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');
|
|
198
|
-
this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');
|
|
199
|
-
} // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
_createClass$4(Source, [{
|
|
203
|
-
key: SYMBOL_TO_STRING_TAG,
|
|
204
|
-
get: function get() {
|
|
205
|
-
return 'Source';
|
|
206
|
-
}
|
|
207
|
-
}]);
|
|
16
|
+
function isObjectLike(value) {
|
|
17
|
+
return _typeof$4(value) == 'object' && value !== null;
|
|
18
|
+
}
|
|
208
19
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
* Test if the given value is a Source object.
|
|
213
|
-
*
|
|
214
|
-
* @internal
|
|
215
|
-
*/
|
|
20
|
+
// In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
|
|
21
|
+
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
22
|
+
var SYMBOL_ITERATOR = typeof Symbol === 'function' && Symbol.iterator != null ? Symbol.iterator : '@@iterator'; // In ES2017 (or a polyfilled) environment, this will be Symbol.asyncIterator
|
|
216
23
|
|
|
217
|
-
|
|
218
|
-
function isSource(source) {
|
|
219
|
-
return instanceOf(source, Source);
|
|
220
|
-
}
|
|
24
|
+
var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag != null ? Symbol.toStringTag : '@@toStringTag';
|
|
221
25
|
|
|
222
26
|
/**
|
|
223
27
|
* Represents a location in a Source.
|
|
@@ -310,144 +114,39 @@ function leftPad(len, str) {
|
|
|
310
114
|
return whitespace(len - str.length) + str;
|
|
311
115
|
}
|
|
312
116
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
NON_NULL_TYPE: 'NonNullType',
|
|
347
|
-
// Type System Definitions
|
|
348
|
-
SCHEMA_DEFINITION: 'SchemaDefinition',
|
|
349
|
-
OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',
|
|
350
|
-
// Type Definitions
|
|
351
|
-
SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',
|
|
352
|
-
OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',
|
|
353
|
-
FIELD_DEFINITION: 'FieldDefinition',
|
|
354
|
-
INPUT_VALUE_DEFINITION: 'InputValueDefinition',
|
|
355
|
-
INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',
|
|
356
|
-
UNION_TYPE_DEFINITION: 'UnionTypeDefinition',
|
|
357
|
-
ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',
|
|
358
|
-
ENUM_VALUE_DEFINITION: 'EnumValueDefinition',
|
|
359
|
-
INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',
|
|
360
|
-
// Directive Definitions
|
|
361
|
-
DIRECTIVE_DEFINITION: 'DirectiveDefinition',
|
|
362
|
-
// Type System Extensions
|
|
363
|
-
SCHEMA_EXTENSION: 'SchemaExtension',
|
|
364
|
-
// Type Extensions
|
|
365
|
-
SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',
|
|
366
|
-
OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',
|
|
367
|
-
INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',
|
|
368
|
-
UNION_TYPE_EXTENSION: 'UnionTypeExtension',
|
|
369
|
-
ENUM_TYPE_EXTENSION: 'EnumTypeExtension',
|
|
370
|
-
INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'
|
|
371
|
-
});
|
|
372
|
-
/**
|
|
373
|
-
* The enum type representing the possible kind values of AST nodes.
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* An exported enum describing the different kinds of tokens that the
|
|
378
|
-
* lexer emits.
|
|
379
|
-
*/
|
|
380
|
-
var TokenKind = Object.freeze({
|
|
381
|
-
SOF: '<SOF>',
|
|
382
|
-
EOF: '<EOF>',
|
|
383
|
-
BANG: '!',
|
|
384
|
-
DOLLAR: '$',
|
|
385
|
-
AMP: '&',
|
|
386
|
-
PAREN_L: '(',
|
|
387
|
-
PAREN_R: ')',
|
|
388
|
-
SPREAD: '...',
|
|
389
|
-
COLON: ':',
|
|
390
|
-
EQUALS: '=',
|
|
391
|
-
AT: '@',
|
|
392
|
-
BRACKET_L: '[',
|
|
393
|
-
BRACKET_R: ']',
|
|
394
|
-
BRACE_L: '{',
|
|
395
|
-
PIPE: '|',
|
|
396
|
-
BRACE_R: '}',
|
|
397
|
-
NAME: 'Name',
|
|
398
|
-
INT: 'Int',
|
|
399
|
-
FLOAT: 'Float',
|
|
400
|
-
STRING: 'String',
|
|
401
|
-
BLOCK_STRING: 'BlockString',
|
|
402
|
-
COMMENT: 'Comment'
|
|
403
|
-
});
|
|
404
|
-
/**
|
|
405
|
-
* The enum type representing the token kinds values.
|
|
406
|
-
*/
|
|
407
|
-
|
|
408
|
-
function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Return true if `value` is object-like. A value is object-like if it's not
|
|
412
|
-
* `null` and has a `typeof` result of "object".
|
|
413
|
-
*/
|
|
414
|
-
function isObjectLike(value) {
|
|
415
|
-
return _typeof$2(value) == 'object' && value !== null;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
419
|
-
|
|
420
|
-
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
421
|
-
|
|
422
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty$4(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
423
|
-
|
|
424
|
-
function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
425
|
-
|
|
426
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
427
|
-
|
|
428
|
-
function _defineProperties$3(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
429
|
-
|
|
430
|
-
function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
|
|
431
|
-
|
|
432
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
433
|
-
|
|
434
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
435
|
-
|
|
436
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
437
|
-
|
|
438
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
439
|
-
|
|
440
|
-
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
441
|
-
|
|
442
|
-
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
443
|
-
|
|
444
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
445
|
-
|
|
446
|
-
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
447
|
-
|
|
448
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
449
|
-
|
|
450
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
117
|
+
function _typeof$3(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$3 = function _typeof(obj) { return typeof obj; }; } else { _typeof$3 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$3(obj); }
|
|
118
|
+
|
|
119
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
120
|
+
|
|
121
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty$4(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
122
|
+
|
|
123
|
+
function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
124
|
+
|
|
125
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
126
|
+
|
|
127
|
+
function _defineProperties$4(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
128
|
+
|
|
129
|
+
function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
|
|
130
|
+
|
|
131
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
132
|
+
|
|
133
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
134
|
+
|
|
135
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof$3(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
136
|
+
|
|
137
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
138
|
+
|
|
139
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
140
|
+
|
|
141
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
142
|
+
|
|
143
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
144
|
+
|
|
145
|
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
146
|
+
|
|
147
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
148
|
+
|
|
149
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
451
150
|
/**
|
|
452
151
|
* A GraphQLError describes an Error found during the parse, validate, or
|
|
453
152
|
* execute phases of performing a GraphQL operation. In addition to a message
|
|
@@ -601,7 +300,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
|
|
|
601
300
|
return _this;
|
|
602
301
|
}
|
|
603
302
|
|
|
604
|
-
_createClass$
|
|
303
|
+
_createClass$4(GraphQLError, [{
|
|
605
304
|
key: "toString",
|
|
606
305
|
value: function toString() {
|
|
607
306
|
return printError(this);
|
|
@@ -657,6 +356,69 @@ function syntaxError(source, position, description) {
|
|
|
657
356
|
return new GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
|
|
658
357
|
}
|
|
659
358
|
|
|
359
|
+
/**
|
|
360
|
+
* The set of allowed kind values for AST nodes.
|
|
361
|
+
*/
|
|
362
|
+
var Kind = Object.freeze({
|
|
363
|
+
// Name
|
|
364
|
+
NAME: 'Name',
|
|
365
|
+
// Document
|
|
366
|
+
DOCUMENT: 'Document',
|
|
367
|
+
OPERATION_DEFINITION: 'OperationDefinition',
|
|
368
|
+
VARIABLE_DEFINITION: 'VariableDefinition',
|
|
369
|
+
SELECTION_SET: 'SelectionSet',
|
|
370
|
+
FIELD: 'Field',
|
|
371
|
+
ARGUMENT: 'Argument',
|
|
372
|
+
// Fragments
|
|
373
|
+
FRAGMENT_SPREAD: 'FragmentSpread',
|
|
374
|
+
INLINE_FRAGMENT: 'InlineFragment',
|
|
375
|
+
FRAGMENT_DEFINITION: 'FragmentDefinition',
|
|
376
|
+
// Values
|
|
377
|
+
VARIABLE: 'Variable',
|
|
378
|
+
INT: 'IntValue',
|
|
379
|
+
FLOAT: 'FloatValue',
|
|
380
|
+
STRING: 'StringValue',
|
|
381
|
+
BOOLEAN: 'BooleanValue',
|
|
382
|
+
NULL: 'NullValue',
|
|
383
|
+
ENUM: 'EnumValue',
|
|
384
|
+
LIST: 'ListValue',
|
|
385
|
+
OBJECT: 'ObjectValue',
|
|
386
|
+
OBJECT_FIELD: 'ObjectField',
|
|
387
|
+
// Directives
|
|
388
|
+
DIRECTIVE: 'Directive',
|
|
389
|
+
// Types
|
|
390
|
+
NAMED_TYPE: 'NamedType',
|
|
391
|
+
LIST_TYPE: 'ListType',
|
|
392
|
+
NON_NULL_TYPE: 'NonNullType',
|
|
393
|
+
// Type System Definitions
|
|
394
|
+
SCHEMA_DEFINITION: 'SchemaDefinition',
|
|
395
|
+
OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',
|
|
396
|
+
// Type Definitions
|
|
397
|
+
SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',
|
|
398
|
+
OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',
|
|
399
|
+
FIELD_DEFINITION: 'FieldDefinition',
|
|
400
|
+
INPUT_VALUE_DEFINITION: 'InputValueDefinition',
|
|
401
|
+
INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',
|
|
402
|
+
UNION_TYPE_DEFINITION: 'UnionTypeDefinition',
|
|
403
|
+
ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',
|
|
404
|
+
ENUM_VALUE_DEFINITION: 'EnumValueDefinition',
|
|
405
|
+
INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',
|
|
406
|
+
// Directive Definitions
|
|
407
|
+
DIRECTIVE_DEFINITION: 'DirectiveDefinition',
|
|
408
|
+
// Type System Extensions
|
|
409
|
+
SCHEMA_EXTENSION: 'SchemaExtension',
|
|
410
|
+
// Type Extensions
|
|
411
|
+
SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',
|
|
412
|
+
OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',
|
|
413
|
+
INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',
|
|
414
|
+
UNION_TYPE_EXTENSION: 'UnionTypeExtension',
|
|
415
|
+
ENUM_TYPE_EXTENSION: 'EnumTypeExtension',
|
|
416
|
+
INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'
|
|
417
|
+
});
|
|
418
|
+
/**
|
|
419
|
+
* The enum type representing the possible kind values of AST nodes.
|
|
420
|
+
*/
|
|
421
|
+
|
|
660
422
|
function invariant(condition, message) {
|
|
661
423
|
var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
|
|
662
424
|
|
|
@@ -665,6 +427,10 @@ function invariant(condition, message) {
|
|
|
665
427
|
}
|
|
666
428
|
}
|
|
667
429
|
|
|
430
|
+
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
431
|
+
var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
|
|
432
|
+
var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
|
|
433
|
+
|
|
668
434
|
/**
|
|
669
435
|
* The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
|
|
670
436
|
*/
|
|
@@ -797,27 +563,300 @@ function isNode(maybeNode) {
|
|
|
797
563
|
*/
|
|
798
564
|
|
|
799
565
|
/**
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
566
|
+
* An exported enum describing the different kinds of tokens that the
|
|
567
|
+
* lexer emits.
|
|
568
|
+
*/
|
|
569
|
+
var TokenKind = Object.freeze({
|
|
570
|
+
SOF: '<SOF>',
|
|
571
|
+
EOF: '<EOF>',
|
|
572
|
+
BANG: '!',
|
|
573
|
+
DOLLAR: '$',
|
|
574
|
+
AMP: '&',
|
|
575
|
+
PAREN_L: '(',
|
|
576
|
+
PAREN_R: ')',
|
|
577
|
+
SPREAD: '...',
|
|
578
|
+
COLON: ':',
|
|
579
|
+
EQUALS: '=',
|
|
580
|
+
AT: '@',
|
|
581
|
+
BRACKET_L: '[',
|
|
582
|
+
BRACKET_R: ']',
|
|
583
|
+
BRACE_L: '{',
|
|
584
|
+
PIPE: '|',
|
|
585
|
+
BRACE_R: '}',
|
|
586
|
+
NAME: 'Name',
|
|
587
|
+
INT: 'Int',
|
|
588
|
+
FLOAT: 'Float',
|
|
589
|
+
STRING: 'String',
|
|
590
|
+
BLOCK_STRING: 'BlockString',
|
|
591
|
+
COMMENT: 'Comment'
|
|
592
|
+
});
|
|
593
|
+
/**
|
|
594
|
+
* The enum type representing the token kinds values.
|
|
806
595
|
*/
|
|
807
|
-
function dedentBlockStringValue(rawString) {
|
|
808
|
-
// Expand a block string's raw value into independent lines.
|
|
809
|
-
var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
|
|
810
|
-
|
|
811
|
-
var commonIndent = getBlockStringIndentation(rawString);
|
|
812
596
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
597
|
+
function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
|
|
598
|
+
var MAX_ARRAY_LENGTH = 10;
|
|
599
|
+
var MAX_RECURSIVE_DEPTH = 2;
|
|
600
|
+
/**
|
|
601
|
+
* Used to print values in error messages.
|
|
602
|
+
*/
|
|
818
603
|
|
|
604
|
+
function inspect(value) {
|
|
605
|
+
return formatValue(value, []);
|
|
606
|
+
}
|
|
819
607
|
|
|
820
|
-
|
|
608
|
+
function formatValue(value, seenValues) {
|
|
609
|
+
switch (_typeof$2(value)) {
|
|
610
|
+
case 'string':
|
|
611
|
+
return JSON.stringify(value);
|
|
612
|
+
|
|
613
|
+
case 'function':
|
|
614
|
+
return value.name ? "[function ".concat(value.name, "]") : '[function]';
|
|
615
|
+
|
|
616
|
+
case 'object':
|
|
617
|
+
if (value === null) {
|
|
618
|
+
return 'null';
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
return formatObjectValue(value, seenValues);
|
|
622
|
+
|
|
623
|
+
default:
|
|
624
|
+
return String(value);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function formatObjectValue(value, previouslySeenValues) {
|
|
629
|
+
if (previouslySeenValues.indexOf(value) !== -1) {
|
|
630
|
+
return '[Circular]';
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
var seenValues = [].concat(previouslySeenValues, [value]);
|
|
634
|
+
var customInspectFn = getCustomFn(value);
|
|
635
|
+
|
|
636
|
+
if (customInspectFn !== undefined) {
|
|
637
|
+
var customValue = customInspectFn.call(value); // check for infinite recursion
|
|
638
|
+
|
|
639
|
+
if (customValue !== value) {
|
|
640
|
+
return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
|
|
641
|
+
}
|
|
642
|
+
} else if (Array.isArray(value)) {
|
|
643
|
+
return formatArray(value, seenValues);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
return formatObject(value, seenValues);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function formatObject(object, seenValues) {
|
|
650
|
+
var keys = Object.keys(object);
|
|
651
|
+
|
|
652
|
+
if (keys.length === 0) {
|
|
653
|
+
return '{}';
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
657
|
+
return '[' + getObjectTag(object) + ']';
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
var properties = keys.map(function (key) {
|
|
661
|
+
var value = formatValue(object[key], seenValues);
|
|
662
|
+
return key + ': ' + value;
|
|
663
|
+
});
|
|
664
|
+
return '{ ' + properties.join(', ') + ' }';
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function formatArray(array, seenValues) {
|
|
668
|
+
if (array.length === 0) {
|
|
669
|
+
return '[]';
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
673
|
+
return '[Array]';
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
var len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
677
|
+
var remaining = array.length - len;
|
|
678
|
+
var items = [];
|
|
679
|
+
|
|
680
|
+
for (var i = 0; i < len; ++i) {
|
|
681
|
+
items.push(formatValue(array[i], seenValues));
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
if (remaining === 1) {
|
|
685
|
+
items.push('... 1 more item');
|
|
686
|
+
} else if (remaining > 1) {
|
|
687
|
+
items.push("... ".concat(remaining, " more items"));
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
return '[' + items.join(', ') + ']';
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
function getCustomFn(object) {
|
|
694
|
+
var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
|
|
695
|
+
|
|
696
|
+
if (typeof customInspectFn === 'function') {
|
|
697
|
+
return customInspectFn;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (typeof object.inspect === 'function') {
|
|
701
|
+
return object.inspect;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function getObjectTag(object) {
|
|
706
|
+
var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
|
|
707
|
+
|
|
708
|
+
if (tag === 'Object' && typeof object.constructor === 'function') {
|
|
709
|
+
var name = object.constructor.name;
|
|
710
|
+
|
|
711
|
+
if (typeof name === 'string' && name !== '') {
|
|
712
|
+
return name;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
return tag;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
function devAssert(condition, message) {
|
|
720
|
+
var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
|
|
721
|
+
|
|
722
|
+
if (!booleanCondition) {
|
|
723
|
+
throw new Error(message);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
728
|
+
/**
|
|
729
|
+
* A replacement for instanceof which includes an error warning when multi-realm
|
|
730
|
+
* constructors are detected.
|
|
731
|
+
*/
|
|
732
|
+
|
|
733
|
+
// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
|
|
734
|
+
// See: https://webpack.js.org/guides/production/
|
|
735
|
+
var instanceOf = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
736
|
+
// eslint-disable-next-line no-shadow
|
|
737
|
+
function instanceOf(value, constructor) {
|
|
738
|
+
return value instanceof constructor;
|
|
739
|
+
} : // eslint-disable-next-line no-shadow
|
|
740
|
+
function instanceOf(value, constructor) {
|
|
741
|
+
if (value instanceof constructor) {
|
|
742
|
+
return true;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
if (_typeof$1(value) === 'object' && value !== null) {
|
|
746
|
+
var _value$constructor;
|
|
747
|
+
|
|
748
|
+
var className = constructor.prototype[Symbol.toStringTag];
|
|
749
|
+
var valueClassName = // We still need to support constructor's name to detect conflicts with older versions of this library.
|
|
750
|
+
Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name;
|
|
751
|
+
|
|
752
|
+
if (className === valueClassName) {
|
|
753
|
+
var stringifiedValue = inspect(value);
|
|
754
|
+
throw new Error("Cannot use ".concat(className, " \"").concat(stringifiedValue, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
return false;
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
function _defineProperties$3(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
762
|
+
|
|
763
|
+
function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
|
|
767
|
+
* optional, but they are useful for clients who store GraphQL documents in source files.
|
|
768
|
+
* For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
|
|
769
|
+
* be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
|
|
770
|
+
* The `line` and `column` properties in `locationOffset` are 1-indexed.
|
|
771
|
+
*/
|
|
772
|
+
var Source = /*#__PURE__*/function () {
|
|
773
|
+
function Source(body) {
|
|
774
|
+
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GraphQL request';
|
|
775
|
+
var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
776
|
+
line: 1,
|
|
777
|
+
column: 1
|
|
778
|
+
};
|
|
779
|
+
typeof body === 'string' || devAssert(0, "Body must be a string. Received: ".concat(inspect(body), "."));
|
|
780
|
+
this.body = body;
|
|
781
|
+
this.name = name;
|
|
782
|
+
this.locationOffset = locationOffset;
|
|
783
|
+
this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');
|
|
784
|
+
this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');
|
|
785
|
+
} // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
_createClass$3(Source, [{
|
|
789
|
+
key: SYMBOL_TO_STRING_TAG,
|
|
790
|
+
get: function get() {
|
|
791
|
+
return 'Source';
|
|
792
|
+
}
|
|
793
|
+
}]);
|
|
794
|
+
|
|
795
|
+
return Source;
|
|
796
|
+
}();
|
|
797
|
+
/**
|
|
798
|
+
* Test if the given value is a Source object.
|
|
799
|
+
*
|
|
800
|
+
* @internal
|
|
801
|
+
*/
|
|
802
|
+
|
|
803
|
+
// eslint-disable-next-line no-redeclare
|
|
804
|
+
function isSource(source) {
|
|
805
|
+
return instanceOf(source, Source);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* The set of allowed directive location values.
|
|
810
|
+
*/
|
|
811
|
+
var DirectiveLocation = Object.freeze({
|
|
812
|
+
// Request Definitions
|
|
813
|
+
QUERY: 'QUERY',
|
|
814
|
+
MUTATION: 'MUTATION',
|
|
815
|
+
SUBSCRIPTION: 'SUBSCRIPTION',
|
|
816
|
+
FIELD: 'FIELD',
|
|
817
|
+
FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
|
|
818
|
+
FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
|
|
819
|
+
INLINE_FRAGMENT: 'INLINE_FRAGMENT',
|
|
820
|
+
VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',
|
|
821
|
+
// Type System Definitions
|
|
822
|
+
SCHEMA: 'SCHEMA',
|
|
823
|
+
SCALAR: 'SCALAR',
|
|
824
|
+
OBJECT: 'OBJECT',
|
|
825
|
+
FIELD_DEFINITION: 'FIELD_DEFINITION',
|
|
826
|
+
ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
|
|
827
|
+
INTERFACE: 'INTERFACE',
|
|
828
|
+
UNION: 'UNION',
|
|
829
|
+
ENUM: 'ENUM',
|
|
830
|
+
ENUM_VALUE: 'ENUM_VALUE',
|
|
831
|
+
INPUT_OBJECT: 'INPUT_OBJECT',
|
|
832
|
+
INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
|
|
833
|
+
});
|
|
834
|
+
/**
|
|
835
|
+
* The enum type representing the directive location values.
|
|
836
|
+
*/
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Produces the value of a block string from its parsed raw value, similar to
|
|
840
|
+
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
|
|
841
|
+
*
|
|
842
|
+
* This implements the GraphQL spec's BlockStringValue() static algorithm.
|
|
843
|
+
*
|
|
844
|
+
* @internal
|
|
845
|
+
*/
|
|
846
|
+
function dedentBlockStringValue(rawString) {
|
|
847
|
+
// Expand a block string's raw value into independent lines.
|
|
848
|
+
var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
|
|
849
|
+
|
|
850
|
+
var commonIndent = getBlockStringIndentation(rawString);
|
|
851
|
+
|
|
852
|
+
if (commonIndent !== 0) {
|
|
853
|
+
for (var i = 1; i < lines.length; i++) {
|
|
854
|
+
lines[i] = lines[i].slice(commonIndent);
|
|
855
|
+
}
|
|
856
|
+
} // Remove leading and trailing blank lines.
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
var startLine = 0;
|
|
821
860
|
|
|
822
861
|
while (startLine < lines.length && isBlank(lines[startLine])) {
|
|
823
862
|
++startLine;
|
|
@@ -1595,37 +1634,7 @@ function isNameStart(code) {
|
|
|
1595
1634
|
}
|
|
1596
1635
|
|
|
1597
1636
|
/**
|
|
1598
|
-
*
|
|
1599
|
-
*/
|
|
1600
|
-
var DirectiveLocation = Object.freeze({
|
|
1601
|
-
// Request Definitions
|
|
1602
|
-
QUERY: 'QUERY',
|
|
1603
|
-
MUTATION: 'MUTATION',
|
|
1604
|
-
SUBSCRIPTION: 'SUBSCRIPTION',
|
|
1605
|
-
FIELD: 'FIELD',
|
|
1606
|
-
FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
|
|
1607
|
-
FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
|
|
1608
|
-
INLINE_FRAGMENT: 'INLINE_FRAGMENT',
|
|
1609
|
-
VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',
|
|
1610
|
-
// Type System Definitions
|
|
1611
|
-
SCHEMA: 'SCHEMA',
|
|
1612
|
-
SCALAR: 'SCALAR',
|
|
1613
|
-
OBJECT: 'OBJECT',
|
|
1614
|
-
FIELD_DEFINITION: 'FIELD_DEFINITION',
|
|
1615
|
-
ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
|
|
1616
|
-
INTERFACE: 'INTERFACE',
|
|
1617
|
-
UNION: 'UNION',
|
|
1618
|
-
ENUM: 'ENUM',
|
|
1619
|
-
ENUM_VALUE: 'ENUM_VALUE',
|
|
1620
|
-
INPUT_OBJECT: 'INPUT_OBJECT',
|
|
1621
|
-
INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
|
|
1622
|
-
});
|
|
1623
|
-
/**
|
|
1624
|
-
* The enum type representing the directive location values.
|
|
1625
|
-
*/
|
|
1626
|
-
|
|
1627
|
-
/**
|
|
1628
|
-
* Configuration options to control parser behavior
|
|
1637
|
+
* Configuration options to control parser behavior
|
|
1629
1638
|
*/
|
|
1630
1639
|
|
|
1631
1640
|
/**
|
|
@@ -3511,738 +3520,713 @@ function getVisitFn(visitor, kind, isLeaving) {
|
|
|
3511
3520
|
}
|
|
3512
3521
|
}
|
|
3513
3522
|
|
|
3523
|
+
/* eslint-disable no-redeclare */
|
|
3524
|
+
// $FlowFixMe[name-already-bound]
|
|
3525
|
+
var find = Array.prototype.find ? function (list, predicate) {
|
|
3526
|
+
return Array.prototype.find.call(list, predicate);
|
|
3527
|
+
} : function (list, predicate) {
|
|
3528
|
+
for (var _i2 = 0; _i2 < list.length; _i2++) {
|
|
3529
|
+
var value = list[_i2];
|
|
3530
|
+
|
|
3531
|
+
if (predicate(value)) {
|
|
3532
|
+
return value;
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
};
|
|
3536
|
+
var find$1 = find;
|
|
3537
|
+
|
|
3538
|
+
/* eslint-disable no-redeclare */
|
|
3539
|
+
// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
|
|
3540
|
+
var objectValues = Object.values || function (obj) {
|
|
3541
|
+
return Object.keys(obj).map(function (key) {
|
|
3542
|
+
return obj[key];
|
|
3543
|
+
});
|
|
3544
|
+
};
|
|
3545
|
+
|
|
3546
|
+
var objectValues$1 = objectValues;
|
|
3547
|
+
|
|
3514
3548
|
/**
|
|
3515
|
-
*
|
|
3516
|
-
*
|
|
3549
|
+
* Given an arbitrary value, presumably thrown while attempting to execute a
|
|
3550
|
+
* GraphQL operation, produce a new GraphQLError aware of the location in the
|
|
3551
|
+
* document responsible for the original Error.
|
|
3517
3552
|
*/
|
|
3518
3553
|
|
|
3519
|
-
function
|
|
3520
|
-
|
|
3521
|
-
|
|
3554
|
+
function locatedError(rawOriginalError, nodes, path) {
|
|
3555
|
+
var _nodes;
|
|
3556
|
+
|
|
3557
|
+
// Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.
|
|
3558
|
+
var originalError = rawOriginalError instanceof Error ? rawOriginalError : new Error('Unexpected error value: ' + inspect(rawOriginalError)); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.
|
|
3559
|
+
|
|
3560
|
+
if (Array.isArray(originalError.path)) {
|
|
3561
|
+
return originalError;
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
return new GraphQLError(originalError.message, (_nodes = originalError.nodes) !== null && _nodes !== void 0 ? _nodes : nodes, originalError.source, originalError.positions, path, originalError);
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
3568
|
+
/**
|
|
3569
|
+
* Returns an Error if a name is invalid.
|
|
3570
|
+
*/
|
|
3571
|
+
|
|
3572
|
+
function isValidNameError(name) {
|
|
3573
|
+
typeof name === 'string' || devAssert(0, 'Expected name to be a string.');
|
|
3574
|
+
|
|
3575
|
+
if (name.length > 1 && name[0] === '_' && name[1] === '_') {
|
|
3576
|
+
return new GraphQLError("Name \"".concat(name, "\" must not begin with \"__\", which is reserved by GraphQL introspection."));
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
if (!NAME_RX.test(name)) {
|
|
3580
|
+
return new GraphQLError("Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"".concat(name, "\" does not."));
|
|
3581
|
+
}
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
/* eslint-disable no-redeclare */
|
|
3585
|
+
// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
|
|
3586
|
+
var objectEntries = Object.entries || function (obj) {
|
|
3587
|
+
return Object.keys(obj).map(function (key) {
|
|
3588
|
+
return [key, obj[key]];
|
|
3522
3589
|
});
|
|
3590
|
+
};
|
|
3591
|
+
|
|
3592
|
+
var objectEntries$1 = objectEntries;
|
|
3593
|
+
|
|
3594
|
+
/**
|
|
3595
|
+
* Creates a keyed JS object from an array, given a function to produce the keys
|
|
3596
|
+
* for each value in the array.
|
|
3597
|
+
*
|
|
3598
|
+
* This provides a convenient lookup for the array items if the key function
|
|
3599
|
+
* produces unique results.
|
|
3600
|
+
*
|
|
3601
|
+
* const phoneBook = [
|
|
3602
|
+
* { name: 'Jon', num: '555-1234' },
|
|
3603
|
+
* { name: 'Jenny', num: '867-5309' }
|
|
3604
|
+
* ]
|
|
3605
|
+
*
|
|
3606
|
+
* // { Jon: { name: 'Jon', num: '555-1234' },
|
|
3607
|
+
* // Jenny: { name: 'Jenny', num: '867-5309' } }
|
|
3608
|
+
* const entriesByName = keyMap(
|
|
3609
|
+
* phoneBook,
|
|
3610
|
+
* entry => entry.name
|
|
3611
|
+
* )
|
|
3612
|
+
*
|
|
3613
|
+
* // { name: 'Jenny', num: '857-6309' }
|
|
3614
|
+
* const jennyEntry = entriesByName['Jenny']
|
|
3615
|
+
*
|
|
3616
|
+
*/
|
|
3617
|
+
function keyMap(list, keyFn) {
|
|
3618
|
+
return list.reduce(function (map, item) {
|
|
3619
|
+
map[keyFn(item)] = item;
|
|
3620
|
+
return map;
|
|
3621
|
+
}, Object.create(null));
|
|
3523
3622
|
}
|
|
3524
|
-
var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future
|
|
3525
3623
|
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
},
|
|
3533
|
-
// Document
|
|
3534
|
-
Document: function Document(node) {
|
|
3535
|
-
return join(node.definitions, '\n\n') + '\n';
|
|
3536
|
-
},
|
|
3537
|
-
OperationDefinition: function OperationDefinition(node) {
|
|
3538
|
-
var op = node.operation;
|
|
3539
|
-
var name = node.name;
|
|
3540
|
-
var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
|
|
3541
|
-
var directives = join(node.directives, ' ');
|
|
3542
|
-
var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
|
|
3543
|
-
// the query short form.
|
|
3624
|
+
/**
|
|
3625
|
+
* Creates an object map with the same keys as `map` and values generated by
|
|
3626
|
+
* running each value of `map` thru `fn`.
|
|
3627
|
+
*/
|
|
3628
|
+
function mapValue(map, fn) {
|
|
3629
|
+
var result = Object.create(null);
|
|
3544
3630
|
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
var
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
directives = _ref.directives;
|
|
3552
|
-
return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
|
|
3553
|
-
},
|
|
3554
|
-
SelectionSet: function SelectionSet(_ref2) {
|
|
3555
|
-
var selections = _ref2.selections;
|
|
3556
|
-
return block(selections);
|
|
3557
|
-
},
|
|
3558
|
-
Field: function Field(_ref3) {
|
|
3559
|
-
var alias = _ref3.alias,
|
|
3560
|
-
name = _ref3.name,
|
|
3561
|
-
args = _ref3.arguments,
|
|
3562
|
-
directives = _ref3.directives,
|
|
3563
|
-
selectionSet = _ref3.selectionSet;
|
|
3564
|
-
var prefix = wrap('', alias, ': ') + name;
|
|
3565
|
-
var argsLine = prefix + wrap('(', join(args, ', '), ')');
|
|
3631
|
+
for (var _i2 = 0, _objectEntries2 = objectEntries$1(map); _i2 < _objectEntries2.length; _i2++) {
|
|
3632
|
+
var _ref2 = _objectEntries2[_i2];
|
|
3633
|
+
var _key = _ref2[0];
|
|
3634
|
+
var _value = _ref2[1];
|
|
3635
|
+
result[_key] = fn(_value, _key);
|
|
3636
|
+
}
|
|
3566
3637
|
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
}
|
|
3638
|
+
return result;
|
|
3639
|
+
}
|
|
3570
3640
|
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
value = _ref4.value;
|
|
3576
|
-
return name + ': ' + value;
|
|
3577
|
-
},
|
|
3578
|
-
// Fragments
|
|
3579
|
-
FragmentSpread: function FragmentSpread(_ref5) {
|
|
3580
|
-
var name = _ref5.name,
|
|
3581
|
-
directives = _ref5.directives;
|
|
3582
|
-
return '...' + name + wrap(' ', join(directives, ' '));
|
|
3583
|
-
},
|
|
3584
|
-
InlineFragment: function InlineFragment(_ref6) {
|
|
3585
|
-
var typeCondition = _ref6.typeCondition,
|
|
3586
|
-
directives = _ref6.directives,
|
|
3587
|
-
selectionSet = _ref6.selectionSet;
|
|
3588
|
-
return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
|
|
3589
|
-
},
|
|
3590
|
-
FragmentDefinition: function FragmentDefinition(_ref7) {
|
|
3591
|
-
var name = _ref7.name,
|
|
3592
|
-
typeCondition = _ref7.typeCondition,
|
|
3593
|
-
variableDefinitions = _ref7.variableDefinitions,
|
|
3594
|
-
directives = _ref7.directives,
|
|
3595
|
-
selectionSet = _ref7.selectionSet;
|
|
3596
|
-
return (// Note: fragment variable definitions are experimental and may be changed
|
|
3597
|
-
// or removed in the future.
|
|
3598
|
-
"fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
|
|
3599
|
-
);
|
|
3600
|
-
},
|
|
3601
|
-
// Value
|
|
3602
|
-
IntValue: function IntValue(_ref8) {
|
|
3603
|
-
var value = _ref8.value;
|
|
3604
|
-
return value;
|
|
3605
|
-
},
|
|
3606
|
-
FloatValue: function FloatValue(_ref9) {
|
|
3607
|
-
var value = _ref9.value;
|
|
3608
|
-
return value;
|
|
3609
|
-
},
|
|
3610
|
-
StringValue: function StringValue(_ref10, key) {
|
|
3611
|
-
var value = _ref10.value,
|
|
3612
|
-
isBlockString = _ref10.block;
|
|
3613
|
-
return isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
|
|
3614
|
-
},
|
|
3615
|
-
BooleanValue: function BooleanValue(_ref11) {
|
|
3616
|
-
var value = _ref11.value;
|
|
3617
|
-
return value ? 'true' : 'false';
|
|
3618
|
-
},
|
|
3619
|
-
NullValue: function NullValue() {
|
|
3620
|
-
return 'null';
|
|
3621
|
-
},
|
|
3622
|
-
EnumValue: function EnumValue(_ref12) {
|
|
3623
|
-
var value = _ref12.value;
|
|
3624
|
-
return value;
|
|
3625
|
-
},
|
|
3626
|
-
ListValue: function ListValue(_ref13) {
|
|
3627
|
-
var values = _ref13.values;
|
|
3628
|
-
return '[' + join(values, ', ') + ']';
|
|
3629
|
-
},
|
|
3630
|
-
ObjectValue: function ObjectValue(_ref14) {
|
|
3631
|
-
var fields = _ref14.fields;
|
|
3632
|
-
return '{' + join(fields, ', ') + '}';
|
|
3633
|
-
},
|
|
3634
|
-
ObjectField: function ObjectField(_ref15) {
|
|
3635
|
-
var name = _ref15.name,
|
|
3636
|
-
value = _ref15.value;
|
|
3637
|
-
return name + ': ' + value;
|
|
3638
|
-
},
|
|
3639
|
-
// Directive
|
|
3640
|
-
Directive: function Directive(_ref16) {
|
|
3641
|
-
var name = _ref16.name,
|
|
3642
|
-
args = _ref16.arguments;
|
|
3643
|
-
return '@' + name + wrap('(', join(args, ', '), ')');
|
|
3644
|
-
},
|
|
3645
|
-
// Type
|
|
3646
|
-
NamedType: function NamedType(_ref17) {
|
|
3647
|
-
var name = _ref17.name;
|
|
3648
|
-
return name;
|
|
3649
|
-
},
|
|
3650
|
-
ListType: function ListType(_ref18) {
|
|
3651
|
-
var type = _ref18.type;
|
|
3652
|
-
return '[' + type + ']';
|
|
3653
|
-
},
|
|
3654
|
-
NonNullType: function NonNullType(_ref19) {
|
|
3655
|
-
var type = _ref19.type;
|
|
3656
|
-
return type + '!';
|
|
3657
|
-
},
|
|
3658
|
-
// Type System Definitions
|
|
3659
|
-
SchemaDefinition: addDescription(function (_ref20) {
|
|
3660
|
-
var directives = _ref20.directives,
|
|
3661
|
-
operationTypes = _ref20.operationTypes;
|
|
3662
|
-
return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
3663
|
-
}),
|
|
3664
|
-
OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
|
|
3665
|
-
var operation = _ref21.operation,
|
|
3666
|
-
type = _ref21.type;
|
|
3667
|
-
return operation + ': ' + type;
|
|
3668
|
-
},
|
|
3669
|
-
ScalarTypeDefinition: addDescription(function (_ref22) {
|
|
3670
|
-
var name = _ref22.name,
|
|
3671
|
-
directives = _ref22.directives;
|
|
3672
|
-
return join(['scalar', name, join(directives, ' ')], ' ');
|
|
3673
|
-
}),
|
|
3674
|
-
ObjectTypeDefinition: addDescription(function (_ref23) {
|
|
3675
|
-
var name = _ref23.name,
|
|
3676
|
-
interfaces = _ref23.interfaces,
|
|
3677
|
-
directives = _ref23.directives,
|
|
3678
|
-
fields = _ref23.fields;
|
|
3679
|
-
return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
3680
|
-
}),
|
|
3681
|
-
FieldDefinition: addDescription(function (_ref24) {
|
|
3682
|
-
var name = _ref24.name,
|
|
3683
|
-
args = _ref24.arguments,
|
|
3684
|
-
type = _ref24.type,
|
|
3685
|
-
directives = _ref24.directives;
|
|
3686
|
-
return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
|
|
3687
|
-
}),
|
|
3688
|
-
InputValueDefinition: addDescription(function (_ref25) {
|
|
3689
|
-
var name = _ref25.name,
|
|
3690
|
-
type = _ref25.type,
|
|
3691
|
-
defaultValue = _ref25.defaultValue,
|
|
3692
|
-
directives = _ref25.directives;
|
|
3693
|
-
return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
|
|
3694
|
-
}),
|
|
3695
|
-
InterfaceTypeDefinition: addDescription(function (_ref26) {
|
|
3696
|
-
var name = _ref26.name,
|
|
3697
|
-
interfaces = _ref26.interfaces,
|
|
3698
|
-
directives = _ref26.directives,
|
|
3699
|
-
fields = _ref26.fields;
|
|
3700
|
-
return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
3701
|
-
}),
|
|
3702
|
-
UnionTypeDefinition: addDescription(function (_ref27) {
|
|
3703
|
-
var name = _ref27.name,
|
|
3704
|
-
directives = _ref27.directives,
|
|
3705
|
-
types = _ref27.types;
|
|
3706
|
-
return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
|
|
3707
|
-
}),
|
|
3708
|
-
EnumTypeDefinition: addDescription(function (_ref28) {
|
|
3709
|
-
var name = _ref28.name,
|
|
3710
|
-
directives = _ref28.directives,
|
|
3711
|
-
values = _ref28.values;
|
|
3712
|
-
return join(['enum', name, join(directives, ' '), block(values)], ' ');
|
|
3713
|
-
}),
|
|
3714
|
-
EnumValueDefinition: addDescription(function (_ref29) {
|
|
3715
|
-
var name = _ref29.name,
|
|
3716
|
-
directives = _ref29.directives;
|
|
3717
|
-
return join([name, join(directives, ' ')], ' ');
|
|
3718
|
-
}),
|
|
3719
|
-
InputObjectTypeDefinition: addDescription(function (_ref30) {
|
|
3720
|
-
var name = _ref30.name,
|
|
3721
|
-
directives = _ref30.directives,
|
|
3722
|
-
fields = _ref30.fields;
|
|
3723
|
-
return join(['input', name, join(directives, ' '), block(fields)], ' ');
|
|
3724
|
-
}),
|
|
3725
|
-
DirectiveDefinition: addDescription(function (_ref31) {
|
|
3726
|
-
var name = _ref31.name,
|
|
3727
|
-
args = _ref31.arguments,
|
|
3728
|
-
repeatable = _ref31.repeatable,
|
|
3729
|
-
locations = _ref31.locations;
|
|
3730
|
-
return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ');
|
|
3731
|
-
}),
|
|
3732
|
-
SchemaExtension: function SchemaExtension(_ref32) {
|
|
3733
|
-
var directives = _ref32.directives,
|
|
3734
|
-
operationTypes = _ref32.operationTypes;
|
|
3735
|
-
return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
3736
|
-
},
|
|
3737
|
-
ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
|
|
3738
|
-
var name = _ref33.name,
|
|
3739
|
-
directives = _ref33.directives;
|
|
3740
|
-
return join(['extend scalar', name, join(directives, ' ')], ' ');
|
|
3741
|
-
},
|
|
3742
|
-
ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
|
|
3743
|
-
var name = _ref34.name,
|
|
3744
|
-
interfaces = _ref34.interfaces,
|
|
3745
|
-
directives = _ref34.directives,
|
|
3746
|
-
fields = _ref34.fields;
|
|
3747
|
-
return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
3748
|
-
},
|
|
3749
|
-
InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
|
|
3750
|
-
var name = _ref35.name,
|
|
3751
|
-
interfaces = _ref35.interfaces,
|
|
3752
|
-
directives = _ref35.directives,
|
|
3753
|
-
fields = _ref35.fields;
|
|
3754
|
-
return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
3755
|
-
},
|
|
3756
|
-
UnionTypeExtension: function UnionTypeExtension(_ref36) {
|
|
3757
|
-
var name = _ref36.name,
|
|
3758
|
-
directives = _ref36.directives,
|
|
3759
|
-
types = _ref36.types;
|
|
3760
|
-
return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
|
|
3761
|
-
},
|
|
3762
|
-
EnumTypeExtension: function EnumTypeExtension(_ref37) {
|
|
3763
|
-
var name = _ref37.name,
|
|
3764
|
-
directives = _ref37.directives,
|
|
3765
|
-
values = _ref37.values;
|
|
3766
|
-
return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
|
|
3767
|
-
},
|
|
3768
|
-
InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
|
|
3769
|
-
var name = _ref38.name,
|
|
3770
|
-
directives = _ref38.directives,
|
|
3771
|
-
fields = _ref38.fields;
|
|
3772
|
-
return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
|
|
3641
|
+
function toObjMap(obj) {
|
|
3642
|
+
/* eslint-enable no-redeclare */
|
|
3643
|
+
if (Object.getPrototypeOf(obj) === null) {
|
|
3644
|
+
return obj;
|
|
3773
3645
|
}
|
|
3774
|
-
};
|
|
3775
|
-
|
|
3776
|
-
function addDescription(cb) {
|
|
3777
|
-
return function (node) {
|
|
3778
|
-
return join([node.description, cb(node)], '\n');
|
|
3779
|
-
};
|
|
3780
|
-
}
|
|
3781
|
-
/**
|
|
3782
|
-
* Given maybeArray, print an empty string if it is null or empty, otherwise
|
|
3783
|
-
* print all items together separated by separator if provided
|
|
3784
|
-
*/
|
|
3785
3646
|
|
|
3647
|
+
var map = Object.create(null);
|
|
3786
3648
|
|
|
3787
|
-
|
|
3788
|
-
|
|
3649
|
+
for (var _i2 = 0, _objectEntries2 = objectEntries$1(obj); _i2 < _objectEntries2.length; _i2++) {
|
|
3650
|
+
var _ref2 = _objectEntries2[_i2];
|
|
3651
|
+
var key = _ref2[0];
|
|
3652
|
+
var value = _ref2[1];
|
|
3653
|
+
map[key] = value;
|
|
3654
|
+
}
|
|
3789
3655
|
|
|
3790
|
-
|
|
3791
|
-
return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter(function (x) {
|
|
3792
|
-
return x;
|
|
3793
|
-
}).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : '';
|
|
3656
|
+
return map;
|
|
3794
3657
|
}
|
|
3658
|
+
|
|
3795
3659
|
/**
|
|
3796
|
-
*
|
|
3797
|
-
*
|
|
3660
|
+
* Creates a keyed JS object from an array, given a function to produce the keys
|
|
3661
|
+
* and a function to produce the values from each item in the array.
|
|
3662
|
+
*
|
|
3663
|
+
* const phoneBook = [
|
|
3664
|
+
* { name: 'Jon', num: '555-1234' },
|
|
3665
|
+
* { name: 'Jenny', num: '867-5309' }
|
|
3666
|
+
* ]
|
|
3667
|
+
*
|
|
3668
|
+
* // { Jon: '555-1234', Jenny: '867-5309' }
|
|
3669
|
+
* const phonesByName = keyValMap(
|
|
3670
|
+
* phoneBook,
|
|
3671
|
+
* entry => entry.name,
|
|
3672
|
+
* entry => entry.num
|
|
3673
|
+
* )
|
|
3674
|
+
*
|
|
3798
3675
|
*/
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3676
|
+
function keyValMap(list, keyFn, valFn) {
|
|
3677
|
+
return list.reduce(function (map, item) {
|
|
3678
|
+
map[keyFn(item)] = valFn(item);
|
|
3679
|
+
return map;
|
|
3680
|
+
}, Object.create(null));
|
|
3803
3681
|
}
|
|
3682
|
+
|
|
3683
|
+
var MAX_SUGGESTIONS = 5;
|
|
3804
3684
|
/**
|
|
3805
|
-
*
|
|
3685
|
+
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
|
|
3806
3686
|
*/
|
|
3807
3687
|
|
|
3688
|
+
// eslint-disable-next-line no-redeclare
|
|
3689
|
+
function didYouMean(firstArg, secondArg) {
|
|
3690
|
+
var _ref = typeof firstArg === 'string' ? [firstArg, secondArg] : [undefined, firstArg],
|
|
3691
|
+
subMessage = _ref[0],
|
|
3692
|
+
suggestionsArg = _ref[1];
|
|
3693
|
+
|
|
3694
|
+
var message = ' Did you mean ';
|
|
3808
3695
|
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
}
|
|
3696
|
+
if (subMessage) {
|
|
3697
|
+
message += subMessage + ' ';
|
|
3698
|
+
}
|
|
3813
3699
|
|
|
3814
|
-
function
|
|
3815
|
-
|
|
3816
|
-
}
|
|
3700
|
+
var suggestions = suggestionsArg.map(function (x) {
|
|
3701
|
+
return "\"".concat(x, "\"");
|
|
3702
|
+
});
|
|
3817
3703
|
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3704
|
+
switch (suggestions.length) {
|
|
3705
|
+
case 0:
|
|
3706
|
+
return '';
|
|
3821
3707
|
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
}
|
|
3708
|
+
case 1:
|
|
3709
|
+
return message + suggestions[0] + '?';
|
|
3825
3710
|
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
}
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
return node.kind === Kind.SCALAR_TYPE_DEFINITION || node.kind === Kind.OBJECT_TYPE_DEFINITION || node.kind === Kind.INTERFACE_TYPE_DEFINITION || node.kind === Kind.UNION_TYPE_DEFINITION || node.kind === Kind.ENUM_TYPE_DEFINITION || node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION;
|
|
3834
|
-
}
|
|
3835
|
-
function isTypeSystemExtensionNode(node) {
|
|
3836
|
-
return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
|
|
3837
|
-
}
|
|
3838
|
-
function isTypeExtensionNode(node) {
|
|
3839
|
-
return node.kind === Kind.SCALAR_TYPE_EXTENSION || node.kind === Kind.OBJECT_TYPE_EXTENSION || node.kind === Kind.INTERFACE_TYPE_EXTENSION || node.kind === Kind.UNION_TYPE_EXTENSION || node.kind === Kind.ENUM_TYPE_EXTENSION || node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;
|
|
3711
|
+
case 2:
|
|
3712
|
+
return message + suggestions[0] + ' or ' + suggestions[1] + '?';
|
|
3713
|
+
}
|
|
3714
|
+
|
|
3715
|
+
var selected = suggestions.slice(0, MAX_SUGGESTIONS);
|
|
3716
|
+
var lastItem = selected.pop();
|
|
3717
|
+
return message + selected.join(', ') + ', or ' + lastItem + '?';
|
|
3840
3718
|
}
|
|
3841
3719
|
|
|
3842
3720
|
/**
|
|
3843
|
-
* Returns
|
|
3844
|
-
* otherwise returns false.
|
|
3721
|
+
* Returns the first argument it receives.
|
|
3845
3722
|
*/
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
return typeof (value === null || value === void 0 ? void 0 : value.then) === 'function';
|
|
3723
|
+
function identityFunc(x) {
|
|
3724
|
+
return x;
|
|
3849
3725
|
}
|
|
3850
3726
|
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
}
|
|
3862
|
-
}
|
|
3863
|
-
};
|
|
3864
|
-
var find$1 = find;
|
|
3727
|
+
/**
|
|
3728
|
+
* Returns a number indicating whether a reference string comes before, or after,
|
|
3729
|
+
* or is the same as the given string in natural sort order.
|
|
3730
|
+
*
|
|
3731
|
+
* See: https://en.wikipedia.org/wiki/Natural_sort_order
|
|
3732
|
+
*
|
|
3733
|
+
*/
|
|
3734
|
+
function naturalCompare(aStr, bStr) {
|
|
3735
|
+
var aIdx = 0;
|
|
3736
|
+
var bIdx = 0;
|
|
3865
3737
|
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
var
|
|
3869
|
-
return Object.keys(obj).map(function (key) {
|
|
3870
|
-
return obj[key];
|
|
3871
|
-
});
|
|
3872
|
-
};
|
|
3738
|
+
while (aIdx < aStr.length && bIdx < bStr.length) {
|
|
3739
|
+
var aChar = aStr.charCodeAt(aIdx);
|
|
3740
|
+
var bChar = bStr.charCodeAt(bIdx);
|
|
3873
3741
|
|
|
3874
|
-
|
|
3742
|
+
if (isDigit(aChar) && isDigit(bChar)) {
|
|
3743
|
+
var aNum = 0;
|
|
3875
3744
|
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3745
|
+
do {
|
|
3746
|
+
++aIdx;
|
|
3747
|
+
aNum = aNum * 10 + aChar - DIGIT_0;
|
|
3748
|
+
aChar = aStr.charCodeAt(aIdx);
|
|
3749
|
+
} while (isDigit(aChar) && aNum > 0);
|
|
3881
3750
|
|
|
3882
|
-
|
|
3883
|
-
var _nodes;
|
|
3751
|
+
var bNum = 0;
|
|
3884
3752
|
|
|
3885
|
-
|
|
3886
|
-
|
|
3753
|
+
do {
|
|
3754
|
+
++bIdx;
|
|
3755
|
+
bNum = bNum * 10 + bChar - DIGIT_0;
|
|
3756
|
+
bChar = bStr.charCodeAt(bIdx);
|
|
3757
|
+
} while (isDigit(bChar) && bNum > 0);
|
|
3887
3758
|
|
|
3888
|
-
|
|
3889
|
-
|
|
3759
|
+
if (aNum < bNum) {
|
|
3760
|
+
return -1;
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
if (aNum > bNum) {
|
|
3764
|
+
return 1;
|
|
3765
|
+
}
|
|
3766
|
+
} else {
|
|
3767
|
+
if (aChar < bChar) {
|
|
3768
|
+
return -1;
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
if (aChar > bChar) {
|
|
3772
|
+
return 1;
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
++aIdx;
|
|
3776
|
+
++bIdx;
|
|
3777
|
+
}
|
|
3890
3778
|
}
|
|
3891
3779
|
|
|
3892
|
-
return
|
|
3780
|
+
return aStr.length - bStr.length;
|
|
3781
|
+
}
|
|
3782
|
+
var DIGIT_0 = 48;
|
|
3783
|
+
var DIGIT_9 = 57;
|
|
3784
|
+
|
|
3785
|
+
function isDigit(code) {
|
|
3786
|
+
return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;
|
|
3893
3787
|
}
|
|
3894
3788
|
|
|
3895
|
-
var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
3896
3789
|
/**
|
|
3897
|
-
*
|
|
3790
|
+
* Given an invalid input string and a list of valid options, returns a filtered
|
|
3791
|
+
* list of valid options sorted based on their similarity with the input.
|
|
3898
3792
|
*/
|
|
3899
3793
|
|
|
3900
|
-
function
|
|
3901
|
-
|
|
3794
|
+
function suggestionList(input, options) {
|
|
3795
|
+
var optionsByDistance = Object.create(null);
|
|
3796
|
+
var lexicalDistance = new LexicalDistance(input);
|
|
3797
|
+
var threshold = Math.floor(input.length * 0.4) + 1;
|
|
3902
3798
|
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3799
|
+
for (var _i2 = 0; _i2 < options.length; _i2++) {
|
|
3800
|
+
var option = options[_i2];
|
|
3801
|
+
var distance = lexicalDistance.measure(option, threshold);
|
|
3906
3802
|
|
|
3907
|
-
|
|
3908
|
-
|
|
3803
|
+
if (distance !== undefined) {
|
|
3804
|
+
optionsByDistance[option] = distance;
|
|
3805
|
+
}
|
|
3909
3806
|
}
|
|
3910
|
-
}
|
|
3911
3807
|
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
return Object.keys(obj).map(function (key) {
|
|
3916
|
-
return [key, obj[key]];
|
|
3808
|
+
return Object.keys(optionsByDistance).sort(function (a, b) {
|
|
3809
|
+
var distanceDiff = optionsByDistance[a] - optionsByDistance[b];
|
|
3810
|
+
return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b);
|
|
3917
3811
|
});
|
|
3918
|
-
}
|
|
3919
|
-
|
|
3920
|
-
var objectEntries$1 = objectEntries;
|
|
3921
|
-
|
|
3812
|
+
}
|
|
3922
3813
|
/**
|
|
3923
|
-
*
|
|
3924
|
-
* for each value in the array.
|
|
3925
|
-
*
|
|
3926
|
-
* This provides a convenient lookup for the array items if the key function
|
|
3927
|
-
* produces unique results.
|
|
3928
|
-
*
|
|
3929
|
-
* const phoneBook = [
|
|
3930
|
-
* { name: 'Jon', num: '555-1234' },
|
|
3931
|
-
* { name: 'Jenny', num: '867-5309' }
|
|
3932
|
-
* ]
|
|
3814
|
+
* Computes the lexical distance between strings A and B.
|
|
3933
3815
|
*
|
|
3934
|
-
*
|
|
3935
|
-
*
|
|
3936
|
-
*
|
|
3937
|
-
*
|
|
3938
|
-
* entry => entry.name
|
|
3939
|
-
* )
|
|
3816
|
+
* The "distance" between two strings is given by counting the minimum number
|
|
3817
|
+
* of edits needed to transform string A into string B. An edit can be an
|
|
3818
|
+
* insertion, deletion, or substitution of a single character, or a swap of two
|
|
3819
|
+
* adjacent characters.
|
|
3940
3820
|
*
|
|
3941
|
-
*
|
|
3942
|
-
*
|
|
3821
|
+
* Includes a custom alteration from Damerau-Levenshtein to treat case changes
|
|
3822
|
+
* as a single edit which helps identify mis-cased values with an edit distance
|
|
3823
|
+
* of 1.
|
|
3943
3824
|
*
|
|
3825
|
+
* This distance can be useful for detecting typos in input or sorting
|
|
3944
3826
|
*/
|
|
3945
|
-
function keyMap(list, keyFn) {
|
|
3946
|
-
return list.reduce(function (map, item) {
|
|
3947
|
-
map[keyFn(item)] = item;
|
|
3948
|
-
return map;
|
|
3949
|
-
}, Object.create(null));
|
|
3950
|
-
}
|
|
3951
|
-
|
|
3952
|
-
/**
|
|
3953
|
-
* Creates an object map with the same keys as `map` and values generated by
|
|
3954
|
-
* running each value of `map` thru `fn`.
|
|
3955
|
-
*/
|
|
3956
|
-
function mapValue(map, fn) {
|
|
3957
|
-
var result = Object.create(null);
|
|
3958
|
-
|
|
3959
|
-
for (var _i2 = 0, _objectEntries2 = objectEntries$1(map); _i2 < _objectEntries2.length; _i2++) {
|
|
3960
|
-
var _ref2 = _objectEntries2[_i2];
|
|
3961
|
-
var _key = _ref2[0];
|
|
3962
|
-
var _value = _ref2[1];
|
|
3963
|
-
result[_key] = fn(_value, _key);
|
|
3964
|
-
}
|
|
3965
3827
|
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
return obj;
|
|
3828
|
+
var LexicalDistance = /*#__PURE__*/function () {
|
|
3829
|
+
function LexicalDistance(input) {
|
|
3830
|
+
this._input = input;
|
|
3831
|
+
this._inputLowerCase = input.toLowerCase();
|
|
3832
|
+
this._inputArray = stringToArray(this._inputLowerCase);
|
|
3833
|
+
this._rows = [new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0)];
|
|
3973
3834
|
}
|
|
3974
3835
|
|
|
3975
|
-
var
|
|
3836
|
+
var _proto = LexicalDistance.prototype;
|
|
3976
3837
|
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
map[key] = value;
|
|
3982
|
-
}
|
|
3838
|
+
_proto.measure = function measure(option, threshold) {
|
|
3839
|
+
if (this._input === option) {
|
|
3840
|
+
return 0;
|
|
3841
|
+
}
|
|
3983
3842
|
|
|
3984
|
-
|
|
3985
|
-
}
|
|
3843
|
+
var optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit
|
|
3986
3844
|
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
*
|
|
3991
|
-
* const phoneBook = [
|
|
3992
|
-
* { name: 'Jon', num: '555-1234' },
|
|
3993
|
-
* { name: 'Jenny', num: '867-5309' }
|
|
3994
|
-
* ]
|
|
3995
|
-
*
|
|
3996
|
-
* // { Jon: '555-1234', Jenny: '867-5309' }
|
|
3997
|
-
* const phonesByName = keyValMap(
|
|
3998
|
-
* phoneBook,
|
|
3999
|
-
* entry => entry.name,
|
|
4000
|
-
* entry => entry.num
|
|
4001
|
-
* )
|
|
4002
|
-
*
|
|
4003
|
-
*/
|
|
4004
|
-
function keyValMap(list, keyFn, valFn) {
|
|
4005
|
-
return list.reduce(function (map, item) {
|
|
4006
|
-
map[keyFn(item)] = valFn(item);
|
|
4007
|
-
return map;
|
|
4008
|
-
}, Object.create(null));
|
|
4009
|
-
}
|
|
3845
|
+
if (this._inputLowerCase === optionLowerCase) {
|
|
3846
|
+
return 1;
|
|
3847
|
+
}
|
|
4010
3848
|
|
|
4011
|
-
var
|
|
4012
|
-
|
|
4013
|
-
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
|
|
4014
|
-
*/
|
|
3849
|
+
var a = stringToArray(optionLowerCase);
|
|
3850
|
+
var b = this._inputArray;
|
|
4015
3851
|
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
3852
|
+
if (a.length < b.length) {
|
|
3853
|
+
var tmp = a;
|
|
3854
|
+
a = b;
|
|
3855
|
+
b = tmp;
|
|
3856
|
+
}
|
|
4021
3857
|
|
|
4022
|
-
|
|
3858
|
+
var aLength = a.length;
|
|
3859
|
+
var bLength = b.length;
|
|
4023
3860
|
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
3861
|
+
if (aLength - bLength > threshold) {
|
|
3862
|
+
return undefined;
|
|
3863
|
+
}
|
|
4027
3864
|
|
|
4028
|
-
|
|
4029
|
-
return "\"".concat(x, "\"");
|
|
4030
|
-
});
|
|
3865
|
+
var rows = this._rows;
|
|
4031
3866
|
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
3867
|
+
for (var j = 0; j <= bLength; j++) {
|
|
3868
|
+
rows[0][j] = j;
|
|
3869
|
+
}
|
|
4035
3870
|
|
|
4036
|
-
|
|
4037
|
-
|
|
3871
|
+
for (var i = 1; i <= aLength; i++) {
|
|
3872
|
+
var upRow = rows[(i - 1) % 3];
|
|
3873
|
+
var currentRow = rows[i % 3];
|
|
3874
|
+
var smallestCell = currentRow[0] = i;
|
|
4038
3875
|
|
|
4039
|
-
|
|
4040
|
-
|
|
3876
|
+
for (var _j = 1; _j <= bLength; _j++) {
|
|
3877
|
+
var cost = a[i - 1] === b[_j - 1] ? 0 : 1;
|
|
3878
|
+
var currentCell = Math.min(upRow[_j] + 1, // delete
|
|
3879
|
+
currentRow[_j - 1] + 1, // insert
|
|
3880
|
+
upRow[_j - 1] + cost // substitute
|
|
3881
|
+
);
|
|
3882
|
+
|
|
3883
|
+
if (i > 1 && _j > 1 && a[i - 1] === b[_j - 2] && a[i - 2] === b[_j - 1]) {
|
|
3884
|
+
// transposition
|
|
3885
|
+
var doubleDiagonalCell = rows[(i - 2) % 3][_j - 2];
|
|
3886
|
+
currentCell = Math.min(currentCell, doubleDiagonalCell + 1);
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
if (currentCell < smallestCell) {
|
|
3890
|
+
smallestCell = currentCell;
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
currentRow[_j] = currentCell;
|
|
3894
|
+
} // Early exit, since distance can't go smaller than smallest element of the previous row.
|
|
3895
|
+
|
|
3896
|
+
|
|
3897
|
+
if (smallestCell > threshold) {
|
|
3898
|
+
return undefined;
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
|
|
3902
|
+
var distance = rows[aLength % 3][bLength];
|
|
3903
|
+
return distance <= threshold ? distance : undefined;
|
|
3904
|
+
};
|
|
3905
|
+
|
|
3906
|
+
return LexicalDistance;
|
|
3907
|
+
}();
|
|
3908
|
+
|
|
3909
|
+
function stringToArray(str) {
|
|
3910
|
+
var strLength = str.length;
|
|
3911
|
+
var array = new Array(strLength);
|
|
3912
|
+
|
|
3913
|
+
for (var i = 0; i < strLength; ++i) {
|
|
3914
|
+
array[i] = str.charCodeAt(i);
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
return array;
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3920
|
+
/**
|
|
3921
|
+
* Converts an AST into a string, using one set of reasonable
|
|
3922
|
+
* formatting rules.
|
|
3923
|
+
*/
|
|
3924
|
+
|
|
3925
|
+
function print(ast) {
|
|
3926
|
+
return visit(ast, {
|
|
3927
|
+
leave: printDocASTReducer
|
|
3928
|
+
});
|
|
3929
|
+
}
|
|
3930
|
+
var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future
|
|
3931
|
+
|
|
3932
|
+
var printDocASTReducer = {
|
|
3933
|
+
Name: function Name(node) {
|
|
3934
|
+
return node.value;
|
|
3935
|
+
},
|
|
3936
|
+
Variable: function Variable(node) {
|
|
3937
|
+
return '$' + node.name;
|
|
3938
|
+
},
|
|
3939
|
+
// Document
|
|
3940
|
+
Document: function Document(node) {
|
|
3941
|
+
return join(node.definitions, '\n\n') + '\n';
|
|
3942
|
+
},
|
|
3943
|
+
OperationDefinition: function OperationDefinition(node) {
|
|
3944
|
+
var op = node.operation;
|
|
3945
|
+
var name = node.name;
|
|
3946
|
+
var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
|
|
3947
|
+
var directives = join(node.directives, ' ');
|
|
3948
|
+
var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
|
|
3949
|
+
// the query short form.
|
|
3950
|
+
|
|
3951
|
+
return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
|
|
3952
|
+
},
|
|
3953
|
+
VariableDefinition: function VariableDefinition(_ref) {
|
|
3954
|
+
var variable = _ref.variable,
|
|
3955
|
+
type = _ref.type,
|
|
3956
|
+
defaultValue = _ref.defaultValue,
|
|
3957
|
+
directives = _ref.directives;
|
|
3958
|
+
return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
|
|
3959
|
+
},
|
|
3960
|
+
SelectionSet: function SelectionSet(_ref2) {
|
|
3961
|
+
var selections = _ref2.selections;
|
|
3962
|
+
return block(selections);
|
|
3963
|
+
},
|
|
3964
|
+
Field: function Field(_ref3) {
|
|
3965
|
+
var alias = _ref3.alias,
|
|
3966
|
+
name = _ref3.name,
|
|
3967
|
+
args = _ref3.arguments,
|
|
3968
|
+
directives = _ref3.directives,
|
|
3969
|
+
selectionSet = _ref3.selectionSet;
|
|
3970
|
+
var prefix = wrap('', alias, ': ') + name;
|
|
3971
|
+
var argsLine = prefix + wrap('(', join(args, ', '), ')');
|
|
3972
|
+
|
|
3973
|
+
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
3974
|
+
argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3977
|
+
return join([argsLine, join(directives, ' '), selectionSet], ' ');
|
|
3978
|
+
},
|
|
3979
|
+
Argument: function Argument(_ref4) {
|
|
3980
|
+
var name = _ref4.name,
|
|
3981
|
+
value = _ref4.value;
|
|
3982
|
+
return name + ': ' + value;
|
|
3983
|
+
},
|
|
3984
|
+
// Fragments
|
|
3985
|
+
FragmentSpread: function FragmentSpread(_ref5) {
|
|
3986
|
+
var name = _ref5.name,
|
|
3987
|
+
directives = _ref5.directives;
|
|
3988
|
+
return '...' + name + wrap(' ', join(directives, ' '));
|
|
3989
|
+
},
|
|
3990
|
+
InlineFragment: function InlineFragment(_ref6) {
|
|
3991
|
+
var typeCondition = _ref6.typeCondition,
|
|
3992
|
+
directives = _ref6.directives,
|
|
3993
|
+
selectionSet = _ref6.selectionSet;
|
|
3994
|
+
return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
|
|
3995
|
+
},
|
|
3996
|
+
FragmentDefinition: function FragmentDefinition(_ref7) {
|
|
3997
|
+
var name = _ref7.name,
|
|
3998
|
+
typeCondition = _ref7.typeCondition,
|
|
3999
|
+
variableDefinitions = _ref7.variableDefinitions,
|
|
4000
|
+
directives = _ref7.directives,
|
|
4001
|
+
selectionSet = _ref7.selectionSet;
|
|
4002
|
+
return (// Note: fragment variable definitions are experimental and may be changed
|
|
4003
|
+
// or removed in the future.
|
|
4004
|
+
"fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
|
|
4005
|
+
);
|
|
4006
|
+
},
|
|
4007
|
+
// Value
|
|
4008
|
+
IntValue: function IntValue(_ref8) {
|
|
4009
|
+
var value = _ref8.value;
|
|
4010
|
+
return value;
|
|
4011
|
+
},
|
|
4012
|
+
FloatValue: function FloatValue(_ref9) {
|
|
4013
|
+
var value = _ref9.value;
|
|
4014
|
+
return value;
|
|
4015
|
+
},
|
|
4016
|
+
StringValue: function StringValue(_ref10, key) {
|
|
4017
|
+
var value = _ref10.value,
|
|
4018
|
+
isBlockString = _ref10.block;
|
|
4019
|
+
return isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
|
|
4020
|
+
},
|
|
4021
|
+
BooleanValue: function BooleanValue(_ref11) {
|
|
4022
|
+
var value = _ref11.value;
|
|
4023
|
+
return value ? 'true' : 'false';
|
|
4024
|
+
},
|
|
4025
|
+
NullValue: function NullValue() {
|
|
4026
|
+
return 'null';
|
|
4027
|
+
},
|
|
4028
|
+
EnumValue: function EnumValue(_ref12) {
|
|
4029
|
+
var value = _ref12.value;
|
|
4030
|
+
return value;
|
|
4031
|
+
},
|
|
4032
|
+
ListValue: function ListValue(_ref13) {
|
|
4033
|
+
var values = _ref13.values;
|
|
4034
|
+
return '[' + join(values, ', ') + ']';
|
|
4035
|
+
},
|
|
4036
|
+
ObjectValue: function ObjectValue(_ref14) {
|
|
4037
|
+
var fields = _ref14.fields;
|
|
4038
|
+
return '{' + join(fields, ', ') + '}';
|
|
4039
|
+
},
|
|
4040
|
+
ObjectField: function ObjectField(_ref15) {
|
|
4041
|
+
var name = _ref15.name,
|
|
4042
|
+
value = _ref15.value;
|
|
4043
|
+
return name + ': ' + value;
|
|
4044
|
+
},
|
|
4045
|
+
// Directive
|
|
4046
|
+
Directive: function Directive(_ref16) {
|
|
4047
|
+
var name = _ref16.name,
|
|
4048
|
+
args = _ref16.arguments;
|
|
4049
|
+
return '@' + name + wrap('(', join(args, ', '), ')');
|
|
4050
|
+
},
|
|
4051
|
+
// Type
|
|
4052
|
+
NamedType: function NamedType(_ref17) {
|
|
4053
|
+
var name = _ref17.name;
|
|
4054
|
+
return name;
|
|
4055
|
+
},
|
|
4056
|
+
ListType: function ListType(_ref18) {
|
|
4057
|
+
var type = _ref18.type;
|
|
4058
|
+
return '[' + type + ']';
|
|
4059
|
+
},
|
|
4060
|
+
NonNullType: function NonNullType(_ref19) {
|
|
4061
|
+
var type = _ref19.type;
|
|
4062
|
+
return type + '!';
|
|
4063
|
+
},
|
|
4064
|
+
// Type System Definitions
|
|
4065
|
+
SchemaDefinition: addDescription(function (_ref20) {
|
|
4066
|
+
var directives = _ref20.directives,
|
|
4067
|
+
operationTypes = _ref20.operationTypes;
|
|
4068
|
+
return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
4069
|
+
}),
|
|
4070
|
+
OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
|
|
4071
|
+
var operation = _ref21.operation,
|
|
4072
|
+
type = _ref21.type;
|
|
4073
|
+
return operation + ': ' + type;
|
|
4074
|
+
},
|
|
4075
|
+
ScalarTypeDefinition: addDescription(function (_ref22) {
|
|
4076
|
+
var name = _ref22.name,
|
|
4077
|
+
directives = _ref22.directives;
|
|
4078
|
+
return join(['scalar', name, join(directives, ' ')], ' ');
|
|
4079
|
+
}),
|
|
4080
|
+
ObjectTypeDefinition: addDescription(function (_ref23) {
|
|
4081
|
+
var name = _ref23.name,
|
|
4082
|
+
interfaces = _ref23.interfaces,
|
|
4083
|
+
directives = _ref23.directives,
|
|
4084
|
+
fields = _ref23.fields;
|
|
4085
|
+
return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
4086
|
+
}),
|
|
4087
|
+
FieldDefinition: addDescription(function (_ref24) {
|
|
4088
|
+
var name = _ref24.name,
|
|
4089
|
+
args = _ref24.arguments,
|
|
4090
|
+
type = _ref24.type,
|
|
4091
|
+
directives = _ref24.directives;
|
|
4092
|
+
return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
|
|
4093
|
+
}),
|
|
4094
|
+
InputValueDefinition: addDescription(function (_ref25) {
|
|
4095
|
+
var name = _ref25.name,
|
|
4096
|
+
type = _ref25.type,
|
|
4097
|
+
defaultValue = _ref25.defaultValue,
|
|
4098
|
+
directives = _ref25.directives;
|
|
4099
|
+
return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
|
|
4100
|
+
}),
|
|
4101
|
+
InterfaceTypeDefinition: addDescription(function (_ref26) {
|
|
4102
|
+
var name = _ref26.name,
|
|
4103
|
+
interfaces = _ref26.interfaces,
|
|
4104
|
+
directives = _ref26.directives,
|
|
4105
|
+
fields = _ref26.fields;
|
|
4106
|
+
return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
4107
|
+
}),
|
|
4108
|
+
UnionTypeDefinition: addDescription(function (_ref27) {
|
|
4109
|
+
var name = _ref27.name,
|
|
4110
|
+
directives = _ref27.directives,
|
|
4111
|
+
types = _ref27.types;
|
|
4112
|
+
return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
|
|
4113
|
+
}),
|
|
4114
|
+
EnumTypeDefinition: addDescription(function (_ref28) {
|
|
4115
|
+
var name = _ref28.name,
|
|
4116
|
+
directives = _ref28.directives,
|
|
4117
|
+
values = _ref28.values;
|
|
4118
|
+
return join(['enum', name, join(directives, ' '), block(values)], ' ');
|
|
4119
|
+
}),
|
|
4120
|
+
EnumValueDefinition: addDescription(function (_ref29) {
|
|
4121
|
+
var name = _ref29.name,
|
|
4122
|
+
directives = _ref29.directives;
|
|
4123
|
+
return join([name, join(directives, ' ')], ' ');
|
|
4124
|
+
}),
|
|
4125
|
+
InputObjectTypeDefinition: addDescription(function (_ref30) {
|
|
4126
|
+
var name = _ref30.name,
|
|
4127
|
+
directives = _ref30.directives,
|
|
4128
|
+
fields = _ref30.fields;
|
|
4129
|
+
return join(['input', name, join(directives, ' '), block(fields)], ' ');
|
|
4130
|
+
}),
|
|
4131
|
+
DirectiveDefinition: addDescription(function (_ref31) {
|
|
4132
|
+
var name = _ref31.name,
|
|
4133
|
+
args = _ref31.arguments,
|
|
4134
|
+
repeatable = _ref31.repeatable,
|
|
4135
|
+
locations = _ref31.locations;
|
|
4136
|
+
return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ');
|
|
4137
|
+
}),
|
|
4138
|
+
SchemaExtension: function SchemaExtension(_ref32) {
|
|
4139
|
+
var directives = _ref32.directives,
|
|
4140
|
+
operationTypes = _ref32.operationTypes;
|
|
4141
|
+
return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
4142
|
+
},
|
|
4143
|
+
ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
|
|
4144
|
+
var name = _ref33.name,
|
|
4145
|
+
directives = _ref33.directives;
|
|
4146
|
+
return join(['extend scalar', name, join(directives, ' ')], ' ');
|
|
4147
|
+
},
|
|
4148
|
+
ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
|
|
4149
|
+
var name = _ref34.name,
|
|
4150
|
+
interfaces = _ref34.interfaces,
|
|
4151
|
+
directives = _ref34.directives,
|
|
4152
|
+
fields = _ref34.fields;
|
|
4153
|
+
return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
4154
|
+
},
|
|
4155
|
+
InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
|
|
4156
|
+
var name = _ref35.name,
|
|
4157
|
+
interfaces = _ref35.interfaces,
|
|
4158
|
+
directives = _ref35.directives,
|
|
4159
|
+
fields = _ref35.fields;
|
|
4160
|
+
return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
4161
|
+
},
|
|
4162
|
+
UnionTypeExtension: function UnionTypeExtension(_ref36) {
|
|
4163
|
+
var name = _ref36.name,
|
|
4164
|
+
directives = _ref36.directives,
|
|
4165
|
+
types = _ref36.types;
|
|
4166
|
+
return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
|
|
4167
|
+
},
|
|
4168
|
+
EnumTypeExtension: function EnumTypeExtension(_ref37) {
|
|
4169
|
+
var name = _ref37.name,
|
|
4170
|
+
directives = _ref37.directives,
|
|
4171
|
+
values = _ref37.values;
|
|
4172
|
+
return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
|
|
4173
|
+
},
|
|
4174
|
+
InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
|
|
4175
|
+
var name = _ref38.name,
|
|
4176
|
+
directives = _ref38.directives,
|
|
4177
|
+
fields = _ref38.fields;
|
|
4178
|
+
return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
|
|
4041
4179
|
}
|
|
4180
|
+
};
|
|
4042
4181
|
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
}
|
|
4047
|
-
|
|
4048
|
-
/**
|
|
4049
|
-
* Returns the first argument it receives.
|
|
4050
|
-
*/
|
|
4051
|
-
function identityFunc(x) {
|
|
4052
|
-
return x;
|
|
4182
|
+
function addDescription(cb) {
|
|
4183
|
+
return function (node) {
|
|
4184
|
+
return join([node.description, cb(node)], '\n');
|
|
4185
|
+
};
|
|
4053
4186
|
}
|
|
4054
|
-
|
|
4055
4187
|
/**
|
|
4056
|
-
*
|
|
4057
|
-
*
|
|
4058
|
-
*
|
|
4059
|
-
* See: https://en.wikipedia.org/wiki/Natural_sort_order
|
|
4060
|
-
*
|
|
4188
|
+
* Given maybeArray, print an empty string if it is null or empty, otherwise
|
|
4189
|
+
* print all items together separated by separator if provided
|
|
4061
4190
|
*/
|
|
4062
|
-
function naturalCompare(aStr, bStr) {
|
|
4063
|
-
var aIdx = 0;
|
|
4064
|
-
var bIdx = 0;
|
|
4065
|
-
|
|
4066
|
-
while (aIdx < aStr.length && bIdx < bStr.length) {
|
|
4067
|
-
var aChar = aStr.charCodeAt(aIdx);
|
|
4068
|
-
var bChar = bStr.charCodeAt(bIdx);
|
|
4069
|
-
|
|
4070
|
-
if (isDigit(aChar) && isDigit(bChar)) {
|
|
4071
|
-
var aNum = 0;
|
|
4072
|
-
|
|
4073
|
-
do {
|
|
4074
|
-
++aIdx;
|
|
4075
|
-
aNum = aNum * 10 + aChar - DIGIT_0;
|
|
4076
|
-
aChar = aStr.charCodeAt(aIdx);
|
|
4077
|
-
} while (isDigit(aChar) && aNum > 0);
|
|
4078
|
-
|
|
4079
|
-
var bNum = 0;
|
|
4080
|
-
|
|
4081
|
-
do {
|
|
4082
|
-
++bIdx;
|
|
4083
|
-
bNum = bNum * 10 + bChar - DIGIT_0;
|
|
4084
|
-
bChar = bStr.charCodeAt(bIdx);
|
|
4085
|
-
} while (isDigit(bChar) && bNum > 0);
|
|
4086
|
-
|
|
4087
|
-
if (aNum < bNum) {
|
|
4088
|
-
return -1;
|
|
4089
|
-
}
|
|
4090
|
-
|
|
4091
|
-
if (aNum > bNum) {
|
|
4092
|
-
return 1;
|
|
4093
|
-
}
|
|
4094
|
-
} else {
|
|
4095
|
-
if (aChar < bChar) {
|
|
4096
|
-
return -1;
|
|
4097
|
-
}
|
|
4098
|
-
|
|
4099
|
-
if (aChar > bChar) {
|
|
4100
|
-
return 1;
|
|
4101
|
-
}
|
|
4102
4191
|
|
|
4103
|
-
++aIdx;
|
|
4104
|
-
++bIdx;
|
|
4105
|
-
}
|
|
4106
|
-
}
|
|
4107
4192
|
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
var DIGIT_0 = 48;
|
|
4111
|
-
var DIGIT_9 = 57;
|
|
4193
|
+
function join(maybeArray) {
|
|
4194
|
+
var _maybeArray$filter$jo;
|
|
4112
4195
|
|
|
4113
|
-
|
|
4114
|
-
return
|
|
4196
|
+
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
4197
|
+
return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter(function (x) {
|
|
4198
|
+
return x;
|
|
4199
|
+
}).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : '';
|
|
4115
4200
|
}
|
|
4116
|
-
|
|
4117
4201
|
/**
|
|
4118
|
-
* Given
|
|
4119
|
-
*
|
|
4202
|
+
* Given array, print each item on its own line, wrapped in an
|
|
4203
|
+
* indented "{ }" block.
|
|
4120
4204
|
*/
|
|
4121
4205
|
|
|
4122
|
-
function suggestionList(input, options) {
|
|
4123
|
-
var optionsByDistance = Object.create(null);
|
|
4124
|
-
var lexicalDistance = new LexicalDistance(input);
|
|
4125
|
-
var threshold = Math.floor(input.length * 0.4) + 1;
|
|
4126
|
-
|
|
4127
|
-
for (var _i2 = 0; _i2 < options.length; _i2++) {
|
|
4128
|
-
var option = options[_i2];
|
|
4129
|
-
var distance = lexicalDistance.measure(option, threshold);
|
|
4130
|
-
|
|
4131
|
-
if (distance !== undefined) {
|
|
4132
|
-
optionsByDistance[option] = distance;
|
|
4133
|
-
}
|
|
4134
|
-
}
|
|
4135
4206
|
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
return distanceDiff !== 0 ? distanceDiff : naturalCompare(a, b);
|
|
4139
|
-
});
|
|
4207
|
+
function block(array) {
|
|
4208
|
+
return wrap('{\n', indent(join(array, '\n')), '\n}');
|
|
4140
4209
|
}
|
|
4141
4210
|
/**
|
|
4142
|
-
*
|
|
4143
|
-
*
|
|
4144
|
-
* The "distance" between two strings is given by counting the minimum number
|
|
4145
|
-
* of edits needed to transform string A into string B. An edit can be an
|
|
4146
|
-
* insertion, deletion, or substitution of a single character, or a swap of two
|
|
4147
|
-
* adjacent characters.
|
|
4148
|
-
*
|
|
4149
|
-
* Includes a custom alteration from Damerau-Levenshtein to treat case changes
|
|
4150
|
-
* as a single edit which helps identify mis-cased values with an edit distance
|
|
4151
|
-
* of 1.
|
|
4152
|
-
*
|
|
4153
|
-
* This distance can be useful for detecting typos in input or sorting
|
|
4211
|
+
* If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
|
|
4154
4212
|
*/
|
|
4155
4213
|
|
|
4156
|
-
var LexicalDistance = /*#__PURE__*/function () {
|
|
4157
|
-
function LexicalDistance(input) {
|
|
4158
|
-
this._input = input;
|
|
4159
|
-
this._inputLowerCase = input.toLowerCase();
|
|
4160
|
-
this._inputArray = stringToArray(this._inputLowerCase);
|
|
4161
|
-
this._rows = [new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0), new Array(input.length + 1).fill(0)];
|
|
4162
|
-
}
|
|
4163
|
-
|
|
4164
|
-
var _proto = LexicalDistance.prototype;
|
|
4165
|
-
|
|
4166
|
-
_proto.measure = function measure(option, threshold) {
|
|
4167
|
-
if (this._input === option) {
|
|
4168
|
-
return 0;
|
|
4169
|
-
}
|
|
4170
|
-
|
|
4171
|
-
var optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit
|
|
4172
|
-
|
|
4173
|
-
if (this._inputLowerCase === optionLowerCase) {
|
|
4174
|
-
return 1;
|
|
4175
|
-
}
|
|
4176
|
-
|
|
4177
|
-
var a = stringToArray(optionLowerCase);
|
|
4178
|
-
var b = this._inputArray;
|
|
4179
|
-
|
|
4180
|
-
if (a.length < b.length) {
|
|
4181
|
-
var tmp = a;
|
|
4182
|
-
a = b;
|
|
4183
|
-
b = tmp;
|
|
4184
|
-
}
|
|
4185
|
-
|
|
4186
|
-
var aLength = a.length;
|
|
4187
|
-
var bLength = b.length;
|
|
4188
|
-
|
|
4189
|
-
if (aLength - bLength > threshold) {
|
|
4190
|
-
return undefined;
|
|
4191
|
-
}
|
|
4192
|
-
|
|
4193
|
-
var rows = this._rows;
|
|
4194
|
-
|
|
4195
|
-
for (var j = 0; j <= bLength; j++) {
|
|
4196
|
-
rows[0][j] = j;
|
|
4197
|
-
}
|
|
4198
|
-
|
|
4199
|
-
for (var i = 1; i <= aLength; i++) {
|
|
4200
|
-
var upRow = rows[(i - 1) % 3];
|
|
4201
|
-
var currentRow = rows[i % 3];
|
|
4202
|
-
var smallestCell = currentRow[0] = i;
|
|
4203
|
-
|
|
4204
|
-
for (var _j = 1; _j <= bLength; _j++) {
|
|
4205
|
-
var cost = a[i - 1] === b[_j - 1] ? 0 : 1;
|
|
4206
|
-
var currentCell = Math.min(upRow[_j] + 1, // delete
|
|
4207
|
-
currentRow[_j - 1] + 1, // insert
|
|
4208
|
-
upRow[_j - 1] + cost // substitute
|
|
4209
|
-
);
|
|
4210
|
-
|
|
4211
|
-
if (i > 1 && _j > 1 && a[i - 1] === b[_j - 2] && a[i - 2] === b[_j - 1]) {
|
|
4212
|
-
// transposition
|
|
4213
|
-
var doubleDiagonalCell = rows[(i - 2) % 3][_j - 2];
|
|
4214
|
-
currentCell = Math.min(currentCell, doubleDiagonalCell + 1);
|
|
4215
|
-
}
|
|
4216
|
-
|
|
4217
|
-
if (currentCell < smallestCell) {
|
|
4218
|
-
smallestCell = currentCell;
|
|
4219
|
-
}
|
|
4220
|
-
|
|
4221
|
-
currentRow[_j] = currentCell;
|
|
4222
|
-
} // Early exit, since distance can't go smaller than smallest element of the previous row.
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
if (smallestCell > threshold) {
|
|
4226
|
-
return undefined;
|
|
4227
|
-
}
|
|
4228
|
-
}
|
|
4229
|
-
|
|
4230
|
-
var distance = rows[aLength % 3][bLength];
|
|
4231
|
-
return distance <= threshold ? distance : undefined;
|
|
4232
|
-
};
|
|
4233
4214
|
|
|
4234
|
-
|
|
4235
|
-
|
|
4215
|
+
function wrap(start, maybeString) {
|
|
4216
|
+
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
4217
|
+
return maybeString != null && maybeString !== '' ? start + maybeString + end : '';
|
|
4218
|
+
}
|
|
4236
4219
|
|
|
4237
|
-
function
|
|
4238
|
-
|
|
4239
|
-
|
|
4220
|
+
function indent(str) {
|
|
4221
|
+
return wrap(' ', str.replace(/\n/g, '\n '));
|
|
4222
|
+
}
|
|
4240
4223
|
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4224
|
+
function isMultiline(str) {
|
|
4225
|
+
return str.indexOf('\n') !== -1;
|
|
4226
|
+
}
|
|
4244
4227
|
|
|
4245
|
-
|
|
4228
|
+
function hasMultilineItems(maybeArray) {
|
|
4229
|
+
return maybeArray != null && maybeArray.some(isMultiline);
|
|
4246
4230
|
}
|
|
4247
4231
|
|
|
4248
4232
|
/**
|
|
@@ -7556,6 +7540,22 @@ function typeFromAST(schema, typeNode) {
|
|
|
7556
7540
|
invariant(0, 'Unexpected type node: ' + inspect(typeNode));
|
|
7557
7541
|
}
|
|
7558
7542
|
|
|
7543
|
+
function isExecutableDefinitionNode(node) {
|
|
7544
|
+
return node.kind === Kind.OPERATION_DEFINITION || node.kind === Kind.FRAGMENT_DEFINITION;
|
|
7545
|
+
}
|
|
7546
|
+
function isTypeSystemDefinitionNode(node) {
|
|
7547
|
+
return node.kind === Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(node) || node.kind === Kind.DIRECTIVE_DEFINITION;
|
|
7548
|
+
}
|
|
7549
|
+
function isTypeDefinitionNode(node) {
|
|
7550
|
+
return node.kind === Kind.SCALAR_TYPE_DEFINITION || node.kind === Kind.OBJECT_TYPE_DEFINITION || node.kind === Kind.INTERFACE_TYPE_DEFINITION || node.kind === Kind.UNION_TYPE_DEFINITION || node.kind === Kind.ENUM_TYPE_DEFINITION || node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION;
|
|
7551
|
+
}
|
|
7552
|
+
function isTypeSystemExtensionNode(node) {
|
|
7553
|
+
return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
|
|
7554
|
+
}
|
|
7555
|
+
function isTypeExtensionNode(node) {
|
|
7556
|
+
return node.kind === Kind.SCALAR_TYPE_EXTENSION || node.kind === Kind.OBJECT_TYPE_EXTENSION || node.kind === Kind.INTERFACE_TYPE_EXTENSION || node.kind === Kind.UNION_TYPE_EXTENSION || node.kind === Kind.ENUM_TYPE_EXTENSION || node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;
|
|
7557
|
+
}
|
|
7558
|
+
|
|
7559
7559
|
/**
|
|
7560
7560
|
* Executable definitions
|
|
7561
7561
|
*
|
|
@@ -12735,7 +12735,6 @@ const docMap = new Map();
|
|
|
12735
12735
|
* As a user shouldn't have access to the Document
|
|
12736
12736
|
*/
|
|
12737
12737
|
const referenceMap = new WeakMap();
|
|
12738
|
-
let addMetaschemaDirectives = false;
|
|
12739
12738
|
/**
|
|
12740
12739
|
* Strips characters that are not significant to the validity or execution
|
|
12741
12740
|
* of a GraphQL document:
|
|
@@ -12768,10 +12767,6 @@ function parseDocument(inputString) {
|
|
|
12768
12767
|
}
|
|
12769
12768
|
return null;
|
|
12770
12769
|
}
|
|
12771
|
-
// in-place substitution for removal of legacy and adding metaschema directives
|
|
12772
|
-
if (addMetaschemaDirectives) {
|
|
12773
|
-
metaschemaMapper(parsedDoc);
|
|
12774
|
-
}
|
|
12775
12770
|
const parsedDocNoLoc = stripLocation(parsedDoc);
|
|
12776
12771
|
docMap.set(operationKey, parsedDocNoLoc);
|
|
12777
12772
|
return parsedDocNoLoc;
|
|
@@ -12790,9 +12785,12 @@ function insertFragments(doc, fragments) {
|
|
|
12790
12785
|
});
|
|
12791
12786
|
return doc;
|
|
12792
12787
|
}
|
|
12793
|
-
function
|
|
12788
|
+
function updateReferenceMapWithKnownKey(doc, key) {
|
|
12789
|
+
referenceMap.set(key, doc);
|
|
12790
|
+
}
|
|
12791
|
+
function updateReferenceMapAndGetKey(doc) {
|
|
12794
12792
|
const key = create(null);
|
|
12795
|
-
|
|
12793
|
+
updateReferenceMapWithKnownKey(doc, key);
|
|
12796
12794
|
return key;
|
|
12797
12795
|
}
|
|
12798
12796
|
/**
|
|
@@ -12903,26 +12901,23 @@ function gql(literals, ...subs) {
|
|
|
12903
12901
|
return null;
|
|
12904
12902
|
}
|
|
12905
12903
|
if (inputSubstitutionFragments.length === 0) {
|
|
12906
|
-
return
|
|
12904
|
+
return updateReferenceMapAndGetKey(document);
|
|
12907
12905
|
}
|
|
12908
|
-
return
|
|
12909
|
-
}
|
|
12910
|
-
/**
|
|
12911
|
-
* Enable the parser to add corresponding metaschema directives for backwards compatibility
|
|
12912
|
-
*/
|
|
12913
|
-
function enableAddMetaschemaDirective() {
|
|
12914
|
-
addMetaschemaDirectives = true;
|
|
12915
|
-
}
|
|
12916
|
-
function disableAddMetaschemaDirective() {
|
|
12917
|
-
addMetaschemaDirectives = false;
|
|
12906
|
+
return updateReferenceMapAndGetKey(insertFragments(document, inputSubstitutionFragments));
|
|
12918
12907
|
}
|
|
12919
12908
|
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
*/
|
|
12909
|
+
/**
|
|
12910
|
+
* @deprecated In favor of gql tagged template literal
|
|
12911
|
+
*/
|
|
12923
12912
|
function parseAndVisit(source) {
|
|
12924
|
-
const ast =
|
|
12925
|
-
|
|
12913
|
+
const ast = parseDocument(source);
|
|
12914
|
+
const luvioDocumentNode = transform(ast);
|
|
12915
|
+
// In-place substitution of metaschema annotations
|
|
12916
|
+
metaschemaMapper(ast);
|
|
12917
|
+
// Set the AST reference map with LuvioDocumentNode as the key
|
|
12918
|
+
// ASTResolver will resolve it to metaschema mapped AST
|
|
12919
|
+
updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
|
|
12920
|
+
return luvioDocumentNode;
|
|
12926
12921
|
}
|
|
12927
12922
|
|
|
12928
|
-
export { GraphQLScalarType, GraphQLSchema, Kind, astResolver, buildASTSchema, buildSchema,
|
|
12923
|
+
export { GraphQLScalarType, GraphQLSchema, Kind, astResolver, buildASTSchema, buildSchema, execute, getNamedType, gql, isObjectType, isScalarType, parse, parseAndVisit, print, stripIgnoredCharacters, visit };
|