@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.
- package/dist/badge.d.ts +5 -0
- package/dist/badge.js +66 -0
- package/dist/code.d.ts +3 -0
- package/dist/code.js +46 -0
- package/dist/common.d.ts +6 -0
- package/dist/common.js +69 -0
- package/dist/const/mdx.d.ts +2 -0
- package/{src → dist}/const/mdx.js +4 -1
- package/dist/const/options.d.ts +17 -0
- package/dist/const/options.js +33 -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 +76 -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 +37 -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 +137 -0
- package/dist/printer.d.ts +21 -0
- package/dist/printer.js +166 -0
- package/dist/relation.d.ts +4 -0
- package/dist/relation.js +71 -0
- package/dist/section.d.ts +6 -0
- package/dist/section.js +136 -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 printBadge: ({ text, classname }: Badge) => MDXString;
|
|
5
|
+
export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
package/dist/badge.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printBadges = exports.printBadge = 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 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;
|
|
50
|
+
const printBadges = (type, options) => {
|
|
51
|
+
if (!("typeBadges" in options) ||
|
|
52
|
+
typeof options.typeBadges !== "boolean" ||
|
|
53
|
+
!options.typeBadges) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
const badges = (0, exports.getTypeBadges)(type, options.groups);
|
|
57
|
+
if (badges.length === 0) {
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
return badges
|
|
61
|
+
.map((badge) => {
|
|
62
|
+
return (0, exports.printBadge)(badge);
|
|
63
|
+
})
|
|
64
|
+
.join(" ");
|
|
65
|
+
};
|
|
66
|
+
exports.printBadges = printBadges;
|
package/dist/code.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
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
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCodeField = exports.printCodeArguments = void 0;
|
|
4
|
+
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const strings_1 = require("./const/strings");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
const printCodeArguments = (type, indentationLevel = 1) => {
|
|
8
|
+
if (typeof type !== "object" ||
|
|
9
|
+
type === null ||
|
|
10
|
+
!("args" in type) ||
|
|
11
|
+
!Array.isArray(type.args) ||
|
|
12
|
+
type.args.length === 0) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
const argIndentation = strings_1.MARKDOWN_CODE_INDENTATION.repeat(indentationLevel);
|
|
16
|
+
const parentIndentation = indentationLevel === 1 ? "" : strings_1.MARKDOWN_CODE_INDENTATION;
|
|
17
|
+
let code = `(${strings_1.MARKDOWN_EOL}`;
|
|
18
|
+
code += type.args.reduce((r, v) => {
|
|
19
|
+
const defaultValue = (0, graphql_1.getFormattedDefaultValue)(v);
|
|
20
|
+
const hasDefaultValue = typeof defaultValue !== "undefined" && defaultValue !== null;
|
|
21
|
+
const printedDefault = hasDefaultValue
|
|
22
|
+
? ` = ${(0, graphql_1.getFormattedDefaultValue)(v)}`
|
|
23
|
+
: "";
|
|
24
|
+
const propType = String(v.type);
|
|
25
|
+
const propName = String(v.name);
|
|
26
|
+
return `${r}${argIndentation}${propName}: ${propType}${printedDefault}${strings_1.MARKDOWN_EOL}`;
|
|
27
|
+
}, "");
|
|
28
|
+
code += `${parentIndentation})`;
|
|
29
|
+
return code;
|
|
30
|
+
};
|
|
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
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
6
|
+
export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasPrintableDirective = 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) => {
|
|
15
|
+
return (0, directive_1.getCustomDirectiveResolver)("descriptor", type, constDirectiveOption, "");
|
|
16
|
+
})
|
|
17
|
+
.filter((text) => {
|
|
18
|
+
return typeof text === "string" && text.length > 0;
|
|
19
|
+
})
|
|
20
|
+
.join(strings_1.MARKDOWN_EOP);
|
|
21
|
+
return `${strings_1.MARKDOWN_EOP}${content}`;
|
|
22
|
+
};
|
|
23
|
+
exports.printCustomDirectives = printCustomDirectives;
|
|
24
|
+
const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) => {
|
|
25
|
+
if (typeof type !== "object" || type === null) {
|
|
26
|
+
return `${strings_1.MARKDOWN_EOP}${replacement}`;
|
|
27
|
+
}
|
|
28
|
+
const description = "description" in type && typeof type.description === "string"
|
|
29
|
+
? (0, utils_1.escapeMDX)(type.description)
|
|
30
|
+
: replacement;
|
|
31
|
+
return `${strings_1.MARKDOWN_EOP}${description}`;
|
|
32
|
+
};
|
|
33
|
+
exports.formatDescription = formatDescription;
|
|
34
|
+
const printDeprecation = (type) => {
|
|
35
|
+
if (typeof type !== "object" || type === null || !(0, graphql_1.isDeprecated)(type)) {
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
const reason = "deprecationReason" in type && typeof type.deprecationReason === "string"
|
|
39
|
+
? type.deprecationReason + strings_1.MARKDOWN_EOL
|
|
40
|
+
: "";
|
|
41
|
+
return `${strings_1.MARKDOWN_EOP}:::caution ${strings_1.DEPRECATED.toUpperCase()}${strings_1.MARKDOWN_EOL}${reason}:::`;
|
|
42
|
+
};
|
|
43
|
+
exports.printDeprecation = printDeprecation;
|
|
44
|
+
const printDescription = (type, options, noText) => {
|
|
45
|
+
const description = (0, exports.formatDescription)(type, noText);
|
|
46
|
+
const customDirectives = (0, exports.printCustomDirectives)(type, options);
|
|
47
|
+
const deprecation = (0, exports.printDeprecation)(type);
|
|
48
|
+
return `${deprecation}${description}${customDirectives}`;
|
|
49
|
+
};
|
|
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;
|
|
@@ -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,17 @@
|
|
|
1
|
+
import type { CollapsibleOption, GraphQLDirective, 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" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
10
|
+
collapsible: Maybe<CollapsibleOption>;
|
|
11
|
+
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
12
|
+
level: Maybe<SectionLevelValue>;
|
|
13
|
+
onlyDocDirectives: GraphQLDirective[];
|
|
14
|
+
parentType: Maybe<string>;
|
|
15
|
+
schema: Maybe<GraphQLSchema>;
|
|
16
|
+
skipDocDirectives: GraphQLDirective[];
|
|
17
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
metatags: [],
|
|
15
|
+
parentTypePrefix: true,
|
|
16
|
+
relatedTypeSection: true,
|
|
17
|
+
typeBadges: true,
|
|
18
|
+
};
|
|
19
|
+
exports.DEFAULT_OPTIONS = {
|
|
20
|
+
...exports.PRINT_TYPE_DEFAULT_OPTIONS,
|
|
21
|
+
basePath: "/",
|
|
22
|
+
collapsible: undefined,
|
|
23
|
+
customDirectives: {},
|
|
24
|
+
groups: undefined,
|
|
25
|
+
header: { toc: true, pagination: true },
|
|
26
|
+
level: undefined,
|
|
27
|
+
metatags: [],
|
|
28
|
+
onlyDocDirectives: [],
|
|
29
|
+
parentType: undefined,
|
|
30
|
+
schema: undefined,
|
|
31
|
+
skipDocDirectives: [],
|
|
32
|
+
withAttributes: false,
|
|
33
|
+
};
|
|
@@ -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 getCustomDirectiveResolver: (resolver: CustomDirectiveResolver, type: unknown, constDirectiveOption: CustomDirectiveMapItem, fallback?: Maybe<string>) => Maybe<string>;
|
|
3
|
+
export declare const printCustomDirective: (type: unknown, constDirectiveOption: CustomDirectiveMapItem, options: PrintTypeOptions) => Maybe<string>;
|
|
4
|
+
export declare const printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
5
|
+
export declare const getCustomTags: (type: unknown, options: PrintTypeOptions) => Badge[];
|
|
6
|
+
export declare const printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printCustomTags = exports.getCustomTags = exports.printCustomDirectives = exports.printCustomDirective = exports.getCustomDirectiveResolver = 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 getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallback) => {
|
|
10
|
+
if (typeof constDirectiveOption === "undefined" ||
|
|
11
|
+
typeof constDirectiveOption.type !== "object" ||
|
|
12
|
+
typeof constDirectiveOption[resolver] !== "function") {
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
return constDirectiveOption[resolver](constDirectiveOption.type, type);
|
|
16
|
+
};
|
|
17
|
+
exports.getCustomDirectiveResolver = getCustomDirectiveResolver;
|
|
18
|
+
const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
19
|
+
const typeNameLink = (0, link_1.printLink)(constDirectiveOption.type, {
|
|
20
|
+
...options,
|
|
21
|
+
withAttributes: false,
|
|
22
|
+
});
|
|
23
|
+
const description = (0, exports.getCustomDirectiveResolver)("descriptor", type, constDirectiveOption);
|
|
24
|
+
if (typeof description !== "string") {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return `${options_1.SectionLevels.LEVEL_4} ${typeNameLink}${strings_1.MARKDOWN_EOL}> ${description}${strings_1.MARKDOWN_EOL}> `;
|
|
28
|
+
};
|
|
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;
|
|
49
|
+
const getCustomTags = (type, options) => {
|
|
50
|
+
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
|
|
51
|
+
if (typeof constDirectiveMap !== "object" ||
|
|
52
|
+
constDirectiveMap === null ||
|
|
53
|
+
!Object.keys(constDirectiveMap).length) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
return Object.values(constDirectiveMap)
|
|
57
|
+
.map((constDirectiveOption) => {
|
|
58
|
+
return (0, exports.getCustomDirectiveResolver)("tag", type, constDirectiveOption);
|
|
59
|
+
})
|
|
60
|
+
.filter((value) => {
|
|
61
|
+
return typeof value !== "undefined";
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
exports.getCustomTags = getCustomTags;
|
|
65
|
+
const printCustomTags = (type, options) => {
|
|
66
|
+
const badges = (0, exports.getCustomTags)(type, options);
|
|
67
|
+
if (badges.length === 0) {
|
|
68
|
+
return "";
|
|
69
|
+
}
|
|
70
|
+
return badges
|
|
71
|
+
.map((badge) => {
|
|
72
|
+
return (0, badge_1.printBadge)(badge);
|
|
73
|
+
})
|
|
74
|
+
.join(" ");
|
|
75
|
+
};
|
|
76
|
+
exports.printCustomTags = printCustomTags;
|
|
@@ -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,3 @@
|
|
|
1
|
+
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printEnumMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
3
|
+
export declare const printCodeEnum: (type: unknown, options?: PrintTypeOptions) => string;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 common_1 = require("../common");
|
|
8
|
+
const printEnumMetadata = (type, options) => {
|
|
9
|
+
if (!(0, graphql_1.isEnumType)(type)) {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
return (0, section_1.printMetadataSection)(type, type.getValues(), "Values", options);
|
|
13
|
+
};
|
|
14
|
+
exports.printEnumMetadata = printEnumMetadata;
|
|
15
|
+
const printCodeEnum = (type, options) => {
|
|
16
|
+
if (!(0, graphql_1.isEnumType)(type)) {
|
|
17
|
+
return "";
|
|
18
|
+
}
|
|
19
|
+
let code = `enum ${(0, graphql_1.getTypeName)(type)} {${strings_1.MARKDOWN_EOL}`;
|
|
20
|
+
code += type
|
|
21
|
+
.getValues()
|
|
22
|
+
.map((value) => {
|
|
23
|
+
if (!(0, common_1.hasPrintableDirective)(value, options)) {
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
const v = (0, graphql_1.getTypeName)(value);
|
|
27
|
+
const d = (0, graphql_1.isDeprecated)(value) ? ` @${strings_1.DEPRECATED}` : "";
|
|
28
|
+
return ` ${v}${d}`;
|
|
29
|
+
})
|
|
30
|
+
.filter((value) => {
|
|
31
|
+
return value.length > 0;
|
|
32
|
+
})
|
|
33
|
+
.join(strings_1.MARKDOWN_EOL);
|
|
34
|
+
code += `${strings_1.MARKDOWN_EOL}}`;
|
|
35
|
+
return code;
|
|
36
|
+
};
|
|
37
|
+
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;
|