@graphql-markdown/printer-legacy 1.12.3 → 1.12.5

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.
Files changed (69) hide show
  1. package/dist/badge.d.ts +4 -3
  2. package/dist/badge.d.ts.map +1 -0
  3. package/dist/badge.js +2 -2
  4. package/dist/code.d.ts +2 -1
  5. package/dist/code.d.ts.map +1 -0
  6. package/dist/code.js +24 -22
  7. package/dist/common.d.ts +7 -8
  8. package/dist/common.d.ts.map +1 -0
  9. package/dist/common.js +3 -5
  10. package/dist/const/options.d.ts +2 -1
  11. package/dist/const/options.d.ts.map +1 -0
  12. package/dist/const/strings.d.ts +1 -0
  13. package/dist/const/strings.d.ts.map +1 -0
  14. package/dist/directive.d.ts +4 -3
  15. package/dist/directive.d.ts.map +1 -0
  16. package/dist/directive.js +7 -8
  17. package/dist/example.d.ts +1 -0
  18. package/dist/example.d.ts.map +1 -0
  19. package/dist/format-helpers.d.ts +42 -0
  20. package/dist/format-helpers.d.ts.map +1 -0
  21. package/dist/format-helpers.js +74 -0
  22. package/dist/formatter.d.ts +28 -0
  23. package/dist/formatter.d.ts.map +1 -0
  24. package/dist/formatter.js +63 -0
  25. package/dist/frontmatter.d.ts +1 -0
  26. package/dist/frontmatter.d.ts.map +1 -0
  27. package/dist/graphql/directive.d.ts +3 -2
  28. package/dist/graphql/directive.d.ts.map +1 -0
  29. package/dist/graphql/directive.js +1 -1
  30. package/dist/graphql/enum.d.ts +3 -2
  31. package/dist/graphql/enum.d.ts.map +1 -0
  32. package/dist/graphql/index.d.ts +1 -0
  33. package/dist/graphql/index.d.ts.map +1 -0
  34. package/dist/graphql/input.d.ts +2 -1
  35. package/dist/graphql/input.d.ts.map +1 -0
  36. package/dist/graphql/input.js +2 -1
  37. package/dist/graphql/interface.d.ts +2 -1
  38. package/dist/graphql/interface.d.ts.map +1 -0
  39. package/dist/graphql/interface.js +2 -1
  40. package/dist/graphql/object.d.ts +1 -0
  41. package/dist/graphql/object.d.ts.map +1 -0
  42. package/dist/graphql/operation.d.ts +4 -3
  43. package/dist/graphql/operation.d.ts.map +1 -0
  44. package/dist/graphql/operation.js +3 -3
  45. package/dist/graphql/scalar.d.ts +4 -3
  46. package/dist/graphql/scalar.d.ts.map +1 -0
  47. package/dist/graphql/union.d.ts +3 -2
  48. package/dist/graphql/union.d.ts.map +1 -0
  49. package/dist/group.d.ts +3 -2
  50. package/dist/group.d.ts.map +1 -0
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +1 -1
  54. package/dist/link.d.ts +5 -7
  55. package/dist/link.d.ts.map +1 -0
  56. package/dist/link.js +12 -13
  57. package/dist/mdx/index.d.ts +2 -1
  58. package/dist/mdx/index.d.ts.map +1 -0
  59. package/dist/mdx/index.js +2 -2
  60. package/dist/printer.d.ts +8 -12
  61. package/dist/printer.d.ts.map +1 -0
  62. package/dist/printer.js +24 -25
  63. package/dist/relation.d.ts +8 -7
  64. package/dist/relation.d.ts.map +1 -0
  65. package/dist/relation.js +9 -9
  66. package/dist/section.d.ts +5 -4
  67. package/dist/section.d.ts.map +1 -0
  68. package/dist/section.js +1 -1
  69. package/package.json +9 -9
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.printCodeInput = exports.printInputMetadata = void 0;
4
4
  const object_1 = require("./object");
5
- exports.printInputMetadata = object_1.printObjectMetadata;
5
+ const object_2 = require("./object");
6
+ Object.defineProperty(exports, "printInputMetadata", { enumerable: true, get: function () { return object_2.printObjectMetadata; } });
6
7
  const printCodeInput = (type, options) => {
7
8
  return (0, object_1.printCodeType)(type, "input", options);
8
9
  };
@@ -7,7 +7,7 @@ import type { PrintTypeOptions } from "@graphql-markdown/types";
7
7
  * Prints metadata for a GraphQL interface type.
8
8
  * This is an alias for {@link printObjectMetadata}.
9
9
  */
