@graphql-markdown/printer-legacy 1.4.3 → 1.5.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.
Files changed (66) hide show
  1. package/dist/badge.d.ts +5 -0
  2. package/dist/badge.js +66 -0
  3. package/dist/code.d.ts +3 -0
  4. package/dist/code.js +46 -0
  5. package/dist/common.d.ts +6 -0
  6. package/dist/common.js +69 -0
  7. package/dist/const/mdx.d.ts +2 -0
  8. package/{src → dist}/const/mdx.js +4 -1
  9. package/dist/const/options.d.ts +17 -0
  10. package/dist/const/options.js +33 -0
  11. package/dist/const/strings.d.ts +12 -0
  12. package/dist/const/strings.js +26 -0
  13. package/dist/directive.d.ts +6 -0
  14. package/dist/directive.js +76 -0
  15. package/dist/graphql/directive.d.ts +3 -0
  16. package/dist/graphql/directive.js +34 -0
  17. package/dist/graphql/enum.d.ts +3 -0
  18. package/dist/graphql/enum.js +37 -0
  19. package/dist/graphql/index.d.ts +8 -0
  20. package/dist/graphql/index.js +24 -0
  21. package/dist/graphql/input.d.ts +3 -0
  22. package/dist/graphql/input.js +7 -0
  23. package/dist/graphql/interface.d.ts +3 -0
  24. package/dist/graphql/interface.js +7 -0
  25. package/dist/graphql/object.d.ts +4 -0
  26. package/dist/graphql/object.js +47 -0
  27. package/dist/graphql/operation.d.ts +4 -0
  28. package/dist/graphql/operation.js +27 -0
  29. package/dist/graphql/scalar.d.ts +4 -0
  30. package/dist/graphql/scalar.js +26 -0
  31. package/dist/graphql/union.d.ts +3 -0
  32. package/dist/graphql/union.js +27 -0
  33. package/dist/group.d.ts +2 -0
  34. package/dist/group.js +22 -0
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.js +5 -0
  37. package/dist/link.d.ts +9 -0
  38. package/dist/link.js +137 -0
  39. package/dist/printer.d.ts +21 -0
  40. package/dist/printer.js +166 -0
  41. package/dist/relation.d.ts +4 -0
  42. package/dist/relation.js +71 -0
  43. package/dist/section.d.ts +6 -0
  44. package/dist/section.js +136 -0
  45. package/package.json +51 -7
  46. package/src/badge.js +0 -70
  47. package/src/code.js +0 -60
  48. package/src/common.js +0 -66
  49. package/src/const/options.js +0 -28
  50. package/src/const/strings.js +0 -48
  51. package/src/directive.js +0 -105
  52. package/src/graphql/directive.js +0 -47
  53. package/src/graphql/enum.js +0 -47
  54. package/src/graphql/index.js +0 -10
  55. package/src/graphql/input.js +0 -10
  56. package/src/graphql/interface.js +0 -10
  57. package/src/graphql/object.js +0 -56
  58. package/src/graphql/operation.js +0 -28
  59. package/src/graphql/scalar.js +0 -30
  60. package/src/graphql/union.js +0 -31
  61. package/src/group.js +0 -21
  62. package/src/index.js +0 -3
  63. package/src/link.js +0 -182
  64. package/src/printer.js +0 -242
  65. package/src/relation.js +0 -92
  66. package/src/section.js +0 -185
