@axinom/mosaic-user-auth 0.34.0 → 0.35.0-rc.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/THIRD-PARTY-LICENSES.txt +1 -1
- package/dist/cjs/index.js +327 -530
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +327 -530
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -513,6 +513,45 @@ const approveDevice = (userAuthConfig, endUserAccessToken, userCode) => submitDe
|
|
|
513
513
|
*/
|
|
514
514
|
const denyDevice = (userAuthConfig, endUserAccessToken, userCode) => submitDeviceApproval(userAuthConfig, endUserAccessToken, userCode, 'deny');
|
|
515
515
|
|
|
516
|
+
/**
|
|
517
|
+
* Produces the value of a block string from its parsed raw value, similar to
|
|
518
|
+
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
|
|
519
|
+
*
|
|
520
|
+
* This implements the GraphQL spec's BlockStringValue() static algorithm.
|
|
521
|
+
*
|
|
522
|
+
* @internal
|
|
523
|
+
*/
|
|
524
|
+
/**
|
|
525
|
+
* Print a block string in the indented block form by adding a leading and
|
|
526
|
+
* trailing blank line. However, if a block string starts with whitespace and is
|
|
527
|
+
* a single-line, adding a leading blank line would strip that whitespace.
|
|
528
|
+
*
|
|
529
|
+
* @internal
|
|
530
|
+
*/
|
|
531
|
+
|
|
532
|
+
function printBlockString(value) {
|
|
533
|
+
var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
534
|
+
var preferMultipleLines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
535
|
+
var isSingleLine = value.indexOf('\n') === -1;
|
|
536
|
+
var hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
|
|
537
|
+
var hasTrailingQuote = value[value.length - 1] === '"';
|
|
538
|
+
var hasTrailingSlash = value[value.length - 1] === '\\';
|
|
539
|
+
var printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;
|
|
540
|
+
var result = ''; // Format a multi-line block quote to account for leading space.
|
|
541
|
+
|
|
542
|
+
if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {
|
|
543
|
+
result += '\n' + indentation;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
result += indentation ? value.replace(/\n/g, '\n' + indentation) : value;
|
|
547
|
+
|
|
548
|
+
if (printAsMultipleLines) {
|
|
549
|
+
result += '\n';
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
return '"""' + result.replace(/"""/g, '\\"""') + '"""';
|
|
553
|
+
}
|
|
554
|
+
|
|
516
555
|
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
517
556
|
var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
|
|
518
557
|
var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
|
|
@@ -639,145 +678,6 @@ function getObjectTag(object) {
|
|
|
639
678
|
return tag;
|
|
640
679
|
}
|
|
641
680
|
|
|
642
|
-
function invariant(condition, message) {
|
|
643
|
-
var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
|
|
644
|
-
|
|
645
|
-
if (!booleanCondition) {
|
|
646
|
-
throw new Error(message != null ? message : 'Unexpected invariant triggered.');
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
/**
|
|
651
|
-
* The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
|
|
652
|
-
*/
|
|
653
|
-
|
|
654
|
-
function defineInspect(classObject) {
|
|
655
|
-
var fn = classObject.prototype.toJSON;
|
|
656
|
-
typeof fn === 'function' || invariant(0);
|
|
657
|
-
classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
|
|
658
|
-
|
|
659
|
-
if (nodejsCustomInspectSymbol$1) {
|
|
660
|
-
classObject.prototype[nodejsCustomInspectSymbol$1] = fn;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* Contains a range of UTF-8 character offsets and token references that
|
|
666
|
-
* identify the region of the source from which the AST derived.
|
|
667
|
-
*/
|
|
668
|
-
var Location = /*#__PURE__*/function () {
|
|
669
|
-
/**
|
|
670
|
-
* The character offset at which this Node begins.
|
|
671
|
-
*/
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* The character offset at which this Node ends.
|
|
675
|
-
*/
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* The Token at which this Node begins.
|
|
679
|
-
*/
|
|
680
|
-
|
|
681
|
-
/**
|
|
682
|
-
* The Token at which this Node ends.
|
|
683
|
-
*/
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* The Source document the AST represents.
|
|
687
|
-
*/
|
|
688
|
-
function Location(startToken, endToken, source) {
|
|
689
|
-
this.start = startToken.start;
|
|
690
|
-
this.end = endToken.end;
|
|
691
|
-
this.startToken = startToken;
|
|
692
|
-
this.endToken = endToken;
|
|
693
|
-
this.source = source;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
var _proto = Location.prototype;
|
|
697
|
-
|
|
698
|
-
_proto.toJSON = function toJSON() {
|
|
699
|
-
return {
|
|
700
|
-
start: this.start,
|
|
701
|
-
end: this.end
|
|
702
|
-
};
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
return Location;
|
|
706
|
-
}(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
|
|
707
|
-
|
|
708
|
-
defineInspect(Location);
|
|
709
|
-
/**
|
|
710
|
-
* Represents a range of characters represented by a lexical token
|
|
711
|
-
* within a Source.
|
|
712
|
-
*/
|
|
713
|
-
|
|
714
|
-
var Token = /*#__PURE__*/function () {
|
|
715
|
-
/**
|
|
716
|
-
* The kind of Token.
|
|
717
|
-
*/
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* The character offset at which this Node begins.
|
|
721
|
-
*/
|
|
722
|
-
|
|
723
|
-
/**
|
|
724
|
-
* The character offset at which this Node ends.
|
|
725
|
-
*/
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* The 1-indexed line number on which this Token appears.
|
|
729
|
-
*/
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* The 1-indexed column number at which this Token begins.
|
|
733
|
-
*/
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* For non-punctuation tokens, represents the interpreted value of the token.
|
|
737
|
-
*/
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
|
741
|
-
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
742
|
-
* the last.
|
|
743
|
-
*/
|
|
744
|
-
function Token(kind, start, end, line, column, prev, value) {
|
|
745
|
-
this.kind = kind;
|
|
746
|
-
this.start = start;
|
|
747
|
-
this.end = end;
|
|
748
|
-
this.line = line;
|
|
749
|
-
this.column = column;
|
|
750
|
-
this.value = value;
|
|
751
|
-
this.prev = prev;
|
|
752
|
-
this.next = null;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
var _proto2 = Token.prototype;
|
|
756
|
-
|
|
757
|
-
_proto2.toJSON = function toJSON() {
|
|
758
|
-
return {
|
|
759
|
-
kind: this.kind,
|
|
760
|
-
value: this.value,
|
|
761
|
-
line: this.line,
|
|
762
|
-
column: this.column
|
|
763
|
-
};
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
return Token;
|
|
767
|
-
}(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
|
|
768
|
-
|
|
769
|
-
defineInspect(Token);
|
|
770
|
-
/**
|
|
771
|
-
* @internal
|
|
772
|
-
*/
|
|
773
|
-
|
|
774
|
-
function isNode(maybeNode) {
|
|
775
|
-
return maybeNode != null && typeof maybeNode.kind === 'string';
|
|
776
|
-
}
|
|
777
|
-
/**
|
|
778
|
-
* The list of all possible AST node types.
|
|
779
|
-
*/
|
|
780
|
-
|
|
781
681
|
/**
|
|
782
682
|
* A visitor is provided to visit, it contains the collection of
|
|
783
683
|
* relevant functions to be called during the visitor's traversal.
|
|
@@ -830,360 +730,218 @@ var QueryDocumentKeys = {
|
|
|
830
730
|
EnumTypeExtension: ['name', 'directives', 'values'],
|
|
831
731
|
InputObjectTypeExtension: ['name', 'directives', 'fields']
|
|
832
732
|
};
|
|
833
|
-
|
|
834
|
-
/**
|
|
835
|
-
* visit() will walk through an AST using a depth-first traversal, calling
|
|
836
|
-
* the visitor's enter function at each node in the traversal, and calling the
|
|
837
|
-
* leave function after visiting that node and all of its child nodes.
|
|
838
|
-
*
|
|
839
|
-
* By returning different values from the enter and leave functions, the
|
|
840
|
-
* behavior of the visitor can be altered, including skipping over a sub-tree of
|
|
841
|
-
* the AST (by returning false), editing the AST by returning a value or null
|
|
842
|
-
* to remove the value, or to stop the whole traversal by returning BREAK.
|
|
843
|
-
*
|
|
844
|
-
* When using visit() to edit an AST, the original AST will not be modified, and
|
|
845
|
-
* a new version of the AST with the changes applied will be returned from the
|
|
846
|
-
* visit function.
|
|
847
|
-
*
|
|
848
|
-
* const editedAST = visit(ast, {
|
|
849
|
-
* enter(node, key, parent, path, ancestors) {
|
|
850
|
-
* // @return
|
|
851
|
-
* // undefined: no action
|
|
852
|
-
* // false: skip visiting this node
|
|
853
|
-
* // visitor.BREAK: stop visiting altogether
|
|
854
|
-
* // null: delete this node
|
|
855
|
-
* // any value: replace this node with the returned value
|
|
856
|
-
* },
|
|
857
|
-
* leave(node, key, parent, path, ancestors) {
|
|
858
|
-
* // @return
|
|
859
|
-
* // undefined: no action
|
|
860
|
-
* // false: no action
|
|
861
|
-
* // visitor.BREAK: stop visiting altogether
|
|
862
|
-
* // null: delete this node
|
|
863
|
-
* // any value: replace this node with the returned value
|
|
864
|
-
* }
|
|
865
|
-
* });
|
|
866
|
-
*
|
|
867
|
-
* Alternatively to providing enter() and leave() functions, a visitor can
|
|
868
|
-
* instead provide functions named the same as the kinds of AST nodes, or
|
|
869
|
-
* enter/leave visitors at a named key, leading to four permutations of the
|
|
870
|
-
* visitor API:
|
|
871
|
-
*
|
|
872
|
-
* 1) Named visitors triggered when entering a node of a specific kind.
|
|
873
|
-
*
|
|
874
|
-
* visit(ast, {
|
|
875
|
-
* Kind(node) {
|
|
876
|
-
* // enter the "Kind" node
|
|
877
|
-
* }
|
|
878
|
-
* })
|
|
879
|
-
*
|
|
880
|
-
* 2) Named visitors that trigger upon entering and leaving a node of
|
|
881
|
-
* a specific kind.
|
|
882
|
-
*
|
|
883
|
-
* visit(ast, {
|
|
884
|
-
* Kind: {
|
|
885
|
-
* enter(node) {
|
|
886
|
-
* // enter the "Kind" node
|
|
887
|
-
* }
|
|
888
|
-
* leave(node) {
|
|
889
|
-
* // leave the "Kind" node
|
|
890
|
-
* }
|
|
891
|
-
* }
|
|
892
|
-
* })
|
|
893
|
-
*
|
|
894
|
-
* 3) Generic visitors that trigger upon entering and leaving any node.
|
|
895
|
-
*
|
|
896
|
-
* visit(ast, {
|
|
897
|
-
* enter(node) {
|
|
898
|
-
* // enter any node
|
|
899
|
-
* },
|
|
900
|
-
* leave(node) {
|
|
901
|
-
* // leave any node
|
|
902
|
-
* }
|
|
903
|
-
* })
|
|
904
|
-
*
|
|
905
|
-
* 4) Parallel visitors for entering and leaving nodes of a specific kind.
|
|
906
|
-
*
|
|
907
|
-
* visit(ast, {
|
|
908
|
-
* enter: {
|
|
909
|
-
* Kind(node) {
|
|
910
|
-
* // enter the "Kind" node
|
|
911
|
-
* }
|
|
912
|
-
* },
|
|
913
|
-
* leave: {
|
|
914
|
-
* Kind(node) {
|
|
915
|
-
* // leave the "Kind" node
|
|
916
|
-
* }
|
|
917
|
-
* }
|
|
918
|
-
* })
|
|
919
|
-
*/
|
|
733
|
+
Object.freeze({});
|
|
920
734
|
|
|
921
|
-
function
|
|
922
|
-
var visitorKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QueryDocumentKeys;
|
|
923
|
-
|
|
924
|
-
/* eslint-disable no-undef-init */
|
|
925
|
-
var stack = undefined;
|
|
926
|
-
var inArray = Array.isArray(root);
|
|
927
|
-
var keys = [root];
|
|
928
|
-
var index = -1;
|
|
929
|
-
var edits = [];
|
|
930
|
-
var node = undefined;
|
|
931
|
-
var key = undefined;
|
|
932
|
-
var parent = undefined;
|
|
933
|
-
var path = [];
|
|
934
|
-
var ancestors = [];
|
|
935
|
-
var newRoot = root;
|
|
936
|
-
/* eslint-enable no-undef-init */
|
|
735
|
+
function ownKeys(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; }
|
|
937
736
|
|
|
938
|
-
|
|
939
|
-
index++;
|
|
940
|
-
var isLeaving = index === keys.length;
|
|
941
|
-
var isEdited = isLeaving && edits.length !== 0;
|
|
942
|
-
|
|
943
|
-
if (isLeaving) {
|
|
944
|
-
key = ancestors.length === 0 ? undefined : path[path.length - 1];
|
|
945
|
-
node = parent;
|
|
946
|
-
parent = ancestors.pop();
|
|
947
|
-
|
|
948
|
-
if (isEdited) {
|
|
949
|
-
if (inArray) {
|
|
950
|
-
node = node.slice();
|
|
951
|
-
} else {
|
|
952
|
-
var clone = {};
|
|
953
|
-
|
|
954
|
-
for (var _i2 = 0, _Object$keys2 = Object.keys(node); _i2 < _Object$keys2.length; _i2++) {
|
|
955
|
-
var k = _Object$keys2[_i2];
|
|
956
|
-
clone[k] = node[k];
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
node = clone;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
var editOffset = 0;
|
|
963
|
-
|
|
964
|
-
for (var ii = 0; ii < edits.length; ii++) {
|
|
965
|
-
var editKey = edits[ii][0];
|
|
966
|
-
var editValue = edits[ii][1];
|
|
737
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
967
738
|
|
|
968
|
-
|
|
969
|
-
editKey -= editOffset;
|
|
970
|
-
}
|
|
739
|
+
function _defineProperty(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; }
|
|
971
740
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
741
|
+
/**
|
|
742
|
+
* Reduces children before their parents without changing the input AST.
|
|
743
|
+
* Returned values are not revisited.
|
|
744
|
+
* @internal
|
|
745
|
+
*/
|
|
746
|
+
function reduce(root, reducer) {
|
|
747
|
+
var stack = [];
|
|
748
|
+
var frame = {
|
|
749
|
+
parent: [root],
|
|
750
|
+
keys: undefined,
|
|
751
|
+
results: [],
|
|
752
|
+
index: -1
|
|
753
|
+
};
|
|
754
|
+
var node;
|
|
980
755
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
756
|
+
do {
|
|
757
|
+
var kind = void 0;
|
|
758
|
+
frame.index++;
|
|
759
|
+
var keys = frame.keys;
|
|
760
|
+
var length = keys == null ? frame.parent.length : keys.length;
|
|
761
|
+
|
|
762
|
+
if (frame.index === length) {
|
|
763
|
+
node = frame.results;
|
|
764
|
+
kind = keys == null ? undefined : node.kind;
|
|
765
|
+
frame = stack.pop();
|
|
986
766
|
} else {
|
|
987
|
-
|
|
988
|
-
node = parent ? parent[key] : newRoot;
|
|
767
|
+
node = keys == null ? frame.parent[frame.index] : frame.parent[keys[frame.index]];
|
|
989
768
|
|
|
990
|
-
if (node
|
|
769
|
+
if (node == null && stack.length !== 0) {
|
|
991
770
|
continue;
|
|
992
771
|
}
|
|
993
772
|
|
|
994
|
-
if (
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
result = visitFn.call(visitor, node, key, parent, path, ancestors);
|
|
773
|
+
if (Array.isArray(node)) {
|
|
774
|
+
if (node.length !== 0) {
|
|
775
|
+
stack.push(frame);
|
|
776
|
+
frame = {
|
|
777
|
+
parent: node,
|
|
778
|
+
keys: undefined,
|
|
779
|
+
results: [],
|
|
780
|
+
index: -1
|
|
781
|
+
};
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
} else {
|
|
785
|
+
var parent = node;
|
|
786
|
+
kind = parent === null || parent === void 0 ? void 0 : parent.kind;
|
|
787
|
+
var childKeys = typeof kind === 'string' ? QueryDocumentKeys[kind] : undefined;
|
|
1010
788
|
|
|
1011
|
-
if (
|
|
1012
|
-
|
|
789
|
+
if (!Array.isArray(childKeys)) {
|
|
790
|
+
throw new Error("Invalid AST Node: ".concat(inspect(node), "."));
|
|
1013
791
|
}
|
|
1014
792
|
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
if (isNode(result)) {
|
|
1025
|
-
node = result;
|
|
1026
|
-
} else {
|
|
1027
|
-
path.pop();
|
|
1028
|
-
continue;
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
793
|
+
if (childKeys.length !== 0) {
|
|
794
|
+
stack.push(frame);
|
|
795
|
+
frame = {
|
|
796
|
+
parent: parent,
|
|
797
|
+
keys: childKeys,
|
|
798
|
+
results: _objectSpread({}, parent),
|
|
799
|
+
index: -1
|
|
800
|
+
};
|
|
801
|
+
continue;
|
|
1031
802
|
}
|
|
1032
803
|
}
|
|
1033
804
|
}
|
|
1034
805
|
|
|
1035
|
-
if (
|
|
1036
|
-
|
|
806
|
+
if (kind !== undefined) {
|
|
807
|
+
var _reducer$kind;
|
|
808
|
+
|
|
809
|
+
node = (_reducer$kind = reducer[kind]) === null || _reducer$kind === void 0 ? void 0 : _reducer$kind.call(reducer, node, frame.keys == null ? frame.index : frame.keys[frame.index]);
|
|
1037
810
|
}
|
|
1038
811
|
|
|
1039
|
-
if (
|
|
1040
|
-
|
|
812
|
+
if (frame.keys == null) {
|
|
813
|
+
frame.results.push(node);
|
|
1041
814
|
} else {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
stack = {
|
|
1045
|
-
inArray: inArray,
|
|
1046
|
-
index: index,
|
|
1047
|
-
keys: keys,
|
|
1048
|
-
edits: edits,
|
|
1049
|
-
prev: stack
|
|
1050
|
-
};
|
|
1051
|
-
inArray = Array.isArray(node);
|
|
1052
|
-
keys = inArray ? node : (_visitorKeys$node$kin = visitorKeys[node.kind]) !== null && _visitorKeys$node$kin !== void 0 ? _visitorKeys$node$kin : [];
|
|
1053
|
-
index = -1;
|
|
1054
|
-
edits = [];
|
|
1055
|
-
|
|
1056
|
-
if (parent) {
|
|
1057
|
-
ancestors.push(parent);
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
parent = node;
|
|
815
|
+
frame.results[frame.keys[frame.index]] = node;
|
|
1061
816
|
}
|
|
1062
|
-
} while (stack !==
|
|
817
|
+
} while (stack.length !== 0);
|
|
1063
818
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
819
|
+
return node;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** @category Printing */
|
|
823
|
+
// eslint-disable-next-line no-redeclare
|
|
824
|
+
function print(ast, options) {
|
|
825
|
+
var _options$maxIndentDep;
|
|
1067
826
|
|
|
1068
|
-
return
|
|
827
|
+
return render(reduce(ast, printDocASTReducer), (_options$maxIndentDep = options === null || options === void 0 ? void 0 : options.maxIndentDepth) !== null && _options$maxIndentDep !== void 0 ? _options$maxIndentDep : Infinity);
|
|
1069
828
|
}
|
|
1070
|
-
/**
|
|
1071
|
-
* Given a visitor instance, if it is leaving or not, and a node kind, return
|
|
1072
|
-
* the function the visitor runtime should call.
|
|
1073
|
-
*/
|
|
1074
829
|
|
|
1075
|
-
|
|
1076
|
-
|
|
830
|
+
var MAX_LINE_LENGTH = 80;
|
|
831
|
+
|
|
832
|
+
var PrintBuffer = /*#__PURE__*/function () {
|
|
833
|
+
function PrintBuffer() {
|
|
834
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
835
|
+
var isBlockString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
836
|
+
this.next = undefined;
|
|
837
|
+
this.indentBefore = false;
|
|
838
|
+
this.dedentAfter = false;
|
|
839
|
+
this.length = value.length;
|
|
840
|
+
this.lines = value.includes('\n') ? value.split('\n') : value;
|
|
841
|
+
this.newlines = typeof this.lines === 'string' ? 0 : this.lines.length - 1;
|
|
842
|
+
this.isBlockString = isBlockString;
|
|
843
|
+
this.tail = undefined;
|
|
844
|
+
}
|
|
1077
845
|
|
|
1078
|
-
|
|
1079
|
-
if (!isLeaving && typeof kindVisitor === 'function') {
|
|
1080
|
-
// { Kind() {} }
|
|
1081
|
-
return kindVisitor;
|
|
1082
|
-
}
|
|
846
|
+
var _proto = PrintBuffer.prototype;
|
|
1083
847
|
|
|
1084
|
-
|
|
848
|
+
_proto.append = function append(result) {
|
|
849
|
+
var _this$tail, _next$tail;
|
|
1085
850
|
|
|
1086
|
-
if (
|
|
1087
|
-
|
|
1088
|
-
return kindSpecificVisitor;
|
|
851
|
+
if (result.length === 0) {
|
|
852
|
+
return this;
|
|
1089
853
|
}
|
|
1090
|
-
} else {
|
|
1091
|
-
var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
|
|
1092
854
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
855
|
+
var next = typeof result === 'string' ? new PrintBuffer(result) : result;
|
|
856
|
+
((_this$tail = this.tail) !== null && _this$tail !== void 0 ? _this$tail : this).next = next;
|
|
857
|
+
this.tail = (_next$tail = next.tail) !== null && _next$tail !== void 0 ? _next$tail : next;
|
|
858
|
+
this.length += next.length;
|
|
859
|
+
this.newlines += next.newlines;
|
|
860
|
+
return this;
|
|
861
|
+
};
|
|
1098
862
|
|
|
1099
|
-
|
|
863
|
+
_proto.indent = function indent() {
|
|
864
|
+
var _this$tail2;
|
|
1100
865
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
return specificKindVisitor;
|
|
1104
|
-
}
|
|
866
|
+
if (this.length === 0) {
|
|
867
|
+
return this;
|
|
1105
868
|
}
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
869
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
*
|
|
1115
|
-
* @internal
|
|
1116
|
-
*/
|
|
1117
|
-
/**
|
|
1118
|
-
* Print a block string in the indented block form by adding a leading and
|
|
1119
|
-
* trailing blank line. However, if a block string starts with whitespace and is
|
|
1120
|
-
* a single-line, adding a leading blank line would strip that whitespace.
|
|
1121
|
-
*
|
|
1122
|
-
* @internal
|
|
1123
|
-
*/
|
|
870
|
+
this.indentBefore = true;
|
|
871
|
+
((_this$tail2 = this.tail) !== null && _this$tail2 !== void 0 ? _this$tail2 : this).dedentAfter = true;
|
|
872
|
+
this.length += 2 * (this.newlines + 1);
|
|
873
|
+
return this;
|
|
874
|
+
};
|
|
1124
875
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
var preferMultipleLines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1128
|
-
var isSingleLine = value.indexOf('\n') === -1;
|
|
1129
|
-
var hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
|
|
1130
|
-
var hasTrailingQuote = value[value.length - 1] === '"';
|
|
1131
|
-
var hasTrailingSlash = value[value.length - 1] === '\\';
|
|
1132
|
-
var printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;
|
|
1133
|
-
var result = ''; // Format a multi-line block quote to account for leading space.
|
|
876
|
+
return PrintBuffer;
|
|
877
|
+
}();
|
|
1134
878
|
|
|
1135
|
-
|
|
1136
|
-
result += '\n' + indentation;
|
|
1137
|
-
}
|
|
879
|
+
var EMPTY = new PrintBuffer();
|
|
1138
880
|
|
|
1139
|
-
|
|
881
|
+
function render(buffer, maxDepth) {
|
|
882
|
+
var output = '';
|
|
883
|
+
var text = '';
|
|
884
|
+
var depth = 0;
|
|
885
|
+
var indentation = '';
|
|
886
|
+
var part = buffer;
|
|
1140
887
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
}
|
|
888
|
+
while (part !== undefined) {
|
|
889
|
+
var lines = part.lines;
|
|
1144
890
|
|
|
1145
|
-
|
|
1146
|
-
|
|
891
|
+
if (part.indentBefore) {
|
|
892
|
+
if (depth < maxDepth) {
|
|
893
|
+
indentation += ' ';
|
|
894
|
+
text += ' ';
|
|
895
|
+
}
|
|
1147
896
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
* formatting rules.
|
|
1151
|
-
*/
|
|
897
|
+
depth++;
|
|
898
|
+
}
|
|
1152
899
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
900
|
+
if (typeof lines === 'string') {
|
|
901
|
+
text += lines;
|
|
902
|
+
} else {
|
|
903
|
+
text += lines[0];
|
|
904
|
+
var newline = !part.isBlockString && depth >= maxDepth ? ' ' : '\n' + indentation;
|
|
905
|
+
|
|
906
|
+
for (var i = 1; i < lines.length; i++) {
|
|
907
|
+
output += text;
|
|
908
|
+
text = newline + lines[i];
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
if (part.dedentAfter) {
|
|
913
|
+
depth--;
|
|
914
|
+
indentation = indentation.slice(0, depth * 2);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
part = part.next;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
return output + text;
|
|
1157
921
|
}
|
|
1158
|
-
var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future
|
|
1159
922
|
|
|
1160
923
|
var printDocASTReducer = {
|
|
1161
924
|
Name: function Name(node) {
|
|
1162
|
-
return node.value;
|
|
925
|
+
return new PrintBuffer(node.value);
|
|
1163
926
|
},
|
|
1164
927
|
Variable: function Variable(node) {
|
|
1165
|
-
return '$'
|
|
928
|
+
return join(['$', node.name]);
|
|
1166
929
|
},
|
|
1167
930
|
// Document
|
|
1168
931
|
Document: function Document(node) {
|
|
1169
|
-
return join(node.definitions, '\n\n')
|
|
932
|
+
return join([join(node.definitions, '\n\n'), '\n']);
|
|
1170
933
|
},
|
|
1171
934
|
OperationDefinition: function OperationDefinition(node) {
|
|
1172
|
-
var op = node.operation;
|
|
1173
|
-
var name = node.name;
|
|
1174
935
|
var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
|
|
1175
936
|
var directives = join(node.directives, ' ');
|
|
1176
|
-
|
|
1177
|
-
// the query short form.
|
|
1178
|
-
|
|
1179
|
-
return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
|
|
937
|
+
return !node.name && directives.length === 0 && varDefs.length === 0 && node.operation === 'query' ? node.selectionSet : join([node.operation, join([node.name, varDefs]), directives, node.selectionSet], ' ');
|
|
1180
938
|
},
|
|
1181
939
|
VariableDefinition: function VariableDefinition(_ref) {
|
|
1182
940
|
var variable = _ref.variable,
|
|
1183
941
|
type = _ref.type,
|
|
1184
942
|
defaultValue = _ref.defaultValue,
|
|
1185
943
|
directives = _ref.directives;
|
|
1186
|
-
return variable
|
|
944
|
+
return join([variable, ': ', type, wrap(' = ', defaultValue), wrap(' ', join(directives, ' '))]);
|
|
1187
945
|
},
|
|
1188
946
|
SelectionSet: function SelectionSet(_ref2) {
|
|
1189
947
|
var selections = _ref2.selections;
|
|
@@ -1195,25 +953,19 @@ var printDocASTReducer = {
|
|
|
1195
953
|
args = _ref3.arguments,
|
|
1196
954
|
directives = _ref3.directives,
|
|
1197
955
|
selectionSet = _ref3.selectionSet;
|
|
1198
|
-
var prefix = wrap('', alias, ': ')
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
1202
|
-
argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
return join([argsLine, join(directives, ' '), selectionSet], ' ');
|
|
956
|
+
var prefix = join([wrap('', alias, ': '), name], '');
|
|
957
|
+
return join([wrappedLineAndArgs(prefix, args), wrap(' ', join(directives, ' ')), wrap(' ', selectionSet)]);
|
|
1206
958
|
},
|
|
1207
959
|
Argument: function Argument(_ref4) {
|
|
1208
960
|
var name = _ref4.name,
|
|
1209
961
|
value = _ref4.value;
|
|
1210
|
-
return name
|
|
962
|
+
return join([name, ': ', value]);
|
|
1211
963
|
},
|
|
1212
964
|
// Fragments
|
|
1213
965
|
FragmentSpread: function FragmentSpread(_ref5) {
|
|
1214
966
|
var name = _ref5.name,
|
|
1215
967
|
directives = _ref5.directives;
|
|
1216
|
-
return '...'
|
|
968
|
+
return join(['...', name, wrap(' ', join(directives, ' '))]);
|
|
1217
969
|
},
|
|
1218
970
|
InlineFragment: function InlineFragment(_ref6) {
|
|
1219
971
|
var typeCondition = _ref6.typeCondition,
|
|
@@ -1227,54 +979,53 @@ var printDocASTReducer = {
|
|
|
1227
979
|
variableDefinitions = _ref7.variableDefinitions,
|
|
1228
980
|
directives = _ref7.directives,
|
|
1229
981
|
selectionSet = _ref7.selectionSet;
|
|
1230
|
-
return (// Note: fragment variable definitions are experimental and may be changed
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
);
|
|
982
|
+
return join([// Note: fragment variable definitions are experimental and may be changed
|
|
983
|
+
// or removed in the future.
|
|
984
|
+
'fragment ', name, wrap('(', join(variableDefinitions, ', '), ')'), ' on ', typeCondition, ' ', wrap('', join(directives, ' '), ' '), selectionSet]);
|
|
1234
985
|
},
|
|
1235
986
|
// Value
|
|
1236
987
|
IntValue: function IntValue(_ref8) {
|
|
1237
988
|
var value = _ref8.value;
|
|
1238
|
-
return value;
|
|
989
|
+
return new PrintBuffer(value);
|
|
1239
990
|
},
|
|
1240
991
|
FloatValue: function FloatValue(_ref9) {
|
|
1241
992
|
var value = _ref9.value;
|
|
1242
|
-
return value;
|
|
993
|
+
return new PrintBuffer(value);
|
|
1243
994
|
},
|
|
1244
995
|
StringValue: function StringValue(_ref10, key) {
|
|
1245
996
|
var value = _ref10.value,
|
|
1246
997
|
isBlockString = _ref10.block;
|
|
1247
|
-
return isBlockString ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
|
|
998
|
+
return new PrintBuffer(isBlockString === true ? printBlockString(value, key === 'description' ? '' : ' ') : JSON.stringify(value), isBlockString === true);
|
|
1248
999
|
},
|
|
1249
1000
|
BooleanValue: function BooleanValue(_ref11) {
|
|
1250
1001
|
var value = _ref11.value;
|
|
1251
|
-
return value ? 'true' : 'false';
|
|
1002
|
+
return new PrintBuffer(value ? 'true' : 'false');
|
|
1252
1003
|
},
|
|
1253
1004
|
NullValue: function NullValue() {
|
|
1254
|
-
return 'null';
|
|
1005
|
+
return new PrintBuffer('null');
|
|
1255
1006
|
},
|
|
1256
1007
|
EnumValue: function EnumValue(_ref12) {
|
|
1257
1008
|
var value = _ref12.value;
|
|
1258
|
-
return value;
|
|
1009
|
+
return new PrintBuffer(value);
|
|
1259
1010
|
},
|
|
1260
1011
|
ListValue: function ListValue(_ref13) {
|
|
1261
1012
|
var values = _ref13.values;
|
|
1262
|
-
return '['
|
|
1013
|
+
return join(['[', join(values, ', '), ']']);
|
|
1263
1014
|
},
|
|
1264
1015
|
ObjectValue: function ObjectValue(_ref14) {
|
|
1265
1016
|
var fields = _ref14.fields;
|
|
1266
|
-
return '{'
|
|
1017
|
+
return join(['{', join(fields, ', '), '}']);
|
|
1267
1018
|
},
|
|
1268
1019
|
ObjectField: function ObjectField(_ref15) {
|
|
1269
1020
|
var name = _ref15.name,
|
|
1270
1021
|
value = _ref15.value;
|
|
1271
|
-
return name
|
|
1022
|
+
return join([name, ': ', value]);
|
|
1272
1023
|
},
|
|
1273
1024
|
// Directive
|
|
1274
1025
|
Directive: function Directive(_ref16) {
|
|
1275
1026
|
var name = _ref16.name,
|
|
1276
1027
|
args = _ref16.arguments;
|
|
1277
|
-
return '@'
|
|
1028
|
+
return join(['@', name, wrap('(', join(args, ', '), ')')]);
|
|
1278
1029
|
},
|
|
1279
1030
|
// Type
|
|
1280
1031
|
NamedType: function NamedType(_ref17) {
|
|
@@ -1283,86 +1034,97 @@ var printDocASTReducer = {
|
|
|
1283
1034
|
},
|
|
1284
1035
|
ListType: function ListType(_ref18) {
|
|
1285
1036
|
var type = _ref18.type;
|
|
1286
|
-
return '['
|
|
1037
|
+
return join(['[', type, ']']);
|
|
1287
1038
|
},
|
|
1288
1039
|
NonNullType: function NonNullType(_ref19) {
|
|
1289
1040
|
var type = _ref19.type;
|
|
1290
|
-
return type
|
|
1041
|
+
return join([type, '!']);
|
|
1291
1042
|
},
|
|
1292
1043
|
// Type System Definitions
|
|
1293
|
-
SchemaDefinition:
|
|
1294
|
-
var
|
|
1044
|
+
SchemaDefinition: function SchemaDefinition(_ref20) {
|
|
1045
|
+
var description = _ref20.description,
|
|
1046
|
+
directives = _ref20.directives,
|
|
1295
1047
|
operationTypes = _ref20.operationTypes;
|
|
1296
|
-
return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
1297
|
-
}
|
|
1048
|
+
return join([wrap('', description, '\n'), join(['schema', join(directives, ' '), block(operationTypes)], ' ')]);
|
|
1049
|
+
},
|
|
1298
1050
|
OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
|
|
1299
1051
|
var operation = _ref21.operation,
|
|
1300
1052
|
type = _ref21.type;
|
|
1301
|
-
return operation
|
|
1053
|
+
return join([operation, ': ', type]);
|
|
1302
1054
|
},
|
|
1303
|
-
ScalarTypeDefinition:
|
|
1304
|
-
var
|
|
1055
|
+
ScalarTypeDefinition: function ScalarTypeDefinition(_ref22) {
|
|
1056
|
+
var description = _ref22.description,
|
|
1057
|
+
name = _ref22.name,
|
|
1305
1058
|
directives = _ref22.directives;
|
|
1306
|
-
return join(['scalar', name, join(directives, ' ')], ' ');
|
|
1307
|
-
}
|
|
1308
|
-
ObjectTypeDefinition:
|
|
1309
|
-
var
|
|
1059
|
+
return join([wrap('', description, '\n'), join(['scalar', name, join(directives, ' ')], ' ')]);
|
|
1060
|
+
},
|
|
1061
|
+
ObjectTypeDefinition: function ObjectTypeDefinition(_ref23) {
|
|
1062
|
+
var description = _ref23.description,
|
|
1063
|
+
name = _ref23.name,
|
|
1310
1064
|
interfaces = _ref23.interfaces,
|
|
1311
1065
|
directives = _ref23.directives,
|
|
1312
1066
|
fields = _ref23.fields;
|
|
1313
|
-
return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
1314
|
-
}
|
|
1315
|
-
FieldDefinition:
|
|
1316
|
-
var
|
|
1067
|
+
return join([wrap('', description, '\n'), join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ')]);
|
|
1068
|
+
},
|
|
1069
|
+
FieldDefinition: function FieldDefinition(_ref24) {
|
|
1070
|
+
var description = _ref24.description,
|
|
1071
|
+
name = _ref24.name,
|
|
1317
1072
|
args = _ref24.arguments,
|
|
1318
1073
|
type = _ref24.type,
|
|
1319
1074
|
directives = _ref24.directives;
|
|
1320
|
-
return name
|
|
1321
|
-
}
|
|
1322
|
-
InputValueDefinition:
|
|
1323
|
-
var
|
|
1075
|
+
return join([wrap('', description, '\n'), name, hasMultilineItems(args) ? wrap('(\n', join(args, '\n').indent(), '\n)') : wrap('(', join(args, ', '), ')'), ': ', type, wrap(' ', join(directives, ' '))]);
|
|
1076
|
+
},
|
|
1077
|
+
InputValueDefinition: function InputValueDefinition(_ref25) {
|
|
1078
|
+
var description = _ref25.description,
|
|
1079
|
+
name = _ref25.name,
|
|
1324
1080
|
type = _ref25.type,
|
|
1325
1081
|
defaultValue = _ref25.defaultValue,
|
|
1326
1082
|
directives = _ref25.directives;
|
|
1327
|
-
return join([
|
|
1328
|
-
}
|
|
1329
|
-
InterfaceTypeDefinition:
|
|
1330
|
-
var
|
|
1083
|
+
return join([wrap('', description, '\n'), name, ': ', type, wrap(' = ', defaultValue), wrap(' ', join(directives, ' '))]);
|
|
1084
|
+
},
|
|
1085
|
+
InterfaceTypeDefinition: function InterfaceTypeDefinition(_ref26) {
|
|
1086
|
+
var description = _ref26.description,
|
|
1087
|
+
name = _ref26.name,
|
|
1331
1088
|
interfaces = _ref26.interfaces,
|
|
1332
1089
|
directives = _ref26.directives,
|
|
1333
1090
|
fields = _ref26.fields;
|
|
1334
|
-
return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
|
|
1335
|
-
}
|
|
1336
|
-
UnionTypeDefinition:
|
|
1337
|
-
var
|
|
1091
|
+
return join([wrap('', description, '\n'), join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ')]);
|
|
1092
|
+
},
|
|
1093
|
+
UnionTypeDefinition: function UnionTypeDefinition(_ref27) {
|
|
1094
|
+
var description = _ref27.description,
|
|
1095
|
+
name = _ref27.name,
|
|
1338
1096
|
directives = _ref27.directives,
|
|
1339
1097
|
types = _ref27.types;
|
|
1340
|
-
return join(['union', name, join(directives, ' '),
|
|
1341
|
-
}
|
|
1342
|
-
EnumTypeDefinition:
|
|
1343
|
-
var
|
|
1098
|
+
return join([wrap('', description, '\n'), join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ')]);
|
|
1099
|
+
},
|
|
1100
|
+
EnumTypeDefinition: function EnumTypeDefinition(_ref28) {
|
|
1101
|
+
var description = _ref28.description,
|
|
1102
|
+
name = _ref28.name,
|
|
1344
1103
|
directives = _ref28.directives,
|
|
1345
1104
|
values = _ref28.values;
|
|
1346
|
-
return join(['enum', name, join(directives, ' '), block(values)], ' ');
|
|
1347
|
-
}
|
|
1348
|
-
EnumValueDefinition:
|
|
1349
|
-
var
|
|
1105
|
+
return join([wrap('', description, '\n'), join(['enum', name, join(directives, ' '), block(values)], ' ')]);
|
|
1106
|
+
},
|
|
1107
|
+
EnumValueDefinition: function EnumValueDefinition(_ref29) {
|
|
1108
|
+
var description = _ref29.description,
|
|
1109
|
+
name = _ref29.name,
|
|
1350
1110
|
directives = _ref29.directives;
|
|
1351
|
-
return join([name, join(directives, ' ')], ' ');
|
|
1352
|
-
}
|
|
1353
|
-
InputObjectTypeDefinition:
|
|
1354
|
-
var
|
|
1111
|
+
return join([wrap('', description, '\n'), join([name, join(directives, ' ')], ' ')]);
|
|
1112
|
+
},
|
|
1113
|
+
InputObjectTypeDefinition: function InputObjectTypeDefinition(_ref30) {
|
|
1114
|
+
var description = _ref30.description,
|
|
1115
|
+
name = _ref30.name,
|
|
1355
1116
|
directives = _ref30.directives,
|
|
1356
1117
|
fields = _ref30.fields;
|
|
1357
|
-
return join(['input', name, join(directives, ' '), block(fields)], ' ');
|
|
1358
|
-
}
|
|
1359
|
-
DirectiveDefinition:
|
|
1360
|
-
var
|
|
1118
|
+
return join([wrap('', description, '\n'), join(['input', name, join(directives, ' '), block(fields)], ' ')]);
|
|
1119
|
+
},
|
|
1120
|
+
DirectiveDefinition: function DirectiveDefinition(_ref31) {
|
|
1121
|
+
var description = _ref31.description,
|
|
1122
|
+
name = _ref31.name,
|
|
1361
1123
|
args = _ref31.arguments,
|
|
1362
1124
|
repeatable = _ref31.repeatable,
|
|
1363
1125
|
locations = _ref31.locations;
|
|
1364
|
-
return 'directive @'
|
|
1365
|
-
}
|
|
1126
|
+
return join([wrap('', description, '\n'), 'directive @', name, hasMultilineItems(args) ? wrap('(\n', join(args, '\n').indent(), '\n)') : wrap('(', join(args, ', '), ')'), repeatable ? ' repeatable' : '', ' on ', join(locations, ' | ')]);
|
|
1127
|
+
},
|
|
1366
1128
|
SchemaExtension: function SchemaExtension(_ref32) {
|
|
1367
1129
|
var directives = _ref32.directives,
|
|
1368
1130
|
operationTypes = _ref32.operationTypes;
|
|
@@ -1391,7 +1153,7 @@ var printDocASTReducer = {
|
|
|
1391
1153
|
var name = _ref36.name,
|
|
1392
1154
|
directives = _ref36.directives,
|
|
1393
1155
|
types = _ref36.types;
|
|
1394
|
-
return join(['extend union', name, join(directives, ' '),
|
|
1156
|
+
return join(['extend union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
|
|
1395
1157
|
},
|
|
1396
1158
|
EnumTypeExtension: function EnumTypeExtension(_ref37) {
|
|
1397
1159
|
var name = _ref37.name,
|
|
@@ -1406,55 +1168,90 @@ var printDocASTReducer = {
|
|
|
1406
1168
|
return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
|
|
1407
1169
|
}
|
|
1408
1170
|
};
|
|
1409
|
-
|
|
1410
|
-
function addDescription(cb) {
|
|
1411
|
-
return function (node) {
|
|
1412
|
-
return join([node.description, cb(node)], '\n');
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1415
1171
|
/**
|
|
1416
1172
|
* Given maybeArray, print an empty string if it is null or empty, otherwise
|
|
1417
1173
|
* print all items together separated by separator if provided
|
|
1174
|
+
*
|
|
1175
|
+
* @internal
|
|
1418
1176
|
*/
|
|
1419
1177
|
|
|
1420
|
-
|
|
1421
1178
|
function join(maybeArray) {
|
|
1422
|
-
var _maybeArray$filter$jo;
|
|
1423
|
-
|
|
1424
1179
|
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1180
|
+
|
|
1181
|
+
if (maybeArray == null || maybeArray.length === 0) {
|
|
1182
|
+
return EMPTY;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
var result = EMPTY;
|
|
1186
|
+
|
|
1187
|
+
for (var _i2 = 0; _i2 < maybeArray.length; _i2++) {
|
|
1188
|
+
var item = maybeArray[_i2];
|
|
1189
|
+
|
|
1190
|
+
if (item === undefined || item.length === 0) {
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
if (result.length === 0) {
|
|
1195
|
+
result = typeof item === 'string' ? new PrintBuffer(item) : item;
|
|
1196
|
+
} else {
|
|
1197
|
+
if (separator !== '') {
|
|
1198
|
+
result.append(separator);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
result.append(item);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
return result;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
function joinedLength(array, separator) {
|
|
1209
|
+
var length = 0;
|
|
1210
|
+
|
|
1211
|
+
for (var _i4 = 0; _i4 < array.length; _i4++) {
|
|
1212
|
+
var item = array[_i4];
|
|
1213
|
+
|
|
1214
|
+
if (item.length !== 0) {
|
|
1215
|
+
length += (length === 0 ? 0 : separator.length) + item.length;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
return length;
|
|
1428
1220
|
}
|
|
1429
1221
|
/**
|
|
1430
|
-
* Given array, print each item on its own line, wrapped in an
|
|
1431
|
-
*
|
|
1222
|
+
* Given array, print each item on its own line, wrapped in an indented `{ }` block.
|
|
1223
|
+
*
|
|
1224
|
+
* @internal
|
|
1432
1225
|
*/
|
|
1433
1226
|
|
|
1434
1227
|
|
|
1435
1228
|
function block(array) {
|
|
1436
|
-
return wrap('{\n',
|
|
1229
|
+
return wrap('{\n', join(array, '\n').indent(), '\n}');
|
|
1437
1230
|
}
|
|
1438
1231
|
/**
|
|
1439
|
-
* If
|
|
1232
|
+
* If maybeBuffer is not null or empty, then wrap with start and end, otherwise print an empty string.
|
|
1233
|
+
*
|
|
1234
|
+
* @internal
|
|
1440
1235
|
*/
|
|
1441
1236
|
|
|
1442
1237
|
|
|
1443
|
-
function wrap(start,
|
|
1238
|
+
function wrap(start, maybeBuffer) {
|
|
1444
1239
|
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
1445
|
-
return
|
|
1240
|
+
return maybeBuffer != null && maybeBuffer.length !== 0 ? start === '' ? maybeBuffer.append(end) : new PrintBuffer(start).append(maybeBuffer).append(end) : EMPTY;
|
|
1446
1241
|
}
|
|
1447
1242
|
|
|
1448
|
-
function
|
|
1449
|
-
return
|
|
1243
|
+
function hasMultilineItems(maybeArray) {
|
|
1244
|
+
return maybeArray != null && maybeArray.some(function (result) {
|
|
1245
|
+
return result.newlines !== 0;
|
|
1246
|
+
});
|
|
1450
1247
|
}
|
|
1451
1248
|
|
|
1452
|
-
function
|
|
1453
|
-
|
|
1454
|
-
|
|
1249
|
+
function wrappedLineAndArgs(prefix, args) {
|
|
1250
|
+
if (args == null || args.length === 0) {
|
|
1251
|
+
return prefix;
|
|
1252
|
+
}
|
|
1455
1253
|
|
|
1456
|
-
|
|
1457
|
-
return maybeArray != null && maybeArray.some(isMultiline);
|
|
1254
|
+
return join([prefix, prefix.length + joinedLength(args, ', ') + 2 > MAX_LINE_LENGTH ? wrap('(\n', join(args, '\n').indent(), '\n)') : wrap('(', join(args, ', '), ')')]);
|
|
1458
1255
|
}
|
|
1459
1256
|
|
|
1460
1257
|
/**
|