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