package/src/section.js DELETED
@@ -1,185 +0,0 @@
1
- const {
2
- graphql: { isParametrizedField, hasDirective, isDeprecated },
3
- } = require("@graphql-markdown/utils");
4
- const { hasProperty } = require("@graphql-markdown/utils/src/object");
5
-
6
- const { printDescription } = require("./common");
7
- const { printBadges } = require("./badge");
8
- const { printLink, printParentLink } = require("./link");
9
- const { printCustomTags } = require("./directive");
10
-
11
- const {
12
- HEADER_SECTION_ITEM_LEVEL,
13
- HEADER_SECTION_LEVEL,
14
- HEADER_SECTION_SUB_LEVEL,
15
- HIDE_DEPRECATED,
16
- MARKDOWN_EOL,
17
- MARKDOWN_EOP,
18
- SHOW_DEPRECATED,
19
- } = require("./const/strings");
20
-
21
- const { OPTION_DEPRECATED } = require("./const/options");
22
-
23
- const sectionLevels = [
24
- HEADER_SECTION_LEVEL,
25
- HEADER_SECTION_SUB_LEVEL,
26
- HEADER_SECTION_ITEM_LEVEL,
27
- ];
28
-
29
- const printMetadataSection = (type, values, section, options) => {
30
- switch (options.printDeprecated) {
31
- case OPTION_DEPRECATED.GROUP: {
32
- const { fields, deprecated } = values.reduce(
33
- (res, arg) => {
34
- isDeprecated(arg) ? res.deprecated.push(arg) : res.fields.push(arg);
35
- return res;
36
- },
37
- { fields: [], deprecated: [] },
38
- );
39
-
40
- const meta = printSection(fields, section, {
41
- ...options,
42
- parentType: type.name,
43
- });
44
- const deprecatedMeta = printSection(deprecated, "", {
45
- ...options,
46
- parentType: type.name,
47
- level: "",
48
- collapsible: {
49
- dataOpen: HIDE_DEPRECATED,
50
- dataClose: SHOW_DEPRECATED,
51
- },
52
- });
53
-
54
- return `${meta}${deprecatedMeta}`;
55
- }
56
-
57
- case OPTION_DEPRECATED.DEFAULT:
58
- default:
59
- return printSection(values, section, {
60
- ...options,
61
- parentType: type.name,
62
- });
63
- }
64
- };
65
-
66
- const printSection = (values, section, options) => {
67
- const level =
68
- hasProperty(options, "level") &&
69
- typeof options.level !== "undefined" &&
70
- options.level !== null
71
- ? options.level
72
- : HEADER_SECTION_LEVEL;
73
-
74
- if (!Array.isArray(values) || values.length === 0) {
75
- return "";
76
- }
77
-
78
- const levelPosition = sectionLevels.indexOf(level);
79
-
80
- const [openSection, closeSection] = (() => {
81
- if (
82
- hasProperty(options, "collapsible") &&
83
- hasProperty(options.collapsible, "dataOpen") &&
84
- hasProperty(options.collapsible, "dataClose")
85
- ) {
86
- return [
87
- `${MARKDOWN_EOP}<Details dataOpen={${options.collapsible.dataOpen}} dataClose={${options.collapsible.dataClose}}>${MARKDOWN_EOP}`,
88
- `${MARKDOWN_EOP}</Details>${MARKDOWN_EOP}`,
89
- ];
90
- }
91
- return [MARKDOWN_EOP, MARKDOWN_EOP];
92
- })();
93
-
94
- const items = printSectionItems(values, {
95
- ...options,
96
- collapsible: undefined, // do not propagate collapsible
97
- level: levelPosition > -1 ? sectionLevels[levelPosition + 1] : undefined,
98
- });
99
-
100
- if (items === "") {
101
- return ""; // do not print section is no items printed
102
- }
103
-
104
- return `${level} ${section}${openSection}${items}${closeSection}`;
105
- };
106
-
107
- const printSectionItems = (values, options) => {
108
- const level =
109
- hasProperty(options, "level") &&
110
- typeof options.level !== "undefined" &&
111
- options.level !== null
112
- ? options.level
113
- : HEADER_SECTION_SUB_LEVEL;
114
-
115
- if (!Array.isArray(values) || values.length === 0) {
116
- return "";
117
- }
118
-
119
- return values
120
- .map(
121
- (v) =>
122
- v &&
123
- printSectionItem(v, {
124
- ...options,
125
- level,
126
- }),
127
- )
128
- .join(MARKDOWN_EOP);
129
- };
130
-
131
- const printSectionItem = (type, options) => {
132
- const level =
133
- hasProperty(options, "level") &&
134
- typeof options.level !== "undefined" &&
135
- options.level !== null
136
- ? options.level
137
- : HEADER_SECTION_SUB_LEVEL;
138
-
139
- const skipDirective =
140
- hasProperty(options, "skipDocDirective") &&
141
- hasDirective(type, options.skipDocDirective) === true;
142
- const skipDeprecated =
143
- hasProperty(options, "printDeprecated") &&
144
- options.printDeprecated === OPTION_DEPRECATED.SKIP &&
145
- isDeprecated(type) === true;
146
-
147
- if (
148
- typeof type === "undefined" ||
149
- type === null ||
150
- skipDirective === true ||
151
- skipDeprecated === true
152
- ) {
153
- return "";
154
- }
155
-
156
- const typeNameLink = printLink(type, { ...options, withAttributes: false });
157
- const description = printDescription(type, options, "").replaceAll(
158
- "\n",
159
- `${MARKDOWN_EOL}> `,
160
- );
161
- const badges = printBadges(type, options);
162
- const tags = printCustomTags(type, options);
163
- const parentTypeLink = printParentLink(type, options);
164
-
165
- let section = `${level} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${MARKDOWN_EOL}> ${description}${MARKDOWN_EOL}> `;
166
- if (isParametrizedField(type)) {
167
- section += printSectionItems(type.args, {
168
- ...options,
169
- level: HEADER_SECTION_ITEM_LEVEL,
170
- parentType:
171
- typeof options.parentType === "undefined"
172
- ? type.name
173
- : `${options.parentType}.${type.name}`,
174
- });
175
- }
176
-
177
- return section;
178
- };
179
-
180
- module.exports = {
181
- printSection,
182
- printSectionItem,
183
- printSectionItems,
184
- printMetadataSection,
185
- };