10
- export declare const printInterfaceMetadata: (type: unknown, options: PrintTypeOptions) => string;
10
+ export { printObjectMetadata as printInterfaceMetadata } from "./object";
11
11
  /**
12
12
  * Generates a code block representation of a GraphQL interface type.
13
13
  *
@@ -16,3 +16,4 @@ export declare const printInterfaceMetadata: (type: unknown, options: PrintTypeO
16
16
  * @returns A string containing the Markdown code block representation
17
17
  */
18
18
  export declare const printCodeInterface: (type: unknown, options: PrintTypeOptions) => string;
19
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/graphql/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE;;;GAGG;AACH,OAAO,EAAE,mBAAmB,IAAI,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,sDAK9B,CAAC"}
@@ -10,7 +10,8 @@ const object_1 = require("./object");
10
10
  * Prints metadata for a GraphQL interface type.
11
11
  * This is an alias for {@link printObjectMetadata}.
12
12
  */
13
- exports.printInterfaceMetadata = object_1.printObjectMetadata;
13
+ const object_2 = require("./object");
14
+ Object.defineProperty(exports, "printInterfaceMetadata", { enumerable: true, get: function () { return object_2.printObjectMetadata; } });
14
15
  /**
15
16
  * Generates a code block representation of a GraphQL interface type.
16
17
  *
@@ -25,3 +25,4 @@ export declare const printCodeType: (type: unknown, entity: string, options: Pri
25
25
  * @returns GraphQL object type definition as a code block string
26
26
  */
27
27
  export declare const printCodeObject: (type: unknown, options: PrintTypeOptions) => string;
28
+ //# sourceMappingURL=object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/graphql/object.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA8BhE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,sDAa/B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,sEAgCzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,sDAK3B,CAAC"}
@@ -10,16 +10,17 @@ import type { PrintTypeOptions, MDXString } from "@graphql-markdown/types";
10
10
  * @param options - Print type options for customizing output
11
11
  * @returns Formatted string representation of the operation type or empty string if invalid
12
12
  */
13
- export declare const printOperationType: (type: unknown, options: PrintTypeOptions) => MDXString | string;
13
+ export declare const printOperationType: (type: unknown, options: PrintTypeOptions) => string | MDXString;
14
14
  /**
15
15
  * Prints the operation metadata including arguments and type information.
16
16
  * @param type - The operation type to print metadata for
17
17
  * @param options - Print type options for customizing output
18
18
  * @returns Formatted string containing operation metadata or empty string if invalid
19
19
  */
20
- export declare const printOperationMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
20
+ export declare const printOperationMetadata: (type: unknown, options: PrintTypeOptions) => string | MDXString;
21
21
  /**
22
22
  * Prints the code representation of an operation.
23
23
  * @see printCodeField
24
24
  */
25
- export declare const printCodeOperation: (type: unknown, options?: PrintTypeOptions, indentationLevel?: number) => MDXString | string;
25
+ export { printCodeField as printCodeOperation } from "../code";
26
+ //# sourceMappingURL=operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/graphql/operation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAK3E;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,kEAa9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,kEAYlC,CAAC;AAEF;;;GAGG;AACH,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.printCodeOperation = exports.printOperationMetadata = exports.printOperationType = void 0;
9
9
  const graphql_1 = require("@graphql-markdown/graphql");
10
10
  const section_1 = require("../section");
11
- const code_1 = require("../code");
12
11
  /**
13
12
  * Prints the operation type information.
14
13
  * @param type - The operation type to print
@@ -19,7 +18,7 @@ const printOperationType = (type, options) => {
19
18
  if (!(0, graphql_1.isOperation)(type)) {
20
19
  return "";
21
20
  }
22
- const queryType = (0, graphql_1.getTypeName)(type.type).replace(/[![\]]*/g, "");
21
+ const queryType = (0, graphql_1.getTypeName)(type.type).replaceAll(/[![\]]*/g, "");
23
22
  return (0, section_1.printSection)([options.schema.getType(queryType)], "Type", {
24
23
  ...options,
25
24
  parentTypePrefix: false,
@@ -45,4 +44,5 @@ exports.printOperationMetadata = printOperationMetadata;
45
44
  * Prints the code representation of an operation.
46
45
  * @see printCodeField
47
46
  */
48
- exports.printCodeOperation = code_1.printCodeField;
47
+ const code_1 = require("../code");
48
+ Object.defineProperty(exports, "printCodeOperation", { enumerable: true, get: function () { return code_1.printCodeField; } });
@@ -9,7 +9,7 @@ import type { PrintTypeOptions, MDXString } from "@graphql-markdown/types";
9
9
  * @param options - Options for printing type information
10
10
  * @returns Markdown string containing the specification link, or empty string if no URL exists
11
11
  */
12
- export declare const printSpecification: (type: unknown, options: PrintTypeOptions) => MDXString | string;
12
+ export declare const printSpecification: (type: unknown, options: PrintTypeOptions) => string | MDXString;
13
13
  /**
14
14
  * Prints metadata information for a scalar type.
15
15
  * Currently only includes the specification URL if available.
@@ -17,11 +17,12 @@ export declare const printSpecification: (type: unknown, options: PrintTypeOptio
17
17
  * @param options - Options for printing type information
18
18
  * @returns Markdown string containing the scalar metadata
19
19
  */
20
- export declare const printScalarMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
20
+ export declare const printScalarMetadata: (type: unknown, options: PrintTypeOptions) => string | MDXString;
21
21
  /**
22
22
  * Generates the GraphQL SDL representation of a scalar type.
23
23
  * @param type - The GraphQL scalar type object
24
24
  * @param options - Options for printing type information (unused)
25
25
  * @returns SDL string representation of the scalar type
26
26
  */
27
- export declare const printCodeScalar: (type: unknown, options?: PrintTypeOptions) => string;
27
+ export declare const printCodeScalar: (type: unknown, options?: PrintTypeOptions | undefined) => string;
28
+ //# sourceMappingURL=scalar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/graphql/scalar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAO3E;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,kEAiB9B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,kEAK/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,mEAK3B,CAAC"}
@@ -9,11 +9,12 @@ import type { PrintTypeOptions, MDXString } from "@graphql-markdown/types";
9
9
  * @param options - Configuration options for printing
10
10
  * @returns Formatted MDX string containing the union type's possible types
11
11
  */
12
- export declare const printUnionMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
12
+ export declare const printUnionMetadata: (type: unknown, options: PrintTypeOptions) => string | MDXString;
13
13
  /**
14
14
  * Generates GraphQL SDL code representation of a Union type.
15
15
  * @param type - The GraphQL type to process
16
16
  * @param options - Configuration options for printing (unused)
17
17
  * @returns SDL string representation of the union type
18
18
  */
19
- export declare const printCodeUnion: (type: unknown, options?: PrintTypeOptions) => string;
19
+ export declare const printCodeUnion: (type: unknown, options?: PrintTypeOptions | undefined) => string;
20
+ //# sourceMappingURL=union.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../src/graphql/union.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EAEV,MAAM,yBAAyB,CAAC;AAMjC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,kEAY9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,mEAiB1B,CAAC"}
package/dist/group.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Utility module for handling GraphQL schema entity grouping.
3
3
  * @module
4
4
  */
5
- import type { SchemaEntitiesGroupMap, SchemaEntity, Maybe } from "@graphql-markdown/types";
5
+ import type { SchemaEntity, Maybe } from "@graphql-markdown/types";
6
6
  /**
7
7
  * Retrieves the group name for a given GraphQL type based on its category and group mapping.
8
8
  *
@@ -11,4 +11,5 @@ import type { SchemaEntitiesGroupMap, SchemaEntity, Maybe } from "@graphql-markd
11
11
  * @param typeCategory - The category of the schema entity
12
12
  * @returns The slugified group name or empty string if no group is found
13
13
  */
14
- export declare const getGroup: (type: unknown, groups: Maybe<SchemaEntitiesGroupMap>, typeCategory: Maybe<SchemaEntity>) => string;
14
+ export declare const getGroup: (type: unknown, groups: Maybe<Partial<Record<SchemaEntity, Record<string, Maybe<string>>>>>, typeCategory: Maybe<SchemaEntity>) => string;
15
+ //# sourceMappingURL=group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAEV,YAAY,EAEZ,KAAK,EACN,MAAM,yBAAyB,CAAC;AAMjC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,2IA+BpB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { Printer } from "./printer";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Printer = void 0;
4
- var printer_1 = require("./printer");
4
+ const printer_1 = require("./printer");
5
5
  Object.defineProperty(exports, "Printer", { enumerable: true, get: function () { return printer_1.Printer; } });
package/dist/link.d.ts CHANGED
@@ -9,13 +9,10 @@ export declare const API_GROUPS: Required<ApiGroupOverrideType>;
9
9
  * Checks if a type has printable directives based on the provided options.
10
10
  *
11
11
  * @param type - The GraphQL type to check
12
- * @param options - Configuration options for directive printing
13
- * @param options.deprecated - How to handle deprecated types
14
- * @param options.onlyDocDirectives - Only print types with specific directives
15
- * @param options.skipDocDirectives - Skip types with specific directives
12
+ * @param options - Configuration options for directive printing (`deprecated`, `onlyDocDirectives`, `skipDocDirectives`)
16
13
  * @returns `true` if the type should be printed, `false` otherwise
17
14
  */
18
- export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
15
+ export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives"> | undefined) => boolean;
19
16
  /**
20
17
  * Gets the locale category for a given GraphQL type.
21
18
  *
@@ -52,7 +49,7 @@ export declare const hasOptionParentType: (options: PrintLinkOptions) => boolean
52
49
  * @param groups - The group options
53
50
  * @returns The folder name for the API group
54
51
  */
55
- export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<ApiGroupOverrideType | boolean>) => string;
52
+ export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<boolean | ApiGroupOverrideType>) => string;
56
53
  /**
57
54
  * Gets the folder name for deprecated types based on the GraphQL type and deprecation option.
58
55
  *
@@ -103,4 +100,5 @@ export declare const printLink: (type: unknown, options: PrintLinkOptions) => st
103
100
  * @param options - Configuration options for link generation
104
101
  * @returns The formatted parent link as a string or MDX string
105
102
  */
106
- export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => MDXString | string;
103
+ export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => string | MDXString;
104
+ //# sourceMappingURL=link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAGpB,SAAS,EACT,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAEhB,oBAAoB,EAGpB,QAAQ,EACR,UAAU,EACX,MAAM,yBAAyB,CAAC;AA2BjC,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,oBAAoB,CAG5C,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,oIA+BjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,sCAoB7B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,uEAuBjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,wCAEnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,wCAO/B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,2EASjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,gEAKnC,CAAC;AASF;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,oGAsElB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,4FAc3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,iDAqB/B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,sDAuBrB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,kEAc3B,CAAC"}
package/dist/link.js CHANGED
@@ -19,10 +19,7 @@ exports.API_GROUPS = {
19
19
  * Checks if a type has printable directives based on the provided options.
20
20
  *
21
21
  * @param type - The GraphQL type to check
22
- * @param options - Configuration options for directive printing
23
- * @param options.deprecated - How to handle deprecated types
24
- * @param options.onlyDocDirectives - Only print types with specific directives
25
- * @param options.skipDocDirectives - Skip types with specific directives
22
+ * @param options - Configuration options for directive printing (`deprecated`, `onlyDocDirectives`, `skipDocDirectives`)
26
23
  * @returns `true` if the type should be printed, `false` otherwise
27
24
  */
28
25
  const hasPrintableDirective = (type, options) => {
@@ -118,7 +115,7 @@ const hasOptionParentType = (options) => {
118
115
  return ("parentTypePrefix" in options &&
119
116
  options.parentTypePrefix === true &&
120
117
  "parentType" in options &&
121
- typeof options.parentType !== "undefined");
118
+ options.parentType !== undefined);
122
119
  };
123
120
  exports.hasOptionParentType = hasOptionParentType;
124
121
  /**
@@ -148,7 +145,7 @@ const getLinkDeprecatedFolder = (type, option) => {
148
145
  };
149
146
  exports.getLinkDeprecatedFolder = getLinkDeprecatedFolder;
150
147
  const isHierarchy = (options, hierarchy) => {
151
- return (options?.hierarchy?.[hierarchy] && true);
148
+ return options?.hierarchy?.[hierarchy] !== undefined;
152
149
  };
153
150
  /**
154
151
  * Converts a GraphQL type to a link object.
@@ -164,8 +161,7 @@ const toLink = (type, name, operation, options) => {
164
161
  text: name,
165
162
  url: "#",
166
163
  };
167
- if (typeof type !== "object" ||
168
- (typeof options !== "undefined" && !(0, exports.hasPrintableDirective)(type, options))) {
164
+ if (typeof type !== "object" || !(0, exports.hasPrintableDirective)(type, options)) {
169
165
  return fallback;
170
166
  }
171
167
  const graphQLNamedType = (0, graphql_1.getNamedType)(type);
@@ -192,7 +188,12 @@ const toLink = (type, name, operation, options) => {
192
188
  : "";
193
189
  }
194
190
  const text = graphQLNamedType.name || graphQLNamedType.toString();
195
- const url = utils_1.pathUrl.join(options.basePath, deprecatedFolder, apiGroupFolder, groupFolder, category, `${(0, utils_1.slugify)(text)}`);
191
+ const formatFolder = (folder) => {
192
+ return folder && options.formatCategoryFolderName
193
+ ? options.formatCategoryFolderName(folder)
194
+ : folder;
195
+ };
196
+ const url = utils_1.pathUrl.join(options.basePath, formatFolder(deprecatedFolder), formatFolder(groupFolder), formatFolder(apiGroupFolder), formatFolder(category), `${(0, utils_1.slugify)(text)}`);
196
197
  const link = {
197
198
  text,
198
199
  url,
@@ -232,9 +233,7 @@ const printLinkAttributes = (type, text = "") => {
232
233
  if (typeof type !== "object" || type === null) {
233
234
  return text ?? "";
234
235
  }
235
- if (!(0, graphql_1.isLeafType)(type) &&
236
- "ofType" in type &&
237
- typeof type.ofType !== "undefined") {
236
+ if (!(0, graphql_1.isLeafType)(type) && "ofType" in type && type.ofType !== undefined) {
238
237
  text = (0, exports.printLinkAttributes)(type.ofType, text);
239
238
  }
240
239
  if ((0, graphql_1.isListType)(type)) {
@@ -258,7 +257,7 @@ const printLink = (type, options) => {
258
257
  return "";
259
258
  }
260
259
  const link = (0, exports.toLink)(type, (0, graphql_1.getTypeName)(type, (0, utils_1.toString)(type)), undefined, options);
261
- if (typeof options !== "undefined" && !(0, exports.hasOptionWithAttributes)(options)) {
260
+ if (!(0, exports.hasOptionWithAttributes)(options)) {
262
261
  const textWithAttribute = options.formatMDXNameEntity(link.text, options.parentType);
263
262
  return `[${textWithAttribute}](${link.url})`;
264
263
  }
@@ -14,5 +14,6 @@
14
14
  import type { MDXSupportType } from "@graphql-markdown/types";
15
15
  export declare const mdxDeclaration = "";
16
16
  declare const defaultModule: MDXSupportType;
17
- export declare const mdxModule: (mdxPackage?: Record<string, unknown>) => Promise<Readonly<MDXSupportType>>;
17
+ export declare const mdxModule: (mdxPackage?: Record<string, unknown> | undefined) => Promise<Readonly<MDXSupportType>>;
18
18
  export default defaultModule;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdx/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAOV,cAAc,EAGf,MAAM,yBAAyB,CAAC;AA0KjC,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,QAAA,MAAM,aAAa,gBASA,CAAC;AAEpB,eAAO,MAAM,SAAS,yFAoBrB,CAAC;AAEF,eAAe,aAAa,CAAC"}
package/dist/mdx/index.js CHANGED
@@ -131,8 +131,8 @@ const formatMDXNameEntity = (name, parentType) => {
131
131
  * Currently, this function returns the link as is without modification.
132
132
  * This may serve as a placeholder for future formatting logic.
133
133
  *
134
- * @param link - The TypeLink object to format
135
- * @returns The formatted TypeLink object
134
+ * @param link - The `TypeLink` object to format
135
+ * @returns The formatted `TypeLink` object
136
136
  */
137
137
  const formatMDXLink = (link) => {
138
138
  return link;
package/dist/printer.d.ts CHANGED
@@ -29,27 +29,22 @@ import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDX
29
29
  export declare class Printer implements IPrinter {
30
30
  /**
31
31
  * Global printer configuration options
32
- * @static
33
32
  */
34
33
  static options: Readonly<Maybe<PrintTypeOptions>>;
35
34
  /**
36
35
  * Prints type descriptions
37
- * @static
38
36
  */
39
- static readonly printDescription: (type: unknown, options: PrintTypeOptions, noText?: string) => MDXString | string;
37
+ static readonly printDescription: (type: unknown, options: PrintTypeOptions, noText?: string | undefined) => string | MDXString;
40
38
  /**
41
39
  * Prints custom directives
42
- * @static
43
40
  */
44
41
  static readonly printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
45
42
  /**
46
43
  * Prints custom tags
47
- * @static
48
44
  */
49
- static readonly printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
45
+ static readonly printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
50
46
  /**
51
47
  * MDX module configuration
52
- * @static
53
48
  */
54
49
  static printMDXModule: Readonly<MDXSupportType>;
55
50
  /**
@@ -61,7 +56,7 @@ export declare class Printer implements IPrinter {
61
56
  * @param options - Configuration options for the printer
62
57
  * @param mdxParser - Optional MDX parser module for MDX output support
63
58
  */
64
- static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, }?: {
59
+ static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives }?: {
65
60
  customDirectives?: CustomDirectiveMap;
66
61
  deprecated?: TypeDeprecatedOption;
67
62
  groups?: SchemaEntitiesGroupMap;
@@ -102,9 +97,9 @@ export declare class Printer implements IPrinter {
102
97
  * @param type - GraphQL type to print metadata for
103
98
  * @param options - Printer configuration options
104
99
  * @returns Formatted metadata string as MDX or plain string
105
- * @throws {Error} When type is not supported
100
+ * @throws When type is not supported
106
101
  */
107
- static readonly printTypeMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
102
+ static readonly printTypeMetadata: (type: unknown, options: PrintTypeOptions) => string | MDXString;
108
103
  /**
109
104
  * Prints related type information
110
105
  *
@@ -112,7 +107,7 @@ export declare class Printer implements IPrinter {
112
107
  * @param options - Printer configuration options
113
108
  * @returns Formatted relations section as MDX or plain string
114
109
  */
115
- static readonly printRelations: (type: unknown, options: PrintTypeOptions) => MDXString | string;
110
+ static readonly printRelations: (type: unknown, options: PrintTypeOptions) => string | MDXString;
116
111
  /**
117
112
  * Prints HTML meta tags for the documentation
118
113
  *
@@ -120,7 +115,7 @@ export declare class Printer implements IPrinter {
120
115
  * @param options - Printer configuration options containing metatags
121
116
  * @returns Formatted HTML meta tags string
122
117
  */
123
- static readonly printMetaTags: (_type: unknown, { metatags }: PrintTypeOptions) => MDXString | string;
118
+ static readonly printMetaTags: (_type: unknown, { metatags }: PrintTypeOptions) => string | MDXString;
124
119
  /**
125
120
  * Main method to print complete documentation for a GraphQL type
126
121
  *
@@ -150,3 +145,4 @@ export declare class Printer implements IPrinter {
150
145
  */
151
146
  static readonly printType: (name: Maybe<string>, type: unknown, options?: Maybe<Partial<PrintTypeOptions>>) => Maybe<MDXString>;
152
147
  }
148
+ //# sourceMappingURL=printer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAEhB,aAAa,EACb,QAAQ,EACR,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AA8DjC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IACtC;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAElD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,gBAAgB,gGAAoB;IAEpD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,qBAAqB,uDAAyB;IAE9D;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe,mEAAmB;IAElD;;OAEG;IACH,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEhD;;;;;;;;OAQG;IACH,OAAa,IAAI,CACf,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,EAC5B,OAAO,GAAE,KAAK,CAAC,MAAM,CAAY,EACjC,QAAQ,GAAE,KAAK,CAAC,MAAM,CAAO,EAC7B,EACE,gBAAgB,EAChB,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAClB,GAAE;QACD,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;QACtC,UAAU,CAAC,EAAE,oBAAoB,CAAC;QAClC,MAAM,CAAC,EAAE,sBAAsB,CAAC;QAChC,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;QACpC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;QACvC,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;QACjD,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;KACjB,EACxB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC,CAmCf;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,WAAW,mEAYzB;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,uDAwCvB;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY,uDAmB1B;IAEF;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,iBAAiB,mEA2B/B;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,mEAQ5B;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAa,yEAiB3B;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,uGA+CvB;CACH"}
package/dist/printer.js CHANGED
@@ -22,6 +22,14 @@ const strings_1 = require("./const/strings");
22
22
  const mdx_1 = require("./mdx");
23
23
  const options_1 = require("./const/options");
24
24
  const example_1 = require("./example");
25
+ /**
26
+ * Default initialization options for the Printer class.
27
+ * @internal
28
+ */
29
+ const DEFAULT_INIT_OPTIONS = {
30
+ customDirectives: undefined,
31
+ groups: undefined,
32
+ };
25
33
  /**
26
34
  * The Printer class implements the core functionality for generating Markdown documentation
27
35
  * from GraphQL schema types.
@@ -43,27 +51,22 @@ const example_1 = require("./example");
43
51
  class Printer {
44
52
  /**
45
53
  * Global printer configuration options
46
- * @static
47
54
  */
48
55
  static options;
49
56
  /**
50
57
  * Prints type descriptions
51
- * @static
52
58
  */
53
59
  static printDescription = common_1.printDescription;
54
60
  /**
55
61
  * Prints custom directives
56
- * @static
57
62
  */
58
63
  static printCustomDirectives = directive_1.printCustomDirectives;
59
64
  /**
60
65
  * Prints custom tags
61
- * @static
62
66
  */
63
67
  static printCustomTags = directive_1.printCustomTags;
64
68
  /**
65
69
  * MDX module configuration
66
- * @static
67
70
  */
68
71
  static printMDXModule;
69
72
  /**
@@ -75,11 +78,8 @@ class Printer {
75
78
  * @param options - Configuration options for the printer
76
79
  * @param mdxParser - Optional MDX parser module for MDX output support
77
80
  */
78
- static async init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, } = {
79
- customDirectives: undefined,
80
- groups: undefined,
81
- }, mdxParser) {
82
- if (typeof Printer.options !== "undefined") {
81
+ static async init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, } = DEFAULT_INIT_OPTIONS, mdxParser) {
82
+ if (Printer.options !== undefined) {
83
83
  return;
84
84
  }
85
85
  Printer.options = {
@@ -128,38 +128,37 @@ class Printer {
128
128
  * @returns Formatted code block string with type definition
129
129
  */
130
130
  static printCode = (type, options) => {
131
- let code = "";
132
- if (typeof options.codeSection === "undefined" ||
133
- options.codeSection !== true) {
134
- return code;
131
+ if (options.codeSection === undefined || options.codeSection !== true) {
132
+ return "";
135
133
  }
134
+ let code = "";
136
135
  switch (true) {
137
136
  case (0, graphql_1.isOperation)(type):
138
- code += (0, graphql_2.printCodeOperation)(type, options);
137
+ code = (0, graphql_2.printCodeOperation)(type, options);
139
138
  break;
140
139
  case (0, graphql_1.isEnumType)(type):
141
- code += (0, graphql_2.printCodeEnum)(type, options);
140
+ code = (0, graphql_2.printCodeEnum)(type, options);
142
141
  break;
143
142
  case (0, graphql_1.isUnionType)(type):
144
- code += (0, graphql_2.printCodeUnion)(type, options);
143
+ code = (0, graphql_2.printCodeUnion)(type, options);
145
144
  break;
146
145
  case (0, graphql_1.isInterfaceType)(type):
147
- code += (0, graphql_2.printCodeInterface)(type, options);
146
+ code = (0, graphql_2.printCodeInterface)(type, options);
148
147
  break;
149
148
  case (0, graphql_1.isObjectType)(type):
150
- code += (0, graphql_2.printCodeObject)(type, options);
149
+ code = (0, graphql_2.printCodeObject)(type, options);
151
150
  break;
152
151
  case (0, graphql_1.isInputType)(type):
153
- code += (0, graphql_2.printCodeInput)(type, options);
152
+ code = (0, graphql_2.printCodeInput)(type, options);
154
153
  break;
155
154
  case (0, graphql_1.isScalarType)(type):
156
- code += (0, graphql_2.printCodeScalar)(type, options);
155
+ code = (0, graphql_2.printCodeScalar)(type, options);
157
156
  break;
158
157
  case (0, graphql_1.isDirectiveType)(type):
159
- code += (0, graphql_2.printCodeDirective)(type, options);
158
+ code = (0, graphql_2.printCodeDirective)(type, options);
160
159
  break;
161
160
  default:
162
- code += `"${(0, graphql_1.getTypeName)(type)}" not supported`;
161
+ code = `"${(0, graphql_1.getTypeName)(type)}" not supported`;
163
162
  }
164
163
  return strings_1.MARKDOWN_SOC + code.trim() + strings_1.MARKDOWN_EOC;
165
164
  };
@@ -171,7 +170,7 @@ class Printer {
171
170
  * @returns Formatted example section string or empty string if no example
172
171
  */
173
172
  static printExample = (type, options) => {
174
- if (typeof options.exampleSection === "undefined" ||
173
+ if (options.exampleSection === undefined ||
175
174
  options.exampleSection === null ||
176
175
  options.exampleSection === false) {
177
176
  return "";
@@ -188,7 +187,7 @@ class Printer {
188
187
  * @param type - GraphQL type to print metadata for
189
188
  * @param options - Printer configuration options
190
189
  * @returns Formatted metadata string as MDX or plain string
191
- * @throws {Error} When type is not supported
190
+ * @throws When type is not supported
192
191
  */
193
192
  static printTypeMetadata = (type, options) => {
194
193
  switch (true) {
@@ -5,9 +5,9 @@
5
5
  */
6
6
  import type { IGetRelation, MDXString, Maybe, PrintTypeOptions, TypeLocale } from "@graphql-markdown/types";
7
7
  /**
8
- * Converts a string representation of a root type to its corresponding TypeLocale
9
- * @param text - The string to convert to a TypeLocale
10
- * @returns The matching TypeLocale if found, undefined otherwise
8
+ * Converts a string representation of a root type to its corresponding `TypeLocale`
9
+ * @param text - The string to convert to a `TypeLocale`
10
+ * @returns The matching `TypeLocale` if found, `undefined` otherwise
11
11
  * @example
12
12
  * ```ts
13
13
  * const locale = getRootTypeLocaleFromString('Query');
@@ -21,14 +21,14 @@ export declare const getRootTypeLocaleFromString: (text: string) => Maybe<TypeLo
21
21
  * @param section - The section title for the relation
22
22
  * @param getRelation - Function to retrieve relations of type T
23
23
  * @param options - Printing options for type formatting
24
- * @returns {MDXString | string} Formatted MDX string containing the relations or empty string if no relations found
25
- * @throws {Error} If the schema is not provided in options
24
+ * @returns Formatted MDX string containing the relations or empty string if no relations found
25
+ * @throws If the schema is not provided in options
26
26
  * @example
27
27
  * ```ts
28
28
  * const mdx = printRelationOf(type, "Member Of", getRelationOfField, options);
29
29
  * ```
30
30
  */
31
- export declare const printRelationOf: <T>(type: unknown, section: unknown, getRelation: Maybe<IGetRelation<T>>, options: PrintTypeOptions) => MDXString | string;
31
+ export declare const printRelationOf: <T>(type: unknown, section: unknown, getRelation: Maybe<IGetRelation<T>>, options: PrintTypeOptions) => string | MDXString;
32
32
  /**
33
33
  * Prints all relations (return types, member fields, and implementations) for a given type
34
34
  * @param type - The GraphQL type to get all relations for
@@ -40,4 +40,5 @@ export declare const printRelationOf: <T>(type: unknown, section: unknown, getRe
40
40
  * const relations = printRelations(myType, { schema, formatMDXBullet: () => "* " });
41
41
  * ```
42
42
  */
43
- export declare const printRelations: (type: unknown, options: PrintTypeOptions) => MDXString | string;
43
+ export declare const printRelations: (type: unknown, options: PrintTypeOptions) => string | MDXString;
44
+ //# sourceMappingURL=relation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation.d.ts","sourceRoot":"","sources":["../src/relation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,KAAK,EACL,gBAAgB,EAGhB,UAAU,EACX,MAAM,yBAAyB,CAAC;AAgBjC;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,qCASvC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,wHAwDhC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,kEAmB1B,CAAC"}
package/dist/relation.js CHANGED
@@ -12,9 +12,9 @@ const badge_1 = require("./badge");
12
12
  const strings_1 = require("./const/strings");
13
13
  const options_1 = require("./const/options");
14
14
  /**
15
- * Converts a string representation of a root type to its corresponding TypeLocale
16
- * @param text - The string to convert to a TypeLocale
17
- * @returns The matching TypeLocale if found, undefined otherwise
15
+ * Converts a string representation of a root type to its corresponding `TypeLocale`
16
+ * @param text - The string to convert to a `TypeLocale`
17
+ * @returns The matching `TypeLocale` if found, `undefined` otherwise
18
18
  * @example
19
19
  * ```ts
20
20
  * const locale = getRootTypeLocaleFromString('Query');
@@ -36,8 +36,8 @@ exports.getRootTypeLocaleFromString = getRootTypeLocaleFromString;
36
36
  * @param section - The section title for the relation
37
37
  * @param getRelation - Function to retrieve relations of type T
38
38
  * @param options - Printing options for type formatting
39
- * @returns {MDXString | string} Formatted MDX string containing the relations or empty string if no relations found
40
- * @throws {Error} If the schema is not provided in options
39
+ * @returns Formatted MDX string containing the relations or empty string if no relations found
40
+ * @throws If the schema is not provided in options
41
41
  * @example
42
42
  * ```ts
43
43
  * const mdx = printRelationOf(type, "Member Of", getRelationOfField, options);
@@ -55,7 +55,7 @@ const printRelationOf = (type, section, getRelation, options) => {
55
55
  if (!relations) {
56
56
  return "";
57
57
  }
58
- let data = [];
58
+ const data = [];
59
59
  for (const [relation, types] of Object.entries(relations)) {
60
60
  if (types.length === 0) {
61
61
  continue;
@@ -65,7 +65,7 @@ const printRelationOf = (type, section, getRelation, options) => {
65
65
  text: category,
66
66
  classname: badge_1.CSS_BADGE_CLASSNAME.RELATION,
67
67
  }, options);
68
- data = data.concat(types.map((t) => {
68
+ data.push(...types.map((t) => {
69
69
  const link = (0, link_1.getRelationLink)(category, t, options);
70
70
  return link ? `[\`${link.text}\`](${link.url}) ${badge}` : "";
71
71
  }));
@@ -73,8 +73,8 @@ const printRelationOf = (type, section, getRelation, options) => {
73
73
  if (data.length === 0) {
74
74
  return "";
75
75
  }
76
- const content = [...data]
77
- .sort((a, b) => {
76
+ const content = data
77
+ .toSorted((a, b) => {
78
78
  return a.localeCompare(b);
79
79
  })
80
80
  .join(options.formatMDXBullet());