@graphql-markdown/printer-legacy 1.8.5 → 1.9.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/common.js +1 -1
- package/dist/const/options.d.ts +5 -0
- package/dist/const/options.js +8 -2
- package/dist/example.js +4 -7
- package/dist/link.d.ts +3 -2
- package/dist/link.js +35 -12
- package/dist/printer.js +1 -1
- package/package.json +4 -4
package/dist/common.js
CHANGED
|
@@ -8,7 +8,7 @@ const directive_1 = require("./directive");
|
|
|
8
8
|
const strings_1 = require("./const/strings");
|
|
9
9
|
const printCustomDirectives = (type, options) => {
|
|
10
10
|
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
|
|
11
|
-
if (
|
|
11
|
+
if ((0, utils_2.isEmpty)(constDirectiveMap)) {
|
|
12
12
|
return "";
|
|
13
13
|
}
|
|
14
14
|
const content = Object.values(constDirectiveMap)
|
package/dist/const/options.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { CollapsibleOption, GraphQLDirective, GraphQLSchema, Maybe, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, SectionLevelValue } from "@graphql-markdown/types";
|
|
2
|
+
export declare enum TypeHierarchy {
|
|
3
|
+
API = "api",
|
|
4
|
+
ENTITY = "entity",
|
|
5
|
+
FLAT = "flat"
|
|
6
|
+
}
|
|
2
7
|
export declare enum SectionLevels {
|
|
3
8
|
NONE = "",
|
|
4
9
|
LEVEL_3 = "###",
|
package/dist/const/options.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_OPTIONS = exports.PRINT_TYPE_DEFAULT_OPTIONS = exports.SectionLevels = void 0;
|
|
3
|
+
exports.DEFAULT_OPTIONS = exports.PRINT_TYPE_DEFAULT_OPTIONS = exports.SectionLevels = exports.TypeHierarchy = void 0;
|
|
4
|
+
var TypeHierarchy;
|
|
5
|
+
(function (TypeHierarchy) {
|
|
6
|
+
TypeHierarchy["API"] = "api";
|
|
7
|
+
TypeHierarchy["ENTITY"] = "entity";
|
|
8
|
+
TypeHierarchy["FLAT"] = "flat";
|
|
9
|
+
})(TypeHierarchy || (exports.TypeHierarchy = TypeHierarchy = {}));
|
|
4
10
|
var SectionLevels;
|
|
5
11
|
(function (SectionLevels) {
|
|
6
12
|
SectionLevels["NONE"] = "";
|
|
@@ -16,7 +22,7 @@ exports.PRINT_TYPE_DEFAULT_OPTIONS = {
|
|
|
16
22
|
parentTypePrefix: true,
|
|
17
23
|
relatedTypeSection: true,
|
|
18
24
|
typeBadges: true,
|
|
19
|
-
|
|
25
|
+
hierarchy: { [TypeHierarchy.API]: {} },
|
|
20
26
|
};
|
|
21
27
|
exports.DEFAULT_OPTIONS = {
|
|
22
28
|
...exports.PRINT_TYPE_DEFAULT_OPTIONS,
|
package/dist/example.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
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 utils_1 = require("@graphql-markdown/utils");
|
|
6
5
|
const common_1 = require("./common");
|
|
7
6
|
const getDirectiveExampleOption = (options) => {
|
|
8
7
|
let directiveName = "example", argName = "value", parserFunc = undefined;
|
|
@@ -18,7 +17,7 @@ const getDirectiveExampleOption = (options) => {
|
|
|
18
17
|
parserFunc = options.exampleSection.parser;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
const directive = options.schema &&
|
|
20
|
+
const directive = options.schema && (0, graphql_1.instanceOf)(options.schema, graphql_1.GraphQLSchema)
|
|
22
21
|
? options.schema.getDirective(directiveName)
|
|
23
22
|
: undefined;
|
|
24
23
|
if (!directive) {
|
|
@@ -60,21 +59,19 @@ const parseTypeFields = (type, options) => {
|
|
|
60
59
|
});
|
|
61
60
|
return example;
|
|
62
61
|
};
|
|
63
|
-
const parseExampleValue = (value,
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
65
|
-
type) => {
|
|
62
|
+
const parseExampleValue = (value, type) => {
|
|
66
63
|
if (!value || typeof value !== "string") {
|
|
67
64
|
return undefined;
|
|
68
65
|
}
|
|
69
66
|
try {
|
|
70
67
|
return JSON.parse(value);
|
|
71
68
|
}
|
|
72
|
-
catch
|
|
69
|
+
catch {
|
|
73
70
|
if ((0, graphql_1.isOperation)(type)) {
|
|
74
71
|
try {
|
|
75
72
|
return (0, graphql_1.parse)(value, { noLocation: true });
|
|
76
73
|
}
|
|
77
|
-
catch
|
|
74
|
+
catch {
|
|
78
75
|
/* empty */
|
|
79
76
|
}
|
|
80
77
|
}
|
package/dist/link.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { MDXString, Maybe, PrintLinkOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
|
|
1
|
+
import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
|
|
2
|
+
export declare const API_GROUPS: Required<ApiGroupOverrideType>;
|
|
2
3
|
export declare const getCategoryLocale: (type: unknown) => Maybe<TypeLocale>;
|
|
3
4
|
export declare const getLinkCategoryFolder: (type: unknown, operationLocale?: Maybe<TypeLocale>) => Maybe<string>;
|
|
4
5
|
export declare const hasOptionWithAttributes: (options: PrintLinkOptions) => boolean;
|
|
5
6
|
export declare const hasOptionParentType: (options: PrintLinkOptions) => boolean;
|
|
6
|
-
export declare const getLinkApiGroupFolder: (type: unknown) => string;
|
|
7
|
+
export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<ApiGroupOverrideType | boolean>) => string;
|
|
7
8
|
export declare const getLinkDeprecatedFolder: (type: unknown, option: Maybe<TypeDeprecatedOption>) => string;
|
|
8
9
|
export declare const toLink: (type: unknown, name: string, operation: Maybe<TypeLocale>, options: PrintLinkOptions) => TypeLink;
|
|
9
10
|
export declare const getRelationLink: (category: Maybe<TypeLocale>, type: unknown, options: PrintLinkOptions) => Maybe<TypeLink>;
|
package/dist/link.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
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 = 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.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
8
|
const common_1 = require("./common");
|
|
9
|
+
const options_1 = require("./const/options");
|
|
10
|
+
exports.API_GROUPS = {
|
|
11
|
+
operations: "operations",
|
|
12
|
+
types: "types",
|
|
13
|
+
};
|
|
9
14
|
const getCategoryLocale = (type) => {
|
|
10
15
|
switch (true) {
|
|
11
16
|
case (0, graphql_1.isDirectiveType)(type):
|
|
@@ -58,14 +63,21 @@ const hasOptionParentType = (options) => {
|
|
|
58
63
|
typeof options.parentType !== "undefined");
|
|
59
64
|
};
|
|
60
65
|
exports.hasOptionParentType = hasOptionParentType;
|
|
61
|
-
const getLinkApiGroupFolder = (type) => {
|
|
62
|
-
|
|
66
|
+
const getLinkApiGroupFolder = (type, groups) => {
|
|
67
|
+
let folderNames = exports.API_GROUPS;
|
|
68
|
+
if (groups && typeof groups === "object") {
|
|
69
|
+
folderNames = { ...exports.API_GROUPS, ...groups };
|
|
70
|
+
}
|
|
71
|
+
return (0, graphql_1.isApiType)(type) ? folderNames.operations : folderNames.types;
|
|
63
72
|
};
|
|
64
73
|
exports.getLinkApiGroupFolder = getLinkApiGroupFolder;
|
|
65
74
|
const getLinkDeprecatedFolder = (type, option) => {
|
|
66
75
|
return option === "group" && (0, graphql_1.isDeprecated)(type) ? strings_1.DEPRECATED : "";
|
|
67
76
|
};
|
|
68
77
|
exports.getLinkDeprecatedFolder = getLinkDeprecatedFolder;
|
|
78
|
+
const isHierarchy = (options, hierarchy) => {
|
|
79
|
+
return (options?.hierarchy?.[hierarchy] && true);
|
|
80
|
+
};
|
|
69
81
|
const toLink = (type, name, operation, options) => {
|
|
70
82
|
const fallback = {
|
|
71
83
|
text: name,
|
|
@@ -76,18 +88,29 @@ const toLink = (type, name, operation, options) => {
|
|
|
76
88
|
return fallback;
|
|
77
89
|
}
|
|
78
90
|
const graphQLNamedType = (0, graphql_1.getNamedType)(type);
|
|
79
|
-
|
|
80
|
-
if (!category || !graphQLNamedType) {
|
|
91
|
+
if (!graphQLNamedType) {
|
|
81
92
|
return fallback;
|
|
82
93
|
}
|
|
94
|
+
let category = "";
|
|
95
|
+
let deprecatedFolder = "";
|
|
96
|
+
let groupFolder = "";
|
|
97
|
+
let apiGroupFolder = "";
|
|
98
|
+
if (!isHierarchy(options, options_1.TypeHierarchy.FLAT)) {
|
|
99
|
+
category = (0, exports.getLinkCategoryFolder)(graphQLNamedType, operation);
|
|
100
|
+
if (!category) {
|
|
101
|
+
return fallback;
|
|
102
|
+
}
|
|
103
|
+
deprecatedFolder = options.deprecated
|
|
104
|
+
? (0, exports.getLinkDeprecatedFolder)(type, options.deprecated)
|
|
105
|
+
: "";
|
|
106
|
+
groupFolder = options.groups
|
|
107
|
+
? (0, group_1.getGroup)(type, options.groups, category)
|
|
108
|
+
: "";
|
|
109
|
+
apiGroupFolder = isHierarchy(options, options_1.TypeHierarchy.API)
|
|
110
|
+
? (0, exports.getLinkApiGroupFolder)(type)
|
|
111
|
+
: "";
|
|
112
|
+
}
|
|
83
113
|
const text = graphQLNamedType.name || graphQLNamedType.toString();
|
|
84
|
-
const deprecatedFolder = options.deprecated
|
|
85
|
-
? (0, exports.getLinkDeprecatedFolder)(type, options.deprecated)
|
|
86
|
-
: "";
|
|
87
|
-
const groupFolder = options.groups
|
|
88
|
-
? (0, group_1.getGroup)(type, options.groups, category)
|
|
89
|
-
: "";
|
|
90
|
-
const apiGroupFolder = options.useApiGroup ? (0, exports.getLinkApiGroupFolder)(type) : "";
|
|
91
114
|
const url = utils_1.pathUrl.join(options.basePath, deprecatedFolder, apiGroupFolder, groupFolder, category, `${(0, utils_1.slugify)(text)}${strings_1.LINK_MDX_EXTENSION}`);
|
|
92
115
|
return {
|
|
93
116
|
text,
|
package/dist/printer.js
CHANGED
|
@@ -42,7 +42,7 @@ class Printer {
|
|
|
42
42
|
skipDocDirectives: skipDocDirectives ?? [],
|
|
43
43
|
typeBadges: printTypeOptions?.typeBadges ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.typeBadges,
|
|
44
44
|
metatags: metatags ?? [],
|
|
45
|
-
|
|
45
|
+
hierarchy: printTypeOptions?.hierarchy ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.hierarchy,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
static printHeader = (id, title, options) => {
|
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.
|
|
8
|
+
"version": "1.9.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@docusaurus/utils": ">=3.2.0",
|
|
60
|
-
"@graphql-markdown/graphql": "^1.1.
|
|
61
|
-
"@graphql-markdown/utils": "^1.
|
|
60
|
+
"@graphql-markdown/graphql": "^1.1.4",
|
|
61
|
+
"@graphql-markdown/utils": "^1.7.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@graphql-markdown/types": "^1.
|
|
64
|
+
"@graphql-markdown/types": "^1.4.0"
|
|
65
65
|
},
|
|
66
66
|
"resolutions": {
|
|
67
67
|
"micromatch": "4.0.7"
|