@graphql-markdown/printer-legacy 1.9.0 → 1.9.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/code.js +2 -2
- package/dist/common.d.ts +0 -1
- package/dist/common.js +1 -20
- package/dist/example.d.ts +1 -1
- package/dist/example.js +41 -23
- package/dist/frontmatter.js +2 -1
- package/dist/graphql/enum.js +2 -2
- package/dist/link.d.ts +2 -1
- package/dist/link.js +22 -4
- package/dist/printer.js +2 -1
- package/dist/section.js +1 -1
- package/package.json +5 -5
package/dist/code.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
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
|
|
6
|
+
const link_1 = require("./link");
|
|
7
7
|
const printCodeArguments = (type, indentationLevel = 1) => {
|
|
8
8
|
if (typeof type !== "object" ||
|
|
9
9
|
type === null ||
|
|
@@ -33,7 +33,7 @@ const printCodeField = (type, options, indentationLevel = 0) => {
|
|
|
33
33
|
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
34
34
|
return "";
|
|
35
35
|
}
|
|
36
|
-
if (!(0,
|
|
36
|
+
if (!(0, link_1.hasPrintableDirective)(type, options)) {
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
39
|
let code = `${(0, graphql_1.getTypeName)(type)}`;
|
package/dist/common.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ export declare const formatDescription: (type: unknown, replacement?: Maybe<stri
|
|
|
4
4
|
export declare const printWarning: (text?: string, title?: string) => string;
|
|
5
5
|
export declare const printDeprecation: (type: unknown) => string;
|
|
6
6
|
export declare const printDescription: (type: unknown, options?: PrintTypeOptions, noText?: string) => MDXString | string;
|
|
7
|
-
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.
|
|
3
|
+
exports.printDescription = exports.printDeprecation = exports.printWarning = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
4
4
|
const utils_1 = require("@docusaurus/utils");
|
|
5
5
|
const utils_2 = require("@graphql-markdown/utils");
|
|
6
6
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
@@ -62,22 +62,3 @@ const printDescription = (type, options, noText) => {
|
|
|
62
62
|
return `${deprecation}${description}${customDirectives}`;
|
|
63
63
|
};
|
|
64
64
|
exports.printDescription = printDescription;
|
|
65
|
-
const hasPrintableDirective = (type, options) => {
|
|
66
|
-
if (!type) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
if (!options) {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
const skipDirective = "skipDocDirectives" in options && options.skipDocDirectives
|
|
73
|
-
? (0, graphql_1.hasDirective)(type, options.skipDocDirectives)
|
|
74
|
-
: false;
|
|
75
|
-
const skipDeprecated = "deprecated" in options &&
|
|
76
|
-
options.deprecated === "skip" &&
|
|
77
|
-
(0, graphql_1.isDeprecated)(type);
|
|
78
|
-
const onlyDirective = "onlyDocDirectives" in options && options.onlyDocDirectives
|
|
79
|
-
? (0, graphql_1.hasDirective)(type, options.onlyDocDirectives, true)
|
|
80
|
-
: true;
|
|
81
|
-
return !(skipDirective || skipDeprecated) && onlyDirective;
|
|
82
|
-
};
|
|
83
|
-
exports.hasPrintableDirective = hasPrintableDirective;
|
package/dist/example.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Maybe, PrintTypeOptions, TypeDirectiveExample } from "@graphql-markdown/types";
|
|
2
|
-
export declare const getDirectiveExampleOption: (
|
|
2
|
+
export declare const getDirectiveExampleOption: ({ exampleSection, schema, }: PrintTypeOptions) => Maybe<TypeDirectiveExample>;
|
|
3
3
|
export declare const printExample: (type: unknown, options: PrintTypeOptions) => Maybe<string>;
|
package/dist/example.js
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printExample = exports.getDirectiveExampleOption = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
6
|
+
const link_1 = require("./link");
|
|
7
|
+
const getDirectiveExampleOption = ({ exampleSection, schema, }) => {
|
|
7
8
|
let directiveName = "example", argName = "value", parserFunc = undefined;
|
|
8
|
-
if (
|
|
9
|
-
if ("directive" in
|
|
10
|
-
|
|
11
|
-
directiveName = options.exampleSection.directive;
|
|
9
|
+
if (exampleSection && typeof exampleSection === "object") {
|
|
10
|
+
if ("directive" in exampleSection && exampleSection.directive) {
|
|
11
|
+
directiveName = exampleSection.directive;
|
|
12
12
|
}
|
|
13
|
-
if ("field" in
|
|
14
|
-
argName =
|
|
13
|
+
if ("field" in exampleSection && exampleSection.field) {
|
|
14
|
+
argName = exampleSection.field;
|
|
15
15
|
}
|
|
16
|
-
if ("parser" in
|
|
17
|
-
parserFunc =
|
|
16
|
+
if ("parser" in exampleSection && exampleSection.parser) {
|
|
17
|
+
parserFunc = exampleSection.parser;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
const directive =
|
|
21
|
-
?
|
|
20
|
+
const directive = schema && (0, graphql_1.instanceOf)(schema, graphql_1.GraphQLSchema)
|
|
21
|
+
? schema.getDirective(directiveName)
|
|
22
22
|
: undefined;
|
|
23
23
|
if (!directive) {
|
|
24
24
|
return undefined;
|
|
@@ -30,7 +30,7 @@ const getDirectiveExampleOption = (options) => {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
exports.getDirectiveExampleOption = getDirectiveExampleOption;
|
|
33
|
-
const parseTypeFields = (type, options) => {
|
|
33
|
+
const parseTypeFields = (type, options, mappedTypes = []) => {
|
|
34
34
|
const directiveExample = (0, exports.getDirectiveExampleOption)(options);
|
|
35
35
|
if (!directiveExample) {
|
|
36
36
|
return undefined;
|
|
@@ -42,19 +42,26 @@ const parseTypeFields = (type, options) => {
|
|
|
42
42
|
let example = {};
|
|
43
43
|
fields
|
|
44
44
|
.filter((field) => {
|
|
45
|
-
return (0,
|
|
45
|
+
return (0, link_1.hasPrintableDirective)(field, options);
|
|
46
46
|
})
|
|
47
47
|
.forEach((field) => {
|
|
48
48
|
const fieldType = (0, graphql_1.hasDirective)(field, [directiveExample.directive])
|
|
49
49
|
? field
|
|
50
50
|
: field.type;
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
52
|
-
const value = parseExampleDirective(fieldType, options);
|
|
52
|
+
const value = parseExampleDirective(fieldType, options, mappedTypes);
|
|
53
|
+
let structuredValue = value;
|
|
54
|
+
if ((0, graphql_1.isListType)((0, graphql_1.getNullableType)(fieldType))) {
|
|
55
|
+
if (!value && (0, graphql_1.isNonNullType)(fieldType)) {
|
|
56
|
+
structuredValue = [];
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
structuredValue = value ? [value] : undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
53
62
|
example = {
|
|
54
63
|
...example,
|
|
55
|
-
[field.name]:
|
|
56
|
-
? [value]
|
|
57
|
-
: value,
|
|
64
|
+
[field.name]: structuredValue,
|
|
58
65
|
};
|
|
59
66
|
});
|
|
60
67
|
return example;
|
|
@@ -78,27 +85,38 @@ const parseExampleValue = (value, type) => {
|
|
|
78
85
|
}
|
|
79
86
|
return value;
|
|
80
87
|
};
|
|
81
|
-
const parseExampleDirective = (type, options) => {
|
|
88
|
+
const parseExampleDirective = (type, options, mappedTypes = []) => {
|
|
82
89
|
const directiveExample = (0, exports.getDirectiveExampleOption)(options);
|
|
83
|
-
if (!directiveExample || !(0,
|
|
90
|
+
if (!directiveExample || !(0, link_1.hasPrintableDirective)(type, options)) {
|
|
84
91
|
return undefined;
|
|
85
92
|
}
|
|
86
93
|
const parser = typeof directiveExample.parser === "function"
|
|
87
94
|
? directiveExample.parser
|
|
88
95
|
: parseExampleValue;
|
|
96
|
+
// get parent type
|
|
89
97
|
const namedType = (0, graphql_1.isType)(type) ? (0, graphql_1.getNamedType)(type) : type;
|
|
90
98
|
if (!namedType) {
|
|
91
99
|
return undefined;
|
|
92
100
|
}
|
|
101
|
+
// get type name
|
|
102
|
+
const typename = (0, graphql_1.isType)(namedType)
|
|
103
|
+
? (0, utils_1.toString)(namedType)
|
|
104
|
+
: (0, utils_1.toString)(namedType.name);
|
|
105
|
+
// recursion check
|
|
106
|
+
if (mappedTypes.includes(typename)) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
mappedTypes.push(typename);
|
|
93
110
|
try {
|
|
94
111
|
const arg = (0, graphql_1.getTypeDirectiveArgValue)(directiveExample.directive, namedType, directiveExample.field);
|
|
95
112
|
return parser(arg, namedType);
|
|
96
113
|
}
|
|
97
114
|
catch (err) {
|
|
98
115
|
if (err instanceof graphql_1.IntrospectionError) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
if (!(0, graphql_1.isType)(namedType)) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return parseTypeFields(namedType, options, mappedTypes);
|
|
102
120
|
}
|
|
103
121
|
throw err;
|
|
104
122
|
}
|
package/dist/frontmatter.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printFrontMatter = exports.formatFrontMatterProp = void 0;
|
|
4
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
4
5
|
const strings_1 = require("./const/strings");
|
|
5
6
|
const tabs = (indentation = 0) => {
|
|
6
7
|
return strings_1.MARKDOWN_CODE_INDENTATION.repeat(indentation);
|
|
@@ -30,7 +31,7 @@ const formatFrontMatterList = (prop, indentation = 0, prefix = "- ") => {
|
|
|
30
31
|
}));
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
frontMatter.push(`${tabs(indentation)}- ${entry}`);
|
|
34
|
+
frontMatter.push(`${tabs(indentation)}- ${(0, utils_1.toString)(entry)}`);
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
37
|
return frontMatter;
|
package/dist/graphql/enum.js
CHANGED
|
@@ -4,7 +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
|
|
7
|
+
const link_1 = require("../link");
|
|
8
8
|
const printEnumMetadata = (type, options) => {
|
|
9
9
|
if (!(0, graphql_1.isEnumType)(type)) {
|
|
10
10
|
return "";
|
|
@@ -20,7 +20,7 @@ const printCodeEnum = (type, options) => {
|
|
|
20
20
|
code += type
|
|
21
21
|
.getValues()
|
|
22
22
|
.map((value) => {
|
|
23
|
-
if (!(0,
|
|
23
|
+
if (!(0, link_1.hasPrintableDirective)(value, options)) {
|
|
24
24
|
return "";
|
|
25
25
|
}
|
|
26
26
|
const v = (0, graphql_1.getTypeName)(value);
|
package/dist/link.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
|
|
1
|
+
import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, PrintTypeOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
|
|
2
2
|
export declare const API_GROUPS: Required<ApiGroupOverrideType>;
|
|
3
|
+
export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
|
|
3
4
|
export declare const getCategoryLocale: (type: unknown) => Maybe<TypeLocale>;
|
|
4
5
|
export declare const getLinkCategoryFolder: (type: unknown, operationLocale?: Maybe<TypeLocale>) => Maybe<string>;
|
|
5
6
|
export declare const hasOptionWithAttributes: (options: PrintLinkOptions) => boolean;
|
package/dist/link.js
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.getLinkDeprecatedFolder = exports.getLinkApiGroupFolder = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategoryFolder = exports.getCategoryLocale = exports.API_GROUPS = void 0;
|
|
3
|
+
exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.getLinkDeprecatedFolder = exports.getLinkApiGroupFolder = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategoryFolder = exports.getCategoryLocale = exports.hasPrintableDirective = exports.API_GROUPS = 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");
|
|
9
8
|
const options_1 = require("./const/options");
|
|
10
9
|
exports.API_GROUPS = {
|
|
11
10
|
operations: "operations",
|
|
12
11
|
types: "types",
|
|
13
12
|
};
|
|
13
|
+
const hasPrintableDirective = (type, options) => {
|
|
14
|
+
if (!type) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (!options) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
const skipDirective = "skipDocDirectives" in options && options.skipDocDirectives
|
|
21
|
+
? (0, graphql_1.hasDirective)(type, options.skipDocDirectives)
|
|
22
|
+
: false;
|
|
23
|
+
const skipDeprecated = "deprecated" in options &&
|
|
24
|
+
options.deprecated === "skip" &&
|
|
25
|
+
(0, graphql_1.isDeprecated)(type);
|
|
26
|
+
const onlyDirective = "onlyDocDirectives" in options && options.onlyDocDirectives
|
|
27
|
+
? (0, graphql_1.hasDirective)(type, options.onlyDocDirectives, true)
|
|
28
|
+
: true;
|
|
29
|
+
return !(skipDirective || skipDeprecated) && onlyDirective;
|
|
30
|
+
};
|
|
31
|
+
exports.hasPrintableDirective = hasPrintableDirective;
|
|
14
32
|
const getCategoryLocale = (type) => {
|
|
15
33
|
switch (true) {
|
|
16
34
|
case (0, graphql_1.isDirectiveType)(type):
|
|
@@ -84,7 +102,7 @@ const toLink = (type, name, operation, options) => {
|
|
|
84
102
|
url: "#",
|
|
85
103
|
};
|
|
86
104
|
if (typeof type !== "object" ||
|
|
87
|
-
(typeof options !== "undefined" && !(0,
|
|
105
|
+
(typeof options !== "undefined" && !(0, exports.hasPrintableDirective)(type, options))) {
|
|
88
106
|
return fallback;
|
|
89
107
|
}
|
|
90
108
|
const graphQLNamedType = (0, graphql_1.getNamedType)(type);
|
|
@@ -150,7 +168,7 @@ const printLink = (type, options) => {
|
|
|
150
168
|
if (typeof type !== "object" || type === null) {
|
|
151
169
|
return "";
|
|
152
170
|
}
|
|
153
|
-
const link = (0, exports.toLink)(type, (0, graphql_1.getTypeName)(type,
|
|
171
|
+
const link = (0, exports.toLink)(type, (0, graphql_1.getTypeName)(type, (0, utils_1.toString)(type)), undefined, options);
|
|
154
172
|
if (typeof options !== "undefined" && !(0, exports.hasOptionWithAttributes)(options)) {
|
|
155
173
|
const textWithAttribute = (0, exports.hasOptionParentType)(options)
|
|
156
174
|
? `<code style={{ fontWeight: 'normal' }}>${options.parentType}.<b>${link.text}</b></code>`
|
package/dist/printer.js
CHANGED
|
@@ -8,6 +8,7 @@ const common_1 = require("./common");
|
|
|
8
8
|
const directive_1 = require("./directive");
|
|
9
9
|
const frontmatter_1 = require("./frontmatter");
|
|
10
10
|
const graphql_2 = require("./graphql");
|
|
11
|
+
const link_1 = require("./link");
|
|
11
12
|
const strings_1 = require("./const/strings");
|
|
12
13
|
const mdx_1 = require("./const/mdx");
|
|
13
14
|
const options_1 = require("./const/options");
|
|
@@ -143,7 +144,7 @@ class Printer {
|
|
|
143
144
|
...Printer.options,
|
|
144
145
|
...options,
|
|
145
146
|
};
|
|
146
|
-
if (!name || !(0,
|
|
147
|
+
if (!name || !(0, link_1.hasPrintableDirective)(type, printTypeOptions)) {
|
|
147
148
|
return undefined;
|
|
148
149
|
}
|
|
149
150
|
const header = Printer.printHeader(name, (0, graphql_1.getTypeName)(type), printTypeOptions);
|
package/dist/section.js
CHANGED
|
@@ -17,7 +17,7 @@ const printSectionItem = (type, options) => {
|
|
|
17
17
|
const level = "level" in options && typeof options.level === "string"
|
|
18
18
|
? options.level
|
|
19
19
|
: options_1.SectionLevels.LEVEL_4;
|
|
20
|
-
if (!(0,
|
|
20
|
+
if (!(0, link_1.hasPrintableDirective)(type, options)) {
|
|
21
21
|
return "";
|
|
22
22
|
}
|
|
23
23
|
const typeNameLink = (0, link_1.printLink)(type, {
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.9.
|
|
8
|
+
"version": "1.9.1",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@docusaurus/utils": ">=3.2.0",
|
|
60
|
-
"@graphql-markdown/graphql": "^1.1.
|
|
61
|
-
"@graphql-markdown/utils": "^1.7.
|
|
60
|
+
"@graphql-markdown/graphql": "^1.1.5",
|
|
61
|
+
"@graphql-markdown/utils": "^1.7.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@graphql-markdown/types": "^1.4.
|
|
64
|
+
"@graphql-markdown/types": "^1.4.2"
|
|
65
65
|
},
|
|
66
66
|
"resolutions": {
|
|
67
|
-
"micromatch": "4.0.
|
|
67
|
+
"micromatch": "4.0.8"
|
|
68
68
|
},
|
|
69
69
|
"directories": {
|
|
70
70
|
"test": "tests"
|