@graphql-markdown/printer-legacy 1.5.0-next.0 → 1.5.1
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/badge.d.ts +1 -1
- package/dist/badge.js +10 -8
- package/dist/code.d.ts +1 -1
- package/dist/code.js +17 -23
- package/dist/common.d.ts +1 -0
- package/dist/common.js +26 -3
- package/dist/const/options.d.ts +6 -5
- package/dist/const/options.js +4 -1
- package/dist/directive.d.ts +2 -2
- package/dist/directive.js +36 -26
- package/dist/graphql/enum.d.ts +1 -1
- package/dist/graphql/enum.js +5 -7
- package/dist/graphql/input.js +3 -1
- package/dist/graphql/interface.js +3 -1
- package/dist/graphql/object.js +9 -3
- package/dist/graphql/union.js +3 -1
- package/dist/link.d.ts +4 -4
- package/dist/link.js +39 -36
- package/dist/printer.d.ts +9 -6
- package/dist/printer.js +27 -11
- package/dist/relation.js +10 -5
- package/dist/section.d.ts +4 -4
- package/dist/section.js +83 -77
- package/package.json +5 -5
package/dist/badge.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntitiesGroupMap } from "@graphql-markdown/types";
|
|
2
2
|
export declare const DEFAULT_CSS_CLASSNAME: "badge--secondary";
|
|
3
3
|
export declare const getTypeBadges: (type: unknown, groups?: Maybe<SchemaEntitiesGroupMap>) => Badge[];
|
|
4
|
-
export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
5
4
|
export declare const printBadge: ({ text, classname }: Badge) => MDXString;
|
|
5
|
+
export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
package/dist/badge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printBadges = exports.printBadge = exports.getTypeBadges = exports.DEFAULT_CSS_CLASSNAME = void 0;
|
|
4
4
|
const utils_1 = require("@graphql-markdown/utils");
|
|
5
5
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
6
6
|
const link_1 = require("./link");
|
|
@@ -41,6 +41,12 @@ const getTypeBadges = (type, groups) => {
|
|
|
41
41
|
return badges;
|
|
42
42
|
};
|
|
43
43
|
exports.getTypeBadges = getTypeBadges;
|
|
44
|
+
const printBadge = ({ text, classname }) => {
|
|
45
|
+
const textString = typeof text === "string" ? text : text.singular;
|
|
46
|
+
const formattedText = (0, utils_1.escapeMDX)(textString);
|
|
47
|
+
return `<Badge class="badge ${classname}" text="${formattedText}"/>`;
|
|
48
|
+
};
|
|
49
|
+
exports.printBadge = printBadge;
|
|
44
50
|
const printBadges = (type, options) => {
|
|
45
51
|
if (!("typeBadges" in options) ||
|
|
46
52
|
typeof options.typeBadges !== "boolean" ||
|
|
@@ -52,13 +58,9 @@ const printBadges = (type, options) => {
|
|
|
52
58
|
return "";
|
|
53
59
|
}
|
|
54
60
|
return badges
|
|
55
|
-
.map((badge) =>
|
|
61
|
+
.map((badge) => {
|
|
62
|
+
return (0, exports.printBadge)(badge);
|
|
63
|
+
})
|
|
56
64
|
.join(" ");
|
|
57
65
|
};
|
|
58
66
|
exports.printBadges = printBadges;
|
|
59
|
-
const printBadge = ({ text, classname }) => {
|
|
60
|
-
const textString = typeof text === "string" ? text : text.singular;
|
|
61
|
-
const formattedText = (0, utils_1.escapeMDX)(textString);
|
|
62
|
-
return `<Badge class="badge ${classname}" text="${formattedText}"/>`;
|
|
63
|
-
};
|
|
64
|
-
exports.printBadge = printBadge;
|
package/dist/code.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
|
-
export declare const printCodeField: (type: unknown, options?: PrintTypeOptions, indentationLevel?: number) => MDXString | string;
|
|
3
2
|
export declare const printCodeArguments: (type: unknown, indentationLevel?: number) => string;
|
|
3
|
+
export declare const printCodeField: (type: unknown, options?: PrintTypeOptions, indentationLevel?: number) => MDXString | string;
|
package/dist/code.js
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printCodeField = exports.printCodeArguments = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const strings_1 = require("./const/strings");
|
|
6
|
-
const
|
|
7
|
-
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
8
|
-
return "";
|
|
9
|
-
}
|
|
10
|
-
const skipDirective = options &&
|
|
11
|
-
"skipDocDirective" in options &&
|
|
12
|
-
(0, graphql_1.hasDirective)(type, options.skipDocDirective);
|
|
13
|
-
const skipDeprecated = options &&
|
|
14
|
-
"deprecated" in options &&
|
|
15
|
-
options.deprecated === "skip" &&
|
|
16
|
-
(0, graphql_1.isDeprecated)(type);
|
|
17
|
-
if (skipDirective || skipDeprecated) {
|
|
18
|
-
return "";
|
|
19
|
-
}
|
|
20
|
-
let code = `${(0, graphql_1.getTypeName)(type)}`;
|
|
21
|
-
code += (0, exports.printCodeArguments)(type, indentationLevel + 1);
|
|
22
|
-
code += `: ${(0, graphql_1.getTypeName)(type.type)}`;
|
|
23
|
-
code += (0, graphql_1.isDeprecated)(type) ? ` @${strings_1.DEPRECATED}` : "";
|
|
24
|
-
code += strings_1.MARKDOWN_EOL;
|
|
25
|
-
return code;
|
|
26
|
-
};
|
|
27
|
-
exports.printCodeField = printCodeField;
|
|
6
|
+
const common_1 = require("./common");
|
|
28
7
|
const printCodeArguments = (type, indentationLevel = 1) => {
|
|
29
8
|
if (typeof type !== "object" ||
|
|
30
9
|
type === null ||
|
|
@@ -50,3 +29,18 @@ const printCodeArguments = (type, indentationLevel = 1) => {
|
|
|
50
29
|
return code;
|
|
51
30
|
};
|
|
52
31
|
exports.printCodeArguments = printCodeArguments;
|
|
32
|
+
const printCodeField = (type, options, indentationLevel = 0) => {
|
|
33
|
+
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
if (!(0, common_1.hasPrintableDirective)(type, options)) {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
let code = `${(0, graphql_1.getTypeName)(type)}`;
|
|
40
|
+
code += (0, exports.printCodeArguments)(type, indentationLevel + 1);
|
|
41
|
+
code += `: ${(0, graphql_1.getTypeName)(type.type)}`;
|
|
42
|
+
code += (0, graphql_1.isDeprecated)(type) ? ` @${strings_1.DEPRECATED}` : "";
|
|
43
|
+
code += strings_1.MARKDOWN_EOL;
|
|
44
|
+
return code;
|
|
45
|
+
};
|
|
46
|
+
exports.printCodeField = printCodeField;
|
package/dist/common.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare const printCustomDirectives: (type: unknown, options?: PrintTypeO
|
|
|
3
3
|
export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => MDXString | string;
|
|
4
4
|
export declare const printDeprecation: (type: unknown) => string;
|
|
5
5
|
export declare const printDescription: (type: unknown, options?: PrintTypeOptions, noText?: string) => MDXString | string;
|
|
6
|
+
export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
|
package/dist/common.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printDescription = exports.printDeprecation = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
3
|
+
exports.hasPrintableDirective = exports.printDescription = exports.printDeprecation = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
4
4
|
const utils_1 = require("@graphql-markdown/utils");
|
|
5
5
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
6
6
|
const directive_1 = require("./directive");
|
|
@@ -11,8 +11,12 @@ const printCustomDirectives = (type, options) => {
|
|
|
11
11
|
return "";
|
|
12
12
|
}
|
|
13
13
|
const content = Object.values(constDirectiveMap)
|
|
14
|
-
.map((constDirectiveOption) =>
|
|
15
|
-
.
|
|
14
|
+
.map((constDirectiveOption) => {
|
|
15
|
+
return (0, directive_1.getCustomDirectiveResolver)("descriptor", type, constDirectiveOption, "");
|
|
16
|
+
})
|
|
17
|
+
.filter((text) => {
|
|
18
|
+
return typeof text === "string" && text.length > 0;
|
|
19
|
+
})
|
|
16
20
|
.join(strings_1.MARKDOWN_EOP);
|
|
17
21
|
return `${strings_1.MARKDOWN_EOP}${content}`;
|
|
18
22
|
};
|
|
@@ -44,3 +48,22 @@ const printDescription = (type, options, noText) => {
|
|
|
44
48
|
return `${deprecation}${description}${customDirectives}`;
|
|
45
49
|
};
|
|
46
50
|
exports.printDescription = printDescription;
|
|
51
|
+
const hasPrintableDirective = (type, options) => {
|
|
52
|
+
if (!type) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (!options) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const skipDirective = "skipDocDirectives" in options && options.skipDocDirectives
|
|
59
|
+
? (0, graphql_1.hasDirective)(type, options.skipDocDirectives)
|
|
60
|
+
: false;
|
|
61
|
+
const skipDeprecated = "deprecated" in options &&
|
|
62
|
+
options.deprecated === "skip" &&
|
|
63
|
+
(0, graphql_1.isDeprecated)(type);
|
|
64
|
+
const onlyDirective = "onlyDocDirectives" in options && options.onlyDocDirectives
|
|
65
|
+
? (0, graphql_1.hasDirective)(type, options.onlyDocDirectives, true)
|
|
66
|
+
: true;
|
|
67
|
+
return !(skipDirective || skipDeprecated) && onlyDirective;
|
|
68
|
+
};
|
|
69
|
+
exports.hasPrintableDirective = hasPrintableDirective;
|
package/dist/const/options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollapsibleOption,
|
|
1
|
+
import type { CollapsibleOption, GraphQLDirective, GraphQLSchema, Maybe, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, SectionLevelValue } from "@graphql-markdown/types";
|
|
2
2
|
export declare enum SectionLevels {
|
|
3
3
|
NONE = "",
|
|
4
4
|
LEVEL_3 = "###",
|
|
@@ -6,11 +6,12 @@ export declare enum SectionLevels {
|
|
|
6
6
|
LEVEL_5 = "#####"
|
|
7
7
|
}
|
|
8
8
|
export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<PrinterConfigPrintTypeOptions>;
|
|
9
|
-
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "parentType" | "schema" | "
|
|
10
|
-
schema: Maybe<GraphQLSchema>;
|
|
11
|
-
skipDocDirective: Maybe<DirectiveName[]>;
|
|
9
|
+
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
12
10
|
collapsible: Maybe<CollapsibleOption>;
|
|
13
|
-
parentType: Maybe<string>;
|
|
14
11
|
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
15
12
|
level: Maybe<SectionLevelValue>;
|
|
13
|
+
onlyDocDirectives: GraphQLDirective[];
|
|
14
|
+
parentType: Maybe<string>;
|
|
15
|
+
schema: Maybe<GraphQLSchema>;
|
|
16
|
+
skipDocDirectives: GraphQLDirective[];
|
|
16
17
|
};
|
package/dist/const/options.js
CHANGED
|
@@ -11,6 +11,7 @@ var SectionLevels;
|
|
|
11
11
|
exports.PRINT_TYPE_DEFAULT_OPTIONS = {
|
|
12
12
|
codeSection: true,
|
|
13
13
|
deprecated: "default",
|
|
14
|
+
metatags: [],
|
|
14
15
|
parentTypePrefix: true,
|
|
15
16
|
relatedTypeSection: true,
|
|
16
17
|
typeBadges: true,
|
|
@@ -23,8 +24,10 @@ exports.DEFAULT_OPTIONS = {
|
|
|
23
24
|
groups: undefined,
|
|
24
25
|
header: { toc: true, pagination: true },
|
|
25
26
|
level: undefined,
|
|
27
|
+
metatags: [],
|
|
28
|
+
onlyDocDirectives: [],
|
|
26
29
|
parentType: undefined,
|
|
27
30
|
schema: undefined,
|
|
28
|
-
|
|
31
|
+
skipDocDirectives: [],
|
|
29
32
|
withAttributes: false,
|
|
30
33
|
};
|
package/dist/directive.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Badge, PrintTypeOptions, MDXString, CustomDirectiveMapItem, CustomDirectiveResolver, Maybe } from "@graphql-markdown/types";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getCustomDirectiveResolver: (resolver: CustomDirectiveResolver, type: unknown, constDirectiveOption: CustomDirectiveMapItem, fallback?: Maybe<string>) => Maybe<string>;
|
|
3
3
|
export declare const printCustomDirective: (type: unknown, constDirectiveOption: CustomDirectiveMapItem, options: PrintTypeOptions) => Maybe<string>;
|
|
4
|
+
export declare const printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
4
5
|
export declare const getCustomTags: (type: unknown, options: PrintTypeOptions) => Badge[];
|
|
5
6
|
export declare const printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
6
|
-
export declare const getCustomDirectiveResolver: (resolver: CustomDirectiveResolver, type: unknown, constDirectiveOption: CustomDirectiveMapItem, fallback?: Maybe<string>) => Maybe<string>;
|
package/dist/directive.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printCustomTags = exports.getCustomTags = exports.printCustomDirectives = exports.printCustomDirective = exports.getCustomDirectiveResolver = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const strings_1 = require("./const/strings");
|
|
6
6
|
const options_1 = require("./const/options");
|
|
7
7
|
const link_1 = require("./link");
|
|
8
8
|
const badge_1 = require("./badge");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const directives = Object.values(constDirectiveMap)
|
|
15
|
-
.map((constDirectiveOption) => (0, exports.printCustomDirective)(type, constDirectiveOption, options))
|
|
16
|
-
.filter((value) => typeof value !== "undefined");
|
|
17
|
-
if (directives.length === 0) {
|
|
18
|
-
return "";
|
|
9
|
+
const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallback) => {
|
|
10
|
+
if (typeof constDirectiveOption === "undefined" ||
|
|
11
|
+
typeof constDirectiveOption.type !== "object" ||
|
|
12
|
+
typeof constDirectiveOption[resolver] !== "function") {
|
|
13
|
+
return fallback;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
return `${options_1.SectionLevels.LEVEL_3} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
15
|
+
return constDirectiveOption[resolver](constDirectiveOption.type, type);
|
|
22
16
|
};
|
|
23
|
-
exports.
|
|
17
|
+
exports.getCustomDirectiveResolver = getCustomDirectiveResolver;
|
|
24
18
|
const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
25
19
|
const typeNameLink = (0, link_1.printLink)(constDirectiveOption.type, {
|
|
26
20
|
...options,
|
|
@@ -33,6 +27,25 @@ const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
|
33
27
|
return `${options_1.SectionLevels.LEVEL_4} ${typeNameLink}${strings_1.MARKDOWN_EOL}> ${description}${strings_1.MARKDOWN_EOL}> `;
|
|
34
28
|
};
|
|
35
29
|
exports.printCustomDirective = printCustomDirective;
|
|
30
|
+
const printCustomDirectives = (type, options) => {
|
|
31
|
+
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
|
|
32
|
+
if (!constDirectiveMap || Object.keys(constDirectiveMap).length < 1) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
const directives = Object.values(constDirectiveMap)
|
|
36
|
+
.map((constDirectiveOption) => {
|
|
37
|
+
return (0, exports.printCustomDirective)(type, constDirectiveOption, options);
|
|
38
|
+
})
|
|
39
|
+
.filter((value) => {
|
|
40
|
+
return typeof value !== "undefined";
|
|
41
|
+
});
|
|
42
|
+
if (directives.length === 0) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
const content = directives.join(strings_1.MARKDOWN_EOP);
|
|
46
|
+
return `${options_1.SectionLevels.LEVEL_3} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
47
|
+
};
|
|
48
|
+
exports.printCustomDirectives = printCustomDirectives;
|
|
36
49
|
const getCustomTags = (type, options) => {
|
|
37
50
|
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
|
|
38
51
|
if (typeof constDirectiveMap !== "object" ||
|
|
@@ -41,8 +54,12 @@ const getCustomTags = (type, options) => {
|
|
|
41
54
|
return [];
|
|
42
55
|
}
|
|
43
56
|
return Object.values(constDirectiveMap)
|
|
44
|
-
.map((constDirectiveOption) =>
|
|
45
|
-
.
|
|
57
|
+
.map((constDirectiveOption) => {
|
|
58
|
+
return (0, exports.getCustomDirectiveResolver)("tag", type, constDirectiveOption);
|
|
59
|
+
})
|
|
60
|
+
.filter((value) => {
|
|
61
|
+
return typeof value !== "undefined";
|
|
62
|
+
});
|
|
46
63
|
};
|
|
47
64
|
exports.getCustomTags = getCustomTags;
|
|
48
65
|
const printCustomTags = (type, options) => {
|
|
@@ -51,16 +68,9 @@ const printCustomTags = (type, options) => {
|
|
|
51
68
|
return "";
|
|
52
69
|
}
|
|
53
70
|
return badges
|
|
54
|
-
.map((badge) =>
|
|
71
|
+
.map((badge) => {
|
|
72
|
+
return (0, badge_1.printBadge)(badge);
|
|
73
|
+
})
|
|
55
74
|
.join(" ");
|
|
56
75
|
};
|
|
57
76
|
exports.printCustomTags = printCustomTags;
|
|
58
|
-
const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallback) => {
|
|
59
|
-
if (typeof constDirectiveOption === "undefined" ||
|
|
60
|
-
typeof constDirectiveOption.type !== "object" ||
|
|
61
|
-
typeof constDirectiveOption[resolver] !== "function") {
|
|
62
|
-
return fallback;
|
|
63
|
-
}
|
|
64
|
-
return constDirectiveOption[resolver](constDirectiveOption.type, type);
|
|
65
|
-
};
|
|
66
|
-
exports.getCustomDirectiveResolver = getCustomDirectiveResolver;
|
package/dist/graphql/enum.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
2
|
export declare const printEnumMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
3
|
-
export declare const printCodeEnum: (type: unknown, options
|
|
3
|
+
export declare const printCodeEnum: (type: unknown, options?: PrintTypeOptions) => string;
|
package/dist/graphql/enum.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.printCodeEnum = exports.printEnumMetadata = void 0;
|
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const strings_1 = require("../const/strings");
|
|
6
6
|
const section_1 = require("../section");
|
|
7
|
+
const common_1 = require("../common");
|
|
7
8
|
const printEnumMetadata = (type, options) => {
|
|
8
9
|
if (!(0, graphql_1.isEnumType)(type)) {
|
|
9
10
|
return "";
|
|
@@ -19,19 +20,16 @@ const printCodeEnum = (type, options) => {
|
|
|
19
20
|
code += type
|
|
20
21
|
.getValues()
|
|
21
22
|
.map((value) => {
|
|
22
|
-
|
|
23
|
-
(0, graphql_1.hasDirective)(value, options.skipDocDirective);
|
|
24
|
-
const skipDeprecated = "deprecated" in options &&
|
|
25
|
-
options.deprecated === "skip" &&
|
|
26
|
-
(0, graphql_1.isDeprecated)(value);
|
|
27
|
-
if (skipDirective || skipDeprecated) {
|
|
23
|
+
if (!(0, common_1.hasPrintableDirective)(value, options)) {
|
|
28
24
|
return "";
|
|
29
25
|
}
|
|
30
26
|
const v = (0, graphql_1.getTypeName)(value);
|
|
31
27
|
const d = (0, graphql_1.isDeprecated)(value) ? ` @${strings_1.DEPRECATED}` : "";
|
|
32
28
|
return ` ${v}${d}`;
|
|
33
29
|
})
|
|
34
|
-
.filter((value) =>
|
|
30
|
+
.filter((value) => {
|
|
31
|
+
return value.length > 0;
|
|
32
|
+
})
|
|
35
33
|
.join(strings_1.MARKDOWN_EOL);
|
|
36
34
|
code += `${strings_1.MARKDOWN_EOL}}`;
|
|
37
35
|
return code;
|
package/dist/graphql/input.js
CHANGED
|
@@ -3,5 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printCodeInput = exports.printInputMetadata = void 0;
|
|
4
4
|
const object_1 = require("./object");
|
|
5
5
|
exports.printInputMetadata = object_1.printObjectMetadata;
|
|
6
|
-
const printCodeInput = (type, options) =>
|
|
6
|
+
const printCodeInput = (type, options) => {
|
|
7
|
+
return (0, object_1.printCodeType)(type, "input", options);
|
|
8
|
+
};
|
|
7
9
|
exports.printCodeInput = printCodeInput;
|
|
@@ -3,5 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printCodeInterface = exports.printInterfaceMetadata = void 0;
|
|
4
4
|
const object_1 = require("./object");
|
|
5
5
|
exports.printInterfaceMetadata = object_1.printObjectMetadata;
|
|
6
|
-
const printCodeInterface = (type, options) =>
|
|
6
|
+
const printCodeInterface = (type, options) => {
|
|
7
|
+
return (0, object_1.printCodeType)(type, "interface", options);
|
|
8
|
+
};
|
|
7
9
|
exports.printCodeInterface = printCodeInterface;
|
package/dist/graphql/object.js
CHANGED
|
@@ -30,7 +30,9 @@ const printCodeType = (type, entity, options) => {
|
|
|
30
30
|
type.getInterfaces().length > 0
|
|
31
31
|
? ` implements ${type
|
|
32
32
|
.getInterfaces()
|
|
33
|
-
.map((field) =>
|
|
33
|
+
.map((field) => {
|
|
34
|
+
return (0, graphql_1.getTypeName)(field);
|
|
35
|
+
})
|
|
34
36
|
.join(", ")}`
|
|
35
37
|
: "";
|
|
36
38
|
const typeFields = (0, graphql_1.getFields)(type)
|
|
@@ -38,10 +40,14 @@ const printCodeType = (type, entity, options) => {
|
|
|
38
40
|
const f = (0, code_1.printCodeField)(field, options, 1);
|
|
39
41
|
return f.length > 0 ? `${strings_1.MARKDOWN_CODE_INDENTATION}${f}` : "";
|
|
40
42
|
})
|
|
41
|
-
.filter((field) =>
|
|
43
|
+
.filter((field) => {
|
|
44
|
+
return field.length > 0;
|
|
45
|
+
})
|
|
42
46
|
.join("");
|
|
43
47
|
return `${entity} ${name}${extendsInterface} {${strings_1.MARKDOWN_EOL}${typeFields}}`;
|
|
44
48
|
};
|
|
45
49
|
exports.printCodeType = printCodeType;
|
|
46
|
-
const printCodeObject = (type, options) =>
|
|
50
|
+
const printCodeObject = (type, options) => {
|
|
51
|
+
return (0, exports.printCodeType)(type, "type", options);
|
|
52
|
+
};
|
|
47
53
|
exports.printCodeObject = printCodeObject;
|
package/dist/graphql/union.js
CHANGED
|
@@ -20,7 +20,9 @@ const printCodeUnion = (type, options) => {
|
|
|
20
20
|
let code = `union ${(0, graphql_1.getTypeName)(type)} = `;
|
|
21
21
|
code += type
|
|
22
22
|
.getTypes()
|
|
23
|
-
.map((v) =>
|
|
23
|
+
.map((v) => {
|
|
24
|
+
return (0, graphql_1.getTypeName)(v);
|
|
25
|
+
})
|
|
24
26
|
.join(" | ");
|
|
25
27
|
return code;
|
|
26
28
|
};
|
package/dist/link.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { MDXString, Maybe, PrintLinkOptions, TypeLink, TypeLocale } from "@graphql-markdown/types";
|
|
2
2
|
export declare const getLinkCategory: (type: unknown) => Maybe<TypeLocale>;
|
|
3
|
-
export declare const toLink: (type: unknown, name: string, operation: Maybe<TypeLocale>, options: PrintLinkOptions) => TypeLink;
|
|
4
|
-
export declare const getRelationLink: (category: Maybe<TypeLocale>, type: unknown, options: PrintLinkOptions) => Maybe<TypeLink>;
|
|
5
|
-
export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => MDXString | string;
|
|
6
3
|
export declare const hasOptionWithAttributes: (options: PrintLinkOptions) => boolean;
|
|
7
4
|
export declare const hasOptionParentType: (options: PrintLinkOptions) => boolean;
|
|
8
|
-
export declare const
|
|
5
|
+
export declare const toLink: (type: unknown, name: string, operation: Maybe<TypeLocale>, options: PrintLinkOptions) => TypeLink;
|
|
6
|
+
export declare const getRelationLink: (category: Maybe<TypeLocale>, type: unknown, options: PrintLinkOptions) => Maybe<TypeLink>;
|
|
9
7
|
export declare const printLinkAttributes: (type: unknown, text?: Maybe<string>) => string;
|
|
8
|
+
export declare const printLink: (type: unknown, options: PrintLinkOptions) => string;
|
|
9
|
+
export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => MDXString | string;
|
package/dist/link.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategory = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const utils_1 = require("@graphql-markdown/utils");
|
|
6
6
|
const group_1 = require("./group");
|
|
7
7
|
const strings_1 = require("./const/strings");
|
|
8
|
+
const common_1 = require("./common");
|
|
8
9
|
const getLinkCategory = (type) => {
|
|
9
10
|
switch (true) {
|
|
10
11
|
case (0, graphql_1.isDirectiveType)(type):
|
|
@@ -27,6 +28,17 @@ const getLinkCategory = (type) => {
|
|
|
27
28
|
return undefined;
|
|
28
29
|
};
|
|
29
30
|
exports.getLinkCategory = getLinkCategory;
|
|
31
|
+
const hasOptionWithAttributes = (options) => {
|
|
32
|
+
return "withAttributes" in options && options.withAttributes === true;
|
|
33
|
+
};
|
|
34
|
+
exports.hasOptionWithAttributes = hasOptionWithAttributes;
|
|
35
|
+
const hasOptionParentType = (options) => {
|
|
36
|
+
return ("parentTypePrefix" in options &&
|
|
37
|
+
options.parentTypePrefix === true &&
|
|
38
|
+
"parentType" in options &&
|
|
39
|
+
typeof options.parentType !== "undefined");
|
|
40
|
+
};
|
|
41
|
+
exports.hasOptionParentType = hasOptionParentType;
|
|
30
42
|
const toLink = (type, name, operation, options) => {
|
|
31
43
|
const fallback = {
|
|
32
44
|
text: name,
|
|
@@ -35,10 +47,8 @@ const toLink = (type, name, operation, options) => {
|
|
|
35
47
|
if (typeof type !== "object") {
|
|
36
48
|
return fallback;
|
|
37
49
|
}
|
|
38
|
-
if (typeof options !== "undefined" &&
|
|
39
|
-
|
|
40
|
-
return fallback;
|
|
41
|
-
}
|
|
50
|
+
if (typeof options !== "undefined" && !(0, common_1.hasPrintableDirective)(type, options)) {
|
|
51
|
+
return fallback;
|
|
42
52
|
}
|
|
43
53
|
const graphQLNamedType = (0, graphql_1.getNamedType)(type);
|
|
44
54
|
let category = (0, exports.getLinkCategory)(graphQLNamedType);
|
|
@@ -82,23 +92,24 @@ const getRelationLink = (category, type, options) => {
|
|
|
82
92
|
return (0, exports.toLink)(type, type.name, category, options);
|
|
83
93
|
};
|
|
84
94
|
exports.getRelationLink = getRelationLink;
|
|
85
|
-
const
|
|
86
|
-
if (typeof type !== "object" || type === null
|
|
87
|
-
return "";
|
|
95
|
+
const printLinkAttributes = (type, text = "") => {
|
|
96
|
+
if (typeof type !== "object" || type === null) {
|
|
97
|
+
return text ?? "";
|
|
88
98
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
if (!(0, graphql_1.isLeafType)(type) &&
|
|
100
|
+
"ofType" in type &&
|
|
101
|
+
typeof type.ofType !== "undefined") {
|
|
102
|
+
text = (0, exports.printLinkAttributes)(type.ofType, text);
|
|
103
|
+
}
|
|
104
|
+
if ((0, graphql_1.isListType)(type)) {
|
|
105
|
+
return `[${text}]`;
|
|
106
|
+
}
|
|
107
|
+
if ((0, graphql_1.isNonNullType)(type)) {
|
|
108
|
+
return `${text}!`;
|
|
109
|
+
}
|
|
110
|
+
return text ?? "";
|
|
93
111
|
};
|
|
94
|
-
exports.
|
|
95
|
-
const hasOptionWithAttributes = (options) => "withAttributes" in options && options.withAttributes === true;
|
|
96
|
-
exports.hasOptionWithAttributes = hasOptionWithAttributes;
|
|
97
|
-
const hasOptionParentType = (options) => "parentTypePrefix" in options &&
|
|
98
|
-
options.parentTypePrefix === true &&
|
|
99
|
-
"parentType" in options &&
|
|
100
|
-
typeof options.parentType !== "undefined";
|
|
101
|
-
exports.hasOptionParentType = hasOptionParentType;
|
|
112
|
+
exports.printLinkAttributes = printLinkAttributes;
|
|
102
113
|
const printLink = (type, options) => {
|
|
103
114
|
if (typeof type !== "object" || type === null) {
|
|
104
115
|
return "";
|
|
@@ -114,21 +125,13 @@ const printLink = (type, options) => {
|
|
|
114
125
|
return `[\`${text}\`](${link.url})`;
|
|
115
126
|
};
|
|
116
127
|
exports.printLink = printLink;
|
|
117
|
-
const
|
|
118
|
-
if (typeof type !== "object" || type === null) {
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
if (!(0, graphql_1.isLeafType)(type) &&
|
|
122
|
-
"ofType" in type &&
|
|
123
|
-
typeof type.ofType != "undefined") {
|
|
124
|
-
text = (0, exports.printLinkAttributes)(type.ofType, text);
|
|
125
|
-
}
|
|
126
|
-
if ((0, graphql_1.isListType)(type)) {
|
|
127
|
-
return `[${text}]`;
|
|
128
|
-
}
|
|
129
|
-
if ((0, graphql_1.isNonNullType)(type)) {
|
|
130
|
-
return `${text}!`;
|
|
128
|
+
const printParentLink = (type, options) => {
|
|
129
|
+
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
130
|
+
return "";
|
|
131
131
|
}
|
|
132
|
-
return
|
|
132
|
+
return `<Bullet />${(0, exports.printLink)(type.type, {
|
|
133
|
+
...options,
|
|
134
|
+
withAttributes: true,
|
|
135
|
+
})}`;
|
|
133
136
|
};
|
|
134
|
-
exports.
|
|
137
|
+
exports.printParentLink = printParentLink;
|
package/dist/printer.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import type { CustomDirectiveMap,
|
|
1
|
+
import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, Maybe, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
|
|
2
2
|
export declare class Printer implements IPrinter {
|
|
3
3
|
static options: Maybe<PrintTypeOptions>;
|
|
4
|
-
static
|
|
4
|
+
static printDescription: (type: unknown, options?: PrintTypeOptions | undefined, noText?: string | undefined) => string | MDXString;
|
|
5
|
+
static printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
6
|
+
static printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
|
|
7
|
+
static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, onlyDocDirectives, printTypeOptions, skipDocDirectives, metatags, }?: {
|
|
5
8
|
customDirectives?: CustomDirectiveMap;
|
|
6
9
|
deprecated?: TypeDeprecatedOption;
|
|
7
10
|
groups?: SchemaEntitiesGroupMap;
|
|
11
|
+
onlyDocDirectives?: GraphQLDirective[];
|
|
8
12
|
printTypeOptions?: PrinterConfigPrintTypeOptions;
|
|
9
|
-
|
|
13
|
+
skipDocDirectives?: GraphQLDirective[];
|
|
14
|
+
metatags?: Record<string, string>[];
|
|
10
15
|
}): void;
|
|
11
16
|
static printHeader: (id: string, title: string, options: PrintTypeOptions) => string;
|
|
12
|
-
static printDescription: (type: unknown, options?: PrintTypeOptions | undefined, noText?: string | undefined) => string | MDXString;
|
|
13
17
|
static printCode: (type: unknown, options: PrintTypeOptions) => string;
|
|
14
|
-
static printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
15
|
-
static printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
|
|
16
18
|
static printTypeMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
17
19
|
static printRelations: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
20
|
+
static printMetaTags: (_type: unknown, { metatags }: PrintTypeOptions) => MDXString | string;
|
|
18
21
|
static printType: (name: Maybe<string>, type: unknown, options?: Maybe<Partial<PrintTypeOptions>>) => Maybe<MDXString>;
|
|
19
22
|
}
|
package/dist/printer.js
CHANGED
|
@@ -12,11 +12,16 @@ const mdx_1 = require("./const/mdx");
|
|
|
12
12
|
const options_1 = require("./const/options");
|
|
13
13
|
class Printer {
|
|
14
14
|
static options;
|
|
15
|
-
static
|
|
15
|
+
static printDescription = common_1.printDescription;
|
|
16
|
+
static printCustomDirectives = directive_1.printCustomDirectives;
|
|
17
|
+
static printCustomTags = directive_1.printCustomTags;
|
|
18
|
+
static init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, groups, onlyDocDirectives, printTypeOptions, skipDocDirectives, metatags, } = {
|
|
16
19
|
customDirectives: undefined,
|
|
17
20
|
groups: undefined,
|
|
21
|
+
onlyDocDirectives: [],
|
|
18
22
|
printTypeOptions: options_1.PRINT_TYPE_DEFAULT_OPTIONS,
|
|
19
|
-
|
|
23
|
+
skipDocDirectives: [],
|
|
24
|
+
metatags: [],
|
|
20
25
|
}) {
|
|
21
26
|
if (typeof Printer.options !== "undefined") {
|
|
22
27
|
return;
|
|
@@ -33,13 +38,15 @@ class Printer {
|
|
|
33
38
|
relatedTypeSection: printTypeOptions?.relatedTypeSection ??
|
|
34
39
|
options_1.PRINT_TYPE_DEFAULT_OPTIONS.relatedTypeSection,
|
|
35
40
|
schema,
|
|
36
|
-
|
|
41
|
+
onlyDocDirectives: onlyDocDirectives ?? [],
|
|
42
|
+
skipDocDirectives: skipDocDirectives ?? [],
|
|
37
43
|
typeBadges: printTypeOptions?.typeBadges ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.typeBadges,
|
|
44
|
+
metatags: metatags ?? [],
|
|
38
45
|
};
|
|
39
46
|
}
|
|
40
47
|
static printHeader = (id, title, options) => {
|
|
41
48
|
const { toc, pagination } = options.header ?? options_1.DEFAULT_OPTIONS.header;
|
|
42
|
-
const
|
|
49
|
+
const paginationButtons = pagination
|
|
43
50
|
? []
|
|
44
51
|
: ["pagination_next: null", "pagination_prev: null"];
|
|
45
52
|
const header = [
|
|
@@ -47,12 +54,11 @@ class Printer {
|
|
|
47
54
|
`id: ${id}`,
|
|
48
55
|
`title: ${title}`,
|
|
49
56
|
`hide_table_of_contents: ${!toc}`,
|
|
50
|
-
...
|
|
57
|
+
...paginationButtons,
|
|
51
58
|
strings_1.FRONT_MATTER,
|
|
52
59
|
];
|
|
53
60
|
return header.join(strings_1.MARKDOWN_EOL);
|
|
54
61
|
};
|
|
55
|
-
static printDescription = common_1.printDescription;
|
|
56
62
|
static printCode = (type, options) => {
|
|
57
63
|
let code = "";
|
|
58
64
|
if (typeof options.codeSection === "undefined" ||
|
|
@@ -89,8 +95,6 @@ class Printer {
|
|
|
89
95
|
}
|
|
90
96
|
return strings_1.MARKDOWN_SOC + code.trim() + strings_1.MARKDOWN_EOC;
|
|
91
97
|
};
|
|
92
|
-
static printCustomDirectives = directive_1.printCustomDirectives;
|
|
93
|
-
static printCustomTags = directive_1.printCustomTags;
|
|
94
98
|
static printTypeMetadata = (type, options) => {
|
|
95
99
|
switch (true) {
|
|
96
100
|
case (0, graphql_1.isScalarType)(type):
|
|
@@ -119,18 +123,29 @@ class Printer {
|
|
|
119
123
|
}
|
|
120
124
|
return (0, relation_1.printRelations)(type, options);
|
|
121
125
|
};
|
|
126
|
+
static printMetaTags = (_type, { metatags }) => {
|
|
127
|
+
if (!metatags || metatags.length < 1) {
|
|
128
|
+
return "";
|
|
129
|
+
}
|
|
130
|
+
const meta = metatags.map((tag) => {
|
|
131
|
+
const props = Object.entries(tag).map(([name, value]) => {
|
|
132
|
+
return `${name}="${value}"`;
|
|
133
|
+
});
|
|
134
|
+
return `<meta ${props.join(" ")} />`;
|
|
135
|
+
});
|
|
136
|
+
return ["<head>", ...meta, "</head>"].join(strings_1.MARKDOWN_EOL);
|
|
137
|
+
};
|
|
122
138
|
static printType = (name, type, options) => {
|
|
123
139
|
const printTypeOptions = {
|
|
124
140
|
...options_1.DEFAULT_OPTIONS,
|
|
125
141
|
...Printer.options,
|
|
126
142
|
...options,
|
|
127
143
|
};
|
|
128
|
-
if (!type
|
|
129
|
-
!name ||
|
|
130
|
-
(0, graphql_1.hasDirective)(type, printTypeOptions.skipDocDirective)) {
|
|
144
|
+
if (!name || !(0, common_1.hasPrintableDirective)(type, printTypeOptions)) {
|
|
131
145
|
return undefined;
|
|
132
146
|
}
|
|
133
147
|
const header = Printer.printHeader(name, (0, graphql_1.getTypeName)(type), printTypeOptions);
|
|
148
|
+
const metatags = Printer.printMetaTags(type, printTypeOptions);
|
|
134
149
|
const description = Printer.printDescription(type, printTypeOptions);
|
|
135
150
|
const code = Printer.printCode(type, printTypeOptions);
|
|
136
151
|
const customDirectives = Printer.printCustomDirectives(type, printTypeOptions);
|
|
@@ -139,6 +154,7 @@ class Printer {
|
|
|
139
154
|
const relations = Printer.printRelations(type, printTypeOptions);
|
|
140
155
|
return [
|
|
141
156
|
header,
|
|
157
|
+
metatags,
|
|
142
158
|
mdx_1.mdx,
|
|
143
159
|
tags,
|
|
144
160
|
description,
|
package/dist/relation.js
CHANGED
|
@@ -46,19 +46,24 @@ const printRelationOf = (type, section, getRelation, options) => {
|
|
|
46
46
|
return "";
|
|
47
47
|
}
|
|
48
48
|
const content = [...data]
|
|
49
|
-
.sort((a, b) =>
|
|
49
|
+
.sort((a, b) => {
|
|
50
|
+
return a.localeCompare(b);
|
|
51
|
+
})
|
|
50
52
|
.join("<Bullet />");
|
|
51
53
|
return `${options_1.SectionLevels.LEVEL_3} ${section}${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
52
54
|
};
|
|
53
55
|
exports.printRelationOf = printRelationOf;
|
|
54
56
|
const printRelations = (type, options) => {
|
|
55
57
|
const relations = {
|
|
56
|
-
"Returned by": graphql_1.getRelationOfReturn,
|
|
57
|
-
"Member
|
|
58
|
-
|
|
58
|
+
returnedBy: { section: "Returned by", getRelation: graphql_1.getRelationOfReturn },
|
|
59
|
+
memberOf: { section: "Member Of", getRelation: graphql_1.getRelationOfField },
|
|
60
|
+
implementedBy: {
|
|
61
|
+
section: "Implemented By",
|
|
62
|
+
getRelation: graphql_1.getRelationOfImplementation,
|
|
63
|
+
},
|
|
59
64
|
};
|
|
60
65
|
let data = "";
|
|
61
|
-
for (const
|
|
66
|
+
for (const { section, getRelation } of Object.values(relations)) {
|
|
62
67
|
data += (0, exports.printRelationOf)(type, section, getRelation, options);
|
|
63
68
|
}
|
|
64
69
|
return data;
|
package/dist/section.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MDXString, PrintTypeOptions, SectionLevel } from "@graphql-markdown/types";
|
|
2
2
|
export declare const sectionLevels: SectionLevel[];
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
3
|
+
export declare const printSectionItem: <T>(type: T, options: PrintTypeOptions) => MDXString | string;
|
|
4
|
+
export declare const printSectionItems: <V>(values: V | V[], options: PrintTypeOptions) => MDXString | string;
|
|
5
|
+
export declare const printSection: <V>(values: V[] | readonly V[], section: string, options: PrintTypeOptions) => MDXString | string;
|
|
6
|
+
export declare const printMetadataSection: <T, V>(type: T, values: V | V[] | readonly V[], section: string, options: PrintTypeOptions) => MDXString | string;
|
package/dist/section.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printMetadataSection = exports.printSection = exports.printSectionItems = exports.printSectionItem = exports.sectionLevels = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const common_1 = require("./common");
|
|
6
6
|
const badge_1 = require("./badge");
|
|
@@ -13,44 +13,53 @@ exports.sectionLevels = [
|
|
|
13
13
|
options_1.SectionLevels.LEVEL_4,
|
|
14
14
|
options_1.SectionLevels.LEVEL_5,
|
|
15
15
|
];
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
values.length === 0) {
|
|
16
|
+
const printSectionItem = (type, options) => {
|
|
17
|
+
const level = "level" in options && typeof options.level === "string"
|
|
18
|
+
? options.level
|
|
19
|
+
: options_1.SectionLevels.LEVEL_4;
|
|
20
|
+
if (!(0, common_1.hasPrintableDirective)(type, options)) {
|
|
22
21
|
return "";
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
return `${meta}${deprecatedMeta}`;
|
|
44
|
-
}
|
|
45
|
-
case "default":
|
|
46
|
-
default:
|
|
47
|
-
return (0, exports.printSection)(values, section, {
|
|
48
|
-
...options,
|
|
49
|
-
parentType: type.name,
|
|
50
|
-
});
|
|
23
|
+
const typeNameLink = (0, link_1.printLink)(type, {
|
|
24
|
+
...options,
|
|
25
|
+
withAttributes: false,
|
|
26
|
+
});
|
|
27
|
+
const description = (0, common_1.printDescription)(type, options, "").replaceAll("\n", `${strings_1.MARKDOWN_EOL}> `);
|
|
28
|
+
const badges = (0, badge_1.printBadges)(type, options);
|
|
29
|
+
const tags = (0, directive_1.printCustomTags)(type, options);
|
|
30
|
+
const parentTypeLink = (0, link_1.printParentLink)(type, options);
|
|
31
|
+
let section = `${level} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${strings_1.MARKDOWN_EOL}> ${description}${strings_1.MARKDOWN_EOL}> `;
|
|
32
|
+
if ((0, graphql_1.isGraphQLFieldType)(type)) {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
34
|
+
section += (0, exports.printSectionItems)(type.args, {
|
|
35
|
+
...options,
|
|
36
|
+
level: options_1.SectionLevels.LEVEL_5,
|
|
37
|
+
parentType: typeof options.parentType === "undefined"
|
|
38
|
+
? type.name
|
|
39
|
+
: `${options.parentType}.${type.name}`,
|
|
40
|
+
});
|
|
51
41
|
}
|
|
42
|
+
return section;
|
|
52
43
|
};
|
|
53
|
-
exports.
|
|
44
|
+
exports.printSectionItem = printSectionItem;
|
|
45
|
+
const printSectionItems = (values, options) => {
|
|
46
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
const level = ("level" in options && typeof options.level === "string"
|
|
50
|
+
? options.level
|
|
51
|
+
: options_1.SectionLevels.LEVEL_4);
|
|
52
|
+
return values
|
|
53
|
+
.map((v) => {
|
|
54
|
+
return (v &&
|
|
55
|
+
(0, exports.printSectionItem)(v, {
|
|
56
|
+
...options,
|
|
57
|
+
level,
|
|
58
|
+
}));
|
|
59
|
+
})
|
|
60
|
+
.join(strings_1.MARKDOWN_EOP);
|
|
61
|
+
};
|
|
62
|
+
exports.printSectionItems = printSectionItems;
|
|
54
63
|
const printSection = (values, section, options) => {
|
|
55
64
|
if (!Array.isArray(values) || values.length === 0) {
|
|
56
65
|
return "";
|
|
@@ -82,49 +91,46 @@ const printSection = (values, section, options) => {
|
|
|
82
91
|
return `${level} ${section}${openSection}${items}${closeSection}`;
|
|
83
92
|
};
|
|
84
93
|
exports.printSection = printSection;
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
: options_1.SectionLevels.LEVEL_4);
|
|
92
|
-
return values
|
|
93
|
-
.map((v) => v &&
|
|
94
|
-
(0, exports.printSectionItem)(v, {
|
|
95
|
-
...options,
|
|
96
|
-
level,
|
|
97
|
-
}))
|
|
98
|
-
.join(strings_1.MARKDOWN_EOP);
|
|
99
|
-
};
|
|
100
|
-
exports.printSectionItems = printSectionItems;
|
|
101
|
-
const printSectionItem = (type, options) => {
|
|
102
|
-
const level = "level" in options && typeof options.level === "string"
|
|
103
|
-
? options.level
|
|
104
|
-
: options_1.SectionLevels.LEVEL_4;
|
|
105
|
-
const skipDirective = (0, graphql_1.hasDirective)(type, options.skipDocDirective);
|
|
106
|
-
const skipDeprecated = options.deprecated === "skip" && (0, graphql_1.isDeprecated)(type);
|
|
107
|
-
if (!type || skipDirective || skipDeprecated) {
|
|
94
|
+
const printMetadataSection = (type, values, section, options) => {
|
|
95
|
+
if (typeof type !== "object" ||
|
|
96
|
+
type === null ||
|
|
97
|
+
!("name" in type) ||
|
|
98
|
+
!Array.isArray(values) ||
|
|
99
|
+
values.length === 0) {
|
|
108
100
|
return "";
|
|
109
101
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
102
|
+
switch (options.deprecated) {
|
|
103
|
+
case "group": {
|
|
104
|
+
const { fields, deprecated } = values.reduce((res, arg) => {
|
|
105
|
+
if ((0, graphql_1.isDeprecated)(arg)) {
|
|
106
|
+
res.deprecated.push(arg);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
res.fields.push(arg);
|
|
110
|
+
}
|
|
111
|
+
return res;
|
|
112
|
+
}, { fields: [], deprecated: [] });
|
|
113
|
+
const meta = (0, exports.printSection)(fields, section, {
|
|
114
|
+
...options,
|
|
115
|
+
parentType: type.name,
|
|
116
|
+
});
|
|
117
|
+
const deprecatedMeta = (0, exports.printSection)(deprecated, "", {
|
|
118
|
+
...options,
|
|
119
|
+
parentType: type.name,
|
|
120
|
+
level: options_1.SectionLevels.NONE,
|
|
121
|
+
collapsible: {
|
|
122
|
+
dataOpen: strings_1.HIDE_DEPRECATED,
|
|
123
|
+
dataClose: strings_1.SHOW_DEPRECATED,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
return `${meta}${deprecatedMeta}`;
|
|
127
|
+
}
|
|
128
|
+
case "default":
|
|
129
|
+
default:
|
|
130
|
+
return (0, exports.printSection)(values, section, {
|
|
131
|
+
...options,
|
|
132
|
+
parentType: type.name,
|
|
133
|
+
});
|
|
127
134
|
}
|
|
128
|
-
return section;
|
|
129
135
|
};
|
|
130
|
-
exports.
|
|
136
|
+
exports.printMetadataSection = printMetadataSection;
|
package/package.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.5.
|
|
8
|
+
"version": "1.5.1",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "graphql-markdown/graphql-markdown",
|
|
12
|
+
"url": "git+https://github.com/graphql-markdown/graphql-markdown.git",
|
|
13
13
|
"directory": "packages/utils"
|
|
14
14
|
},
|
|
15
15
|
"author": {
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"clean": "rm -rf ./dist"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@graphql-markdown/graphql": "^1.0.
|
|
59
|
-
"@graphql-markdown/utils": "^1.6.
|
|
58
|
+
"@graphql-markdown/graphql": "^1.0.1",
|
|
59
|
+
"@graphql-markdown/utils": "^1.6.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@graphql-markdown/types": "^1.0.0
|
|
62
|
+
"@graphql-markdown/types": "^1.0.0"
|
|
63
63
|
},
|
|
64
64
|
"directories": {
|
|
65
65
|
"test": "tests"
|