@graphql-markdown/printer-legacy 1.4.3 → 1.5.0-next.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/badge.d.ts +5 -0
- package/dist/badge.js +64 -0
- package/dist/code.d.ts +3 -0
- package/dist/code.js +52 -0
- package/dist/common.d.ts +5 -0
- package/dist/common.js +46 -0
- package/dist/const/mdx.d.ts +2 -0
- package/{src → dist}/const/mdx.js +4 -1
- package/dist/const/options.d.ts +16 -0
- package/dist/const/options.js +30 -0
- package/dist/const/strings.d.ts +12 -0
- package/dist/const/strings.js +26 -0
- package/dist/directive.d.ts +6 -0
- package/dist/directive.js +66 -0
- package/dist/graphql/directive.d.ts +3 -0
- package/dist/graphql/directive.js +34 -0
- package/dist/graphql/enum.d.ts +3 -0
- package/dist/graphql/enum.js +39 -0
- package/dist/graphql/index.d.ts +8 -0
- package/dist/graphql/index.js +24 -0
- package/dist/graphql/input.d.ts +3 -0
- package/dist/graphql/input.js +7 -0
- package/dist/graphql/interface.d.ts +3 -0
- package/dist/graphql/interface.js +7 -0
- package/dist/graphql/object.d.ts +4 -0
- package/dist/graphql/object.js +47 -0
- package/dist/graphql/operation.d.ts +4 -0
- package/dist/graphql/operation.js +27 -0
- package/dist/graphql/scalar.d.ts +4 -0
- package/dist/graphql/scalar.js +26 -0
- package/dist/graphql/union.d.ts +3 -0
- package/dist/graphql/union.js +27 -0
- package/dist/group.d.ts +2 -0
- package/dist/group.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/link.d.ts +9 -0
- package/dist/link.js +134 -0
- package/dist/printer.d.ts +19 -0
- package/dist/printer.js +152 -0
- package/dist/relation.d.ts +4 -0
- package/dist/relation.js +66 -0
- package/dist/section.d.ts +6 -0
- package/dist/section.js +130 -0
- package/package.json +51 -7
- package/src/badge.js +0 -70
- package/src/code.js +0 -60
- package/src/common.js +0 -66
- package/src/const/options.js +0 -28
- package/src/const/strings.js +0 -48
- package/src/directive.js +0 -105
- package/src/graphql/directive.js +0 -47
- package/src/graphql/enum.js +0 -47
- package/src/graphql/index.js +0 -10
- package/src/graphql/input.js +0 -10
- package/src/graphql/interface.js +0 -10
- package/src/graphql/object.js +0 -56
- package/src/graphql/operation.js +0 -28
- package/src/graphql/scalar.js +0 -30
- package/src/graphql/union.js +0 -31
- package/src/group.js +0 -21
- package/src/index.js +0 -3
- package/src/link.js +0 -182
- package/src/printer.js +0 -242
- package/src/relation.js +0 -92
- package/src/section.js +0 -185
package/dist/badge.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntitiesGroupMap } from "@graphql-markdown/types";
|
|
2
|
+
export declare const DEFAULT_CSS_CLASSNAME: "badge--secondary";
|
|
3
|
+
export declare const getTypeBadges: (type: unknown, groups?: Maybe<SchemaEntitiesGroupMap>) => Badge[];
|
|
4
|
+
export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
5
|
+
export declare const printBadge: ({ text, classname }: Badge) => MDXString;
|
package/dist/badge.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printBadge = exports.printBadges = exports.getTypeBadges = exports.DEFAULT_CSS_CLASSNAME = void 0;
|
|
4
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
5
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
6
|
+
const link_1 = require("./link");
|
|
7
|
+
const group_1 = require("./group");
|
|
8
|
+
exports.DEFAULT_CSS_CLASSNAME = "badge--secondary";
|
|
9
|
+
const getTypeBadges = (type, groups) => {
|
|
10
|
+
const badges = [];
|
|
11
|
+
if (typeof type !== "object" || type === null) {
|
|
12
|
+
return badges;
|
|
13
|
+
}
|
|
14
|
+
const rootType = ("type" in type ? type.type : type);
|
|
15
|
+
if ((0, graphql_1.isDeprecated)(type)) {
|
|
16
|
+
badges.push({
|
|
17
|
+
text: "deprecated",
|
|
18
|
+
classname: "badge--deprecated badge--secondary",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if ((0, graphql_1.isNonNullType)(rootType)) {
|
|
22
|
+
badges.push({
|
|
23
|
+
text: "non-null",
|
|
24
|
+
classname: exports.DEFAULT_CSS_CLASSNAME,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if ((0, graphql_1.isListType)(rootType)) {
|
|
28
|
+
badges.push({ text: "list", classname: exports.DEFAULT_CSS_CLASSNAME });
|
|
29
|
+
}
|
|
30
|
+
const category = (0, link_1.getLinkCategory)((0, graphql_1.getNamedType)(rootType));
|
|
31
|
+
if (category) {
|
|
32
|
+
badges.push({ text: category, classname: exports.DEFAULT_CSS_CLASSNAME });
|
|
33
|
+
}
|
|
34
|
+
if (groups) {
|
|
35
|
+
const typeCategory = (typeof category === "string" ? category : category?.plural);
|
|
36
|
+
const group = (0, group_1.getGroup)(rootType, groups, typeCategory);
|
|
37
|
+
if (group && group !== "") {
|
|
38
|
+
badges.push({ text: group, classname: exports.DEFAULT_CSS_CLASSNAME });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return badges;
|
|
42
|
+
};
|
|
43
|
+
exports.getTypeBadges = getTypeBadges;
|
|
44
|
+
const printBadges = (type, options) => {
|
|
45
|
+
if (!("typeBadges" in options) ||
|
|
46
|
+
typeof options.typeBadges !== "boolean" ||
|
|
47
|
+
!options.typeBadges) {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
const badges = (0, exports.getTypeBadges)(type, options.groups);
|
|
51
|
+
if (badges.length === 0) {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
return badges
|
|
55
|
+
.map((badge) => (0, exports.printBadge)(badge))
|
|
56
|
+
.join(" ");
|
|
57
|
+
};
|
|
58
|
+
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
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printCodeField: (type: unknown, options?: PrintTypeOptions, indentationLevel?: number) => MDXString | string;
|
|
3
|
+
export declare const printCodeArguments: (type: unknown, indentationLevel?: number) => string;
|
package/dist/code.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeArguments = exports.printCodeField = void 0;
|
|
4
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const strings_1 = require("./const/strings");
|
|
6
|
+
const printCodeField = (type, options, indentationLevel = 0) => {
|
|
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;
|
|
28
|
+
const printCodeArguments = (type, indentationLevel = 1) => {
|
|
29
|
+
if (typeof type !== "object" ||
|
|
30
|
+
type === null ||
|
|
31
|
+
!("args" in type) ||
|
|
32
|
+
!Array.isArray(type.args) ||
|
|
33
|
+
type.args.length === 0) {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
const argIndentation = strings_1.MARKDOWN_CODE_INDENTATION.repeat(indentationLevel);
|
|
37
|
+
const parentIndentation = indentationLevel === 1 ? "" : strings_1.MARKDOWN_CODE_INDENTATION;
|
|
38
|
+
let code = `(${strings_1.MARKDOWN_EOL}`;
|
|
39
|
+
code += type.args.reduce((r, v) => {
|
|
40
|
+
const defaultValue = (0, graphql_1.getFormattedDefaultValue)(v);
|
|
41
|
+
const hasDefaultValue = typeof defaultValue !== "undefined" && defaultValue !== null;
|
|
42
|
+
const printedDefault = hasDefaultValue
|
|
43
|
+
? ` = ${(0, graphql_1.getFormattedDefaultValue)(v)}`
|
|
44
|
+
: "";
|
|
45
|
+
const propType = String(v.type);
|
|
46
|
+
const propName = String(v.name);
|
|
47
|
+
return `${r}${argIndentation}${propName}: ${propType}${printedDefault}${strings_1.MARKDOWN_EOL}`;
|
|
48
|
+
}, "");
|
|
49
|
+
code += `${parentIndentation})`;
|
|
50
|
+
return code;
|
|
51
|
+
};
|
|
52
|
+
exports.printCodeArguments = printCodeArguments;
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PrintTypeOptions, MDXString, Maybe } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printCustomDirectives: (type: unknown, options?: PrintTypeOptions) => string;
|
|
3
|
+
export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => MDXString | string;
|
|
4
|
+
export declare const printDeprecation: (type: unknown) => string;
|
|
5
|
+
export declare const printDescription: (type: unknown, options?: PrintTypeOptions, noText?: string) => MDXString | string;
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printDescription = exports.printDeprecation = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
4
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
5
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
6
|
+
const directive_1 = require("./directive");
|
|
7
|
+
const strings_1 = require("./const/strings");
|
|
8
|
+
const printCustomDirectives = (type, options) => {
|
|
9
|
+
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
|
|
10
|
+
if (!constDirectiveMap || (0, utils_1.isEmpty)(constDirectiveMap)) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
const content = Object.values(constDirectiveMap)
|
|
14
|
+
.map((constDirectiveOption) => (0, directive_1.getCustomDirectiveResolver)("descriptor", type, constDirectiveOption, ""))
|
|
15
|
+
.filter((text) => typeof text === "string" && text.length > 0)
|
|
16
|
+
.join(strings_1.MARKDOWN_EOP);
|
|
17
|
+
return `${strings_1.MARKDOWN_EOP}${content}`;
|
|
18
|
+
};
|
|
19
|
+
exports.printCustomDirectives = printCustomDirectives;
|
|
20
|
+
const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) => {
|
|
21
|
+
if (typeof type !== "object" || type === null) {
|
|
22
|
+
return `${strings_1.MARKDOWN_EOP}${replacement}`;
|
|
23
|
+
}
|
|
24
|
+
const description = "description" in type && typeof type.description === "string"
|
|
25
|
+
? (0, utils_1.escapeMDX)(type.description)
|
|
26
|
+
: replacement;
|
|
27
|
+
return `${strings_1.MARKDOWN_EOP}${description}`;
|
|
28
|
+
};
|
|
29
|
+
exports.formatDescription = formatDescription;
|
|
30
|
+
const printDeprecation = (type) => {
|
|
31
|
+
if (typeof type !== "object" || type === null || !(0, graphql_1.isDeprecated)(type)) {
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
const reason = "deprecationReason" in type && typeof type.deprecationReason === "string"
|
|
35
|
+
? type.deprecationReason + strings_1.MARKDOWN_EOL
|
|
36
|
+
: "";
|
|
37
|
+
return `${strings_1.MARKDOWN_EOP}:::caution ${strings_1.DEPRECATED.toUpperCase()}${strings_1.MARKDOWN_EOL}${reason}:::`;
|
|
38
|
+
};
|
|
39
|
+
exports.printDeprecation = printDeprecation;
|
|
40
|
+
const printDescription = (type, options, noText) => {
|
|
41
|
+
const description = (0, exports.formatDescription)(type, noText);
|
|
42
|
+
const customDirectives = (0, exports.printCustomDirectives)(type, options);
|
|
43
|
+
const deprecation = (0, exports.printDeprecation)(type);
|
|
44
|
+
return `${deprecation}${description}${customDirectives}`;
|
|
45
|
+
};
|
|
46
|
+
exports.printDescription = printDescription;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mdx = void 0;
|
|
4
|
+
exports.mdx = `
|
|
2
5
|
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}> ● </span></>
|
|
3
6
|
|
|
4
7
|
export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CollapsibleOption, DirectiveName, GraphQLSchema, Maybe, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, SectionLevelValue } from "@graphql-markdown/types";
|
|
2
|
+
export declare enum SectionLevels {
|
|
3
|
+
NONE = "",
|
|
4
|
+
LEVEL_3 = "###",
|
|
5
|
+
LEVEL_4 = "####",
|
|
6
|
+
LEVEL_5 = "#####"
|
|
7
|
+
}
|
|
8
|
+
export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<PrinterConfigPrintTypeOptions>;
|
|
9
|
+
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "parentType" | "schema" | "skipDocDirective">> & {
|
|
10
|
+
schema: Maybe<GraphQLSchema>;
|
|
11
|
+
skipDocDirective: Maybe<DirectiveName[]>;
|
|
12
|
+
collapsible: Maybe<CollapsibleOption>;
|
|
13
|
+
parentType: Maybe<string>;
|
|
14
|
+
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
15
|
+
level: Maybe<SectionLevelValue>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_OPTIONS = exports.PRINT_TYPE_DEFAULT_OPTIONS = exports.SectionLevels = void 0;
|
|
4
|
+
var SectionLevels;
|
|
5
|
+
(function (SectionLevels) {
|
|
6
|
+
SectionLevels["NONE"] = "";
|
|
7
|
+
SectionLevels["LEVEL_3"] = "###";
|
|
8
|
+
SectionLevels["LEVEL_4"] = "####";
|
|
9
|
+
SectionLevels["LEVEL_5"] = "#####";
|
|
10
|
+
})(SectionLevels || (exports.SectionLevels = SectionLevels = {}));
|
|
11
|
+
exports.PRINT_TYPE_DEFAULT_OPTIONS = {
|
|
12
|
+
codeSection: true,
|
|
13
|
+
deprecated: "default",
|
|
14
|
+
parentTypePrefix: true,
|
|
15
|
+
relatedTypeSection: true,
|
|
16
|
+
typeBadges: true,
|
|
17
|
+
};
|
|
18
|
+
exports.DEFAULT_OPTIONS = {
|
|
19
|
+
...exports.PRINT_TYPE_DEFAULT_OPTIONS,
|
|
20
|
+
basePath: "/",
|
|
21
|
+
collapsible: undefined,
|
|
22
|
+
customDirectives: {},
|
|
23
|
+
groups: undefined,
|
|
24
|
+
header: { toc: true, pagination: true },
|
|
25
|
+
level: undefined,
|
|
26
|
+
parentType: undefined,
|
|
27
|
+
schema: undefined,
|
|
28
|
+
skipDocDirective: undefined,
|
|
29
|
+
withAttributes: false,
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RootTypeLocale } from "@graphql-markdown/types";
|
|
2
|
+
export declare const ROOT_TYPE_LOCALE: RootTypeLocale;
|
|
3
|
+
export declare const NO_DESCRIPTION_TEXT: "No description";
|
|
4
|
+
export declare const FRONT_MATTER: "---";
|
|
5
|
+
export declare const MARKDOWN_CODE_INDENTATION: " ";
|
|
6
|
+
export declare const MARKDOWN_EOL: "\n";
|
|
7
|
+
export declare const MARKDOWN_EOP: "\n\n";
|
|
8
|
+
export declare const MARKDOWN_EOC: "\n```\n";
|
|
9
|
+
export declare const MARKDOWN_SOC: "\n```graphql\n";
|
|
10
|
+
export declare const DEPRECATED: "deprecated";
|
|
11
|
+
export declare const HIDE_DEPRECATED: "<><span className=\"deprecated\">Hide deprecated</span></>";
|
|
12
|
+
export declare const SHOW_DEPRECATED: "<><span className=\"deprecated\">Show deprecated</span></>";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SHOW_DEPRECATED = exports.HIDE_DEPRECATED = exports.DEPRECATED = exports.MARKDOWN_SOC = exports.MARKDOWN_EOC = exports.MARKDOWN_EOP = exports.MARKDOWN_EOL = exports.MARKDOWN_CODE_INDENTATION = exports.FRONT_MATTER = exports.NO_DESCRIPTION_TEXT = exports.ROOT_TYPE_LOCALE = void 0;
|
|
4
|
+
exports.ROOT_TYPE_LOCALE = {
|
|
5
|
+
DIRECTIVE: { singular: "directive", plural: "directives" },
|
|
6
|
+
ENUM: { singular: "enum", plural: "enums" },
|
|
7
|
+
INPUT: { singular: "input", plural: "inputs" },
|
|
8
|
+
INTERFACE: { singular: "interface", plural: "interfaces" },
|
|
9
|
+
MUTATION: { singular: "mutation", plural: "mutations" },
|
|
10
|
+
OPERATION: { singular: "operation", plural: "operations" },
|
|
11
|
+
QUERY: { singular: "query", plural: "queries" },
|
|
12
|
+
SCALAR: { singular: "scalar", plural: "scalars" },
|
|
13
|
+
SUBSCRIPTION: { singular: "subscription", plural: "subscriptions" },
|
|
14
|
+
TYPE: { singular: "object", plural: "objects" },
|
|
15
|
+
UNION: { singular: "union", plural: "unions" },
|
|
16
|
+
};
|
|
17
|
+
exports.NO_DESCRIPTION_TEXT = "No description";
|
|
18
|
+
exports.FRONT_MATTER = "---";
|
|
19
|
+
exports.MARKDOWN_CODE_INDENTATION = " ";
|
|
20
|
+
exports.MARKDOWN_EOL = "\n";
|
|
21
|
+
exports.MARKDOWN_EOP = "\n\n";
|
|
22
|
+
exports.MARKDOWN_EOC = `${exports.MARKDOWN_EOL}\`\`\`${exports.MARKDOWN_EOL}`;
|
|
23
|
+
exports.MARKDOWN_SOC = `${exports.MARKDOWN_EOL}\`\`\`graphql${exports.MARKDOWN_EOL}`;
|
|
24
|
+
exports.DEPRECATED = "deprecated";
|
|
25
|
+
exports.HIDE_DEPRECATED = `<><span className="deprecated">Hide deprecated</span></>`;
|
|
26
|
+
exports.SHOW_DEPRECATED = `<><span className="deprecated">Show deprecated</span></>`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Badge, PrintTypeOptions, MDXString, CustomDirectiveMapItem, CustomDirectiveResolver, Maybe } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
3
|
+
export declare const printCustomDirective: (type: unknown, constDirectiveOption: CustomDirectiveMapItem, options: PrintTypeOptions) => Maybe<string>;
|
|
4
|
+
export declare const getCustomTags: (type: unknown, options: PrintTypeOptions) => Badge[];
|
|
5
|
+
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>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomDirectiveResolver = exports.printCustomTags = exports.getCustomTags = exports.printCustomDirective = exports.printCustomDirectives = void 0;
|
|
4
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const strings_1 = require("./const/strings");
|
|
6
|
+
const options_1 = require("./const/options");
|
|
7
|
+
const link_1 = require("./link");
|
|
8
|
+
const badge_1 = require("./badge");
|
|
9
|
+
const printCustomDirectives = (type, options) => {
|
|
10
|
+
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
|
|
11
|
+
if (!constDirectiveMap || Object.keys(constDirectiveMap).length < 1) {
|
|
12
|
+
return "";
|
|
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 "";
|
|
19
|
+
}
|
|
20
|
+
const content = directives.join(strings_1.MARKDOWN_EOP);
|
|
21
|
+
return `${options_1.SectionLevels.LEVEL_3} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
22
|
+
};
|
|
23
|
+
exports.printCustomDirectives = printCustomDirectives;
|
|
24
|
+
const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
25
|
+
const typeNameLink = (0, link_1.printLink)(constDirectiveOption.type, {
|
|
26
|
+
...options,
|
|
27
|
+
withAttributes: false,
|
|
28
|
+
});
|
|
29
|
+
const description = (0, exports.getCustomDirectiveResolver)("descriptor", type, constDirectiveOption);
|
|
30
|
+
if (typeof description !== "string") {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return `${options_1.SectionLevels.LEVEL_4} ${typeNameLink}${strings_1.MARKDOWN_EOL}> ${description}${strings_1.MARKDOWN_EOL}> `;
|
|
34
|
+
};
|
|
35
|
+
exports.printCustomDirective = printCustomDirective;
|
|
36
|
+
const getCustomTags = (type, options) => {
|
|
37
|
+
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
|
|
38
|
+
if (typeof constDirectiveMap !== "object" ||
|
|
39
|
+
constDirectiveMap === null ||
|
|
40
|
+
!Object.keys(constDirectiveMap).length) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
return Object.values(constDirectiveMap)
|
|
44
|
+
.map((constDirectiveOption) => (0, exports.getCustomDirectiveResolver)("tag", type, constDirectiveOption))
|
|
45
|
+
.filter((value) => typeof value !== "undefined");
|
|
46
|
+
};
|
|
47
|
+
exports.getCustomTags = getCustomTags;
|
|
48
|
+
const printCustomTags = (type, options) => {
|
|
49
|
+
const badges = (0, exports.getCustomTags)(type, options);
|
|
50
|
+
if (badges.length === 0) {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
return badges
|
|
54
|
+
.map((badge) => (0, badge_1.printBadge)(badge))
|
|
55
|
+
.join(" ");
|
|
56
|
+
};
|
|
57
|
+
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;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PrintDirectiveOptions, GraphQLDirective, MDXString } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printDirectiveMetadata: (type: GraphQLDirective, options: PrintDirectiveOptions) => MDXString | string;
|
|
3
|
+
export declare const printCodeDirective: (type: GraphQLDirective, options?: PrintDirectiveOptions) => string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeDirective = exports.printDirectiveMetadata = void 0;
|
|
4
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const section_1 = require("../section");
|
|
6
|
+
const code_1 = require("../code");
|
|
7
|
+
const printCodeDirectiveLocation = (type) => {
|
|
8
|
+
if (typeof type.locations === "undefined" || type.locations.length === 0) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
let code = ` on `;
|
|
12
|
+
const separator = `\r\n | `;
|
|
13
|
+
if (type.locations.length > 1) {
|
|
14
|
+
code += separator;
|
|
15
|
+
}
|
|
16
|
+
code += type.locations.join(separator).trim();
|
|
17
|
+
return code;
|
|
18
|
+
};
|
|
19
|
+
const printDirectiveMetadata = (type, options) => {
|
|
20
|
+
if (!("args" in type)) {
|
|
21
|
+
return "";
|
|
22
|
+
}
|
|
23
|
+
return (0, section_1.printMetadataSection)(type, type.args, "Arguments", options);
|
|
24
|
+
};
|
|
25
|
+
exports.printDirectiveMetadata = printDirectiveMetadata;
|
|
26
|
+
const printCodeDirective = (type,
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
options) => {
|
|
29
|
+
let code = `directive @${(0, graphql_1.getTypeName)(type)}`;
|
|
30
|
+
code += (0, code_1.printCodeArguments)(type);
|
|
31
|
+
code += printCodeDirectiveLocation(type);
|
|
32
|
+
return code;
|
|
33
|
+
};
|
|
34
|
+
exports.printCodeDirective = printCodeDirective;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeEnum = exports.printEnumMetadata = void 0;
|
|
4
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const strings_1 = require("../const/strings");
|
|
6
|
+
const section_1 = require("../section");
|
|
7
|
+
const printEnumMetadata = (type, options) => {
|
|
8
|
+
if (!(0, graphql_1.isEnumType)(type)) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
return (0, section_1.printMetadataSection)(type, type.getValues(), "Values", options);
|
|
12
|
+
};
|
|
13
|
+
exports.printEnumMetadata = printEnumMetadata;
|
|
14
|
+
const printCodeEnum = (type, options) => {
|
|
15
|
+
if (!(0, graphql_1.isEnumType)(type)) {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
let code = `enum ${(0, graphql_1.getTypeName)(type)} {${strings_1.MARKDOWN_EOL}`;
|
|
19
|
+
code += type
|
|
20
|
+
.getValues()
|
|
21
|
+
.map((value) => {
|
|
22
|
+
const skipDirective = "skipDocDirective" in options &&
|
|
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) {
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
const v = (0, graphql_1.getTypeName)(value);
|
|
31
|
+
const d = (0, graphql_1.isDeprecated)(value) ? ` @${strings_1.DEPRECATED}` : "";
|
|
32
|
+
return ` ${v}${d}`;
|
|
33
|
+
})
|
|
34
|
+
.filter((value) => value.length > 0)
|
|
35
|
+
.join(strings_1.MARKDOWN_EOL);
|
|
36
|
+
code += `${strings_1.MARKDOWN_EOL}}`;
|
|
37
|
+
return code;
|
|
38
|
+
};
|
|
39
|
+
exports.printCodeEnum = printCodeEnum;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./directive"), exports);
|
|
18
|
+
__exportStar(require("./enum"), exports);
|
|
19
|
+
__exportStar(require("./input"), exports);
|
|
20
|
+
__exportStar(require("./interface"), exports);
|
|
21
|
+
__exportStar(require("./object"), exports);
|
|
22
|
+
__exportStar(require("./operation"), exports);
|
|
23
|
+
__exportStar(require("./scalar"), exports);
|
|
24
|
+
__exportStar(require("./union"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeInput = exports.printInputMetadata = void 0;
|
|
4
|
+
const object_1 = require("./object");
|
|
5
|
+
exports.printInputMetadata = object_1.printObjectMetadata;
|
|
6
|
+
const printCodeInput = (type, options) => (0, object_1.printCodeType)(type, "input", options);
|
|
7
|
+
exports.printCodeInput = printCodeInput;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeInterface = exports.printInterfaceMetadata = void 0;
|
|
4
|
+
const object_1 = require("./object");
|
|
5
|
+
exports.printInterfaceMetadata = object_1.printObjectMetadata;
|
|
6
|
+
const printCodeInterface = (type, options) => (0, object_1.printCodeType)(type, "interface", options);
|
|
7
|
+
exports.printCodeInterface = printCodeInterface;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printObjectMetadata: (type: unknown, options: PrintTypeOptions) => string;
|
|
3
|
+
export declare const printCodeType: (type: unknown, entity: string, options: PrintTypeOptions) => string;
|
|
4
|
+
export declare const printCodeObject: (type: unknown, options: PrintTypeOptions) => string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeObject = exports.printCodeType = exports.printObjectMetadata = void 0;
|
|
4
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const section_1 = require("../section");
|
|
6
|
+
const code_1 = require("../code");
|
|
7
|
+
const strings_1 = require("../const/strings");
|
|
8
|
+
const printImplementedInterfaceMetadata = (type, options) => {
|
|
9
|
+
if (typeof type !== "object" ||
|
|
10
|
+
type === null ||
|
|
11
|
+
!("getInterfaces" in type) ||
|
|
12
|
+
typeof type.getInterfaces !== "function") {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
return (0, section_1.printSection)(type.getInterfaces(), "Interfaces", options);
|
|
16
|
+
};
|
|
17
|
+
const printObjectMetadata = (type, options) => {
|
|
18
|
+
const interfaceMeta = printImplementedInterfaceMetadata(type, options);
|
|
19
|
+
const metadata = (0, section_1.printMetadataSection)(type, (0, graphql_1.getFields)(type), "Fields", options);
|
|
20
|
+
return `${metadata}${interfaceMeta}`;
|
|
21
|
+
};
|
|
22
|
+
exports.printObjectMetadata = printObjectMetadata;
|
|
23
|
+
const printCodeType = (type, entity, options) => {
|
|
24
|
+
if (typeof type !== "object" || type === null) {
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
const name = (0, graphql_1.getTypeName)(type);
|
|
28
|
+
const extendsInterface = "getInterfaces" in type &&
|
|
29
|
+
typeof type.getInterfaces === "function" &&
|
|
30
|
+
type.getInterfaces().length > 0
|
|
31
|
+
? ` implements ${type
|
|
32
|
+
.getInterfaces()
|
|
33
|
+
.map((field) => (0, graphql_1.getTypeName)(field))
|
|
34
|
+
.join(", ")}`
|
|
35
|
+
: "";
|
|
36
|
+
const typeFields = (0, graphql_1.getFields)(type)
|
|
37
|
+
.map((field) => {
|
|
38
|
+
const f = (0, code_1.printCodeField)(field, options, 1);
|
|
39
|
+
return f.length > 0 ? `${strings_1.MARKDOWN_CODE_INDENTATION}${f}` : "";
|
|
40
|
+
})
|
|
41
|
+
.filter((field) => field.length > 0)
|
|
42
|
+
.join("");
|
|
43
|
+
return `${entity} ${name}${extendsInterface} {${strings_1.MARKDOWN_EOL}${typeFields}}`;
|
|
44
|
+
};
|
|
45
|
+
exports.printCodeType = printCodeType;
|
|
46
|
+
const printCodeObject = (type, options) => (0, exports.printCodeType)(type, "type", options);
|
|
47
|
+
exports.printCodeObject = printCodeObject;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PrintTypeOptions, MDXString } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printOperationType: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
3
|
+
export declare const printOperationMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
4
|
+
export declare const printCodeOperation: (type: unknown, options?: PrintTypeOptions | undefined, indentationLevel?: number) => string | MDXString;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeOperation = exports.printOperationMetadata = exports.printOperationType = void 0;
|
|
4
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const section_1 = require("../section");
|
|
6
|
+
const code_1 = require("../code");
|
|
7
|
+
const printOperationType = (type, options) => {
|
|
8
|
+
if (!(0, graphql_1.isOperation)(type)) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
const queryType = (0, graphql_1.getTypeName)(type.type).replace(/[![\]]*/g, "");
|
|
12
|
+
return (0, section_1.printSection)([options.schema.getType(queryType)], "Type", {
|
|
13
|
+
...options,
|
|
14
|
+
parentTypePrefix: false,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
exports.printOperationType = printOperationType;
|
|
18
|
+
const printOperationMetadata = (type, options) => {
|
|
19
|
+
if (!(0, graphql_1.isOperation)(type)) {
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
const response = (0, exports.printOperationType)(type, options);
|
|
23
|
+
const metadata = (0, section_1.printMetadataSection)(type, type.args, "Arguments", options);
|
|
24
|
+
return `${metadata}${response}`;
|
|
25
|
+
};
|
|
26
|
+
exports.printOperationMetadata = printOperationMetadata;
|
|
27
|
+
exports.printCodeOperation = code_1.printCodeField;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PrintTypeOptions, MDXString } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printSpecification: (type: unknown) => MDXString | string;
|
|
3
|
+
export declare const printScalarMetadata: (type: unknown, options?: PrintTypeOptions) => MDXString | string;
|
|
4
|
+
export declare const printCodeScalar: (type: unknown, options?: PrintTypeOptions) => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeScalar = exports.printScalarMetadata = exports.printSpecification = void 0;
|
|
4
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const strings_1 = require("../const/strings");
|
|
6
|
+
const options_1 = require("../const/options");
|
|
7
|
+
const printSpecification = (type) => {
|
|
8
|
+
if (typeof type !== "object" ||
|
|
9
|
+
type === null ||
|
|
10
|
+
!("specifiedByURL" in type) ||
|
|
11
|
+
!type.specifiedByURL) {
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
14
|
+
const url = type.specifiedByURL;
|
|
15
|
+
// Needs newline between "export const specifiedByLinkCss" and markdown header to prevent compilation error in docusaurus
|
|
16
|
+
return `${options_1.SectionLevels.LEVEL_3} <SpecifiedBy url="${url}"/>${strings_1.MARKDOWN_EOP}`;
|
|
17
|
+
};
|
|
18
|
+
exports.printSpecification = printSpecification;
|
|
19
|
+
const printScalarMetadata = (type, options) => {
|
|
20
|
+
return (0, exports.printSpecification)(type);
|
|
21
|
+
};
|
|
22
|
+
exports.printScalarMetadata = printScalarMetadata;
|
|
23
|
+
const printCodeScalar = (type, options) => {
|
|
24
|
+
return `scalar ${(0, graphql_1.getTypeName)(type)}`;
|
|
25
|
+
};
|
|
26
|
+
exports.printCodeScalar = printCodeScalar;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PrintTypeOptions, MDXString } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printUnionMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
3
|
+
export declare const printCodeUnion: (type: unknown, options?: PrintTypeOptions) => string;
|