@graphql-markdown/printer-legacy 1.15.0 → 1.16.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.
Files changed (58) hide show
  1. package/dist/badge.d.ts +10 -3
  2. package/dist/badge.d.ts.map +1 -1
  3. package/dist/badge.js +21 -9
  4. package/dist/code.d.ts +1 -1
  5. package/dist/code.d.ts.map +1 -1
  6. package/dist/common.d.ts +5 -13
  7. package/dist/common.d.ts.map +1 -1
  8. package/dist/common.js +11 -6
  9. package/dist/const/options.d.ts +4 -8
  10. package/dist/const/options.d.ts.map +1 -1
  11. package/dist/const/options.js +17 -13
  12. package/dist/const/strings.d.ts +1 -3
  13. package/dist/const/strings.d.ts.map +1 -1
  14. package/dist/const/strings.js +4 -6
  15. package/dist/directive.d.ts +1 -1
  16. package/dist/directive.d.ts.map +1 -1
  17. package/dist/directive.js +5 -8
  18. package/dist/example.d.ts.map +1 -1
  19. package/dist/example.js +2 -0
  20. package/dist/format-helpers.d.ts.map +1 -1
  21. package/dist/formatter.d.ts.map +1 -1
  22. package/dist/formatter.js +9 -30
  23. package/dist/frontmatter.d.ts.map +1 -1
  24. package/dist/graphql/directive.d.ts +1 -1
  25. package/dist/graphql/directive.d.ts.map +1 -1
  26. package/dist/graphql/enum.d.ts +1 -1
  27. package/dist/graphql/enum.d.ts.map +1 -1
  28. package/dist/graphql/input.d.ts.map +1 -1
  29. package/dist/graphql/input.js +1 -1
  30. package/dist/graphql/interface.d.ts.map +1 -1
  31. package/dist/graphql/interface.js +1 -1
  32. package/dist/graphql/object.d.ts.map +1 -1
  33. package/dist/graphql/operation.d.ts +1 -8
  34. package/dist/graphql/operation.d.ts.map +1 -1
  35. package/dist/graphql/operation.js +2 -3
  36. package/dist/graphql/scalar.d.ts +1 -1
  37. package/dist/graphql/scalar.d.ts.map +1 -1
  38. package/dist/graphql/scalar.js +2 -0
  39. package/dist/graphql/union.d.ts +1 -1
  40. package/dist/graphql/union.d.ts.map +1 -1
  41. package/dist/group.d.ts +2 -2
  42. package/dist/group.d.ts.map +1 -1
  43. package/dist/index.js +2 -2
  44. package/dist/link.d.ts +5 -13
  45. package/dist/link.d.ts.map +1 -1
  46. package/dist/link.js +14 -3
  47. package/dist/mdx/index.d.ts +1 -1
  48. package/dist/mdx/index.d.ts.map +1 -1
  49. package/dist/printer.d.ts +10 -35
  50. package/dist/printer.d.ts.map +1 -1
  51. package/dist/printer.js +29 -64
  52. package/dist/relation.d.ts +2 -2
  53. package/dist/relation.d.ts.map +1 -1
  54. package/dist/relation.js +4 -0
  55. package/dist/section.d.ts +2 -2
  56. package/dist/section.d.ts.map +1 -1
  57. package/dist/section.js +4 -0
  58. package/package.json +7 -6
@@ -5,7 +5,7 @@
5
5
  * @module
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.printCodeOperation = exports.printOperationMetadata = exports.printOperationType = void 0;
8
+ exports.printCodeOperation = exports.printOperationMetadata = void 0;
9
9
  const graphql_1 = require("@graphql-markdown/graphql");
10
10
  const strings_1 = require("../const/strings");
11
11
  const code_1 = require("../code");
@@ -26,7 +26,6 @@ const printOperationType = (type, options) => {
26
26
  parentTypePrefix: false,
27
27
  });
28
28
  };
29
- exports.printOperationType = printOperationType;
30
29
  /**
31
30
  * Prints the operation metadata including arguments and type information.
32
31
  * @param type - The operation type to print metadata for
@@ -37,7 +36,7 @@ const printOperationMetadata = (type, options) => {
37
36
  if (!(0, graphql_1.isOperation)(type)) {
38
37
  return undefined;
39
38
  }
40
- const response = (0, exports.printOperationType)(type, options);
39
+ const response = printOperationType(type, options);
41
40
  const metadata = (0, section_1.printMetadataSection)(type, type.args, "Arguments", options);
42
41
  return [metadata, response].filter(Boolean);
43
42
  };
@@ -24,5 +24,5 @@ export declare const printScalarMetadata: (type: unknown, options: PrintTypeOpti
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 | undefined) => string;
27
+ export declare const printCodeScalar: (type: unknown, options?: PrintTypeOptions) => string;
28
28
  //# sourceMappingURL=scalar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/graphql/scalar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,KAAK,EACN,MAAM,yBAAyB,CAAC;AAIjC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,kEAmB9B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,kEAK/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,mEAK3B,CAAC"}
1
+ {"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/graphql/scalar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,KAAK,EACN,MAAM,yBAAyB,CAAC;AAIjC;;;;;GAKG;AAGH,eAAO,MAAM,kBAAkB,SACvB,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,WAAW,CAgBnB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,SACxB,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,WAAW,CAEnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,SACpB,OAAO,YACH,gBAAgB,KACzB,MAEF,CAAC"}
@@ -8,6 +8,8 @@ const graphql_1 = require("@graphql-markdown/graphql");
8
8
  * @param options - Options for printing type information
9
9
  * @returns A specification PageSection, or undefined when no URL exists
10
10
  */
11
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
12
+ // fallow-ignore-next-line unused-export
11
13
  const printSpecification = (type, options) => {
12
14
  if (typeof type !== "object" ||
13
15
  type === null ||
@@ -16,5 +16,5 @@ export declare const printUnionMetadata: (type: unknown, options: PrintTypeOptio
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 | undefined) => string;
19
+ export declare const printCodeUnion: (type: unknown, options?: PrintTypeOptions) => string;
20
20
  //# sourceMappingURL=union.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../src/graphql/union.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAEhB,WAAW,EACX,KAAK,EACN,MAAM,yBAAyB,CAAC;AAMjC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,kEAY9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,mEAiB1B,CAAC"}
1
+ {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../src/graphql/union.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAEhB,WAAW,EACX,KAAK,EACN,MAAM,yBAAyB,CAAC;AAMjC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,SACvB,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,WAAW,CASnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,SACnB,OAAO,YACH,gBAAgB,KACzB,MAcF,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 { SchemaEntity, Maybe } from "@graphql-markdown/types";
5
+ import type { SchemaEntitiesGroupMap, 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,5 +11,5 @@ import type { SchemaEntity, Maybe } from "@graphql-markdown/types";
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<Partial<Record<SchemaEntity, Record<string, Maybe<string>>>>>, typeCategory: Maybe<SchemaEntity>) => string;
14
+ export declare const getGroup: (type: unknown, groups: Maybe<SchemaEntitiesGroupMap>, typeCategory: Maybe<SchemaEntity>) => string;
15
15
  //# sourceMappingURL=group.d.ts.map
@@ -1 +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,2IA6BpB,CAAC"}
1
+ {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EAEZ,KAAK,EACN,MAAM,yBAAyB,CAAC;AAMjC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,SACb,OAAO,UACL,KAAK,CAAC,sBAAsB,CAAC,gBACvB,KAAK,CAAC,YAAY,CAAC,KAChC,MAyBF,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BeforeComposePageTypeEvent = exports.PrintTypeEvent = exports.PrintCodeEvent = exports.Printer = void 0;
4
- const printer_1 = require("./printer");
4
+ var printer_1 = require("./printer");
5
5
  Object.defineProperty(exports, "Printer", { enumerable: true, get: function () { return printer_1.Printer; } });
6
- const events_1 = require("./events");
6
+ var events_1 = require("./events");
7
7
  Object.defineProperty(exports, "PrintCodeEvent", { enumerable: true, get: function () { return events_1.PrintCodeEvent; } });
8
8
  Object.defineProperty(exports, "PrintTypeEvent", { enumerable: true, get: function () { return events_1.PrintTypeEvent; } });
9
9
  Object.defineProperty(exports, "BeforeComposePageTypeEvent", { enumerable: true, get: function () { return events_1.BeforeComposePageTypeEvent; } });
package/dist/link.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Provides utilities for creating, formatting, and managing links to GraphQL types and operations.
4
4
  * @packageDocumentation
5
5
  */
6
- import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, PrintTypeOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
6
+ import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, PrintTypeOptions, TypeLink, TypeLocale } from "@graphql-markdown/types";
7
7
  export declare const API_GROUPS: Required<ApiGroupOverrideType>;
8
8
  /**
9
9
  * Checks if a type has printable directives based on the provided options.
@@ -12,7 +12,7 @@ export declare const API_GROUPS: Required<ApiGroupOverrideType>;
12
12
  * @param options - Configuration options for directive printing (`deprecated`, `onlyDocDirectives`, `skipDocDirectives`)
13
13
  * @returns `true` if the type should be printed, `false` otherwise
14
14
  */
15
- export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives"> | undefined) => boolean;
15
+ export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
16
16
  /**
17
17
  * Gets the locale category for a given GraphQL type.
18
18
  *
@@ -49,15 +49,7 @@ export declare const hasOptionParentType: (options: PrintLinkOptions) => boolean
49
49
  * @param groups - The group options
50
50
  * @returns The folder name for the API group
51
51
  */
52
- export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<boolean | ApiGroupOverrideType>) => string;
53
- /**
54
- * Gets the folder name for deprecated types based on the GraphQL type and deprecation option.
55
- *
56
- * @param type - The GraphQL type to get the folder name for
57
- * @param option - The deprecation option
58
- * @returns The folder name for deprecated types
59
- */
60
- export declare const getLinkDeprecatedFolder: (type: unknown, option: Maybe<TypeDeprecatedOption>) => string;
52
+ export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<ApiGroupOverrideType | boolean>) => string;
61
53
  /**
62
54
  * Converts a GraphQL type to a link object.
63
55
  *
@@ -92,7 +84,7 @@ export declare const printLinkAttributes: (type: unknown, text?: Maybe<string>)
92
84
  * @param options - Configuration options for link generation
93
85
  * @returns The formatted link as a string
94
86
  */
95
- export declare const printLink: <T>(arg: T | Maybe<TypeLink>, options: PrintLinkOptions) => string;
87
+ export declare const printLink: <T>(arg: Maybe<TypeLink> | T, options: PrintLinkOptions) => string;
96
88
  /**
97
89
  * Prints a parent link for a GraphQL type based on the provided options.
98
90
  *
@@ -100,5 +92,5 @@ export declare const printLink: <T>(arg: T | Maybe<TypeLink>, options: PrintLink
100
92
  * @param options - Configuration options for link generation
101
93
  * @returns The formatted parent link as a string or MDX string
102
94
  */
103
- export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => string | MDXString;
95
+ export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => MDXString | string;
104
96
  //# sourceMappingURL=link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAEpB,SAAS,EACT,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAEhB,oBAAoB,EAGpB,QAAQ,EACR,UAAU,EACX,MAAM,yBAAyB,CAAC;AAgCjC,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;AAC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,CAAC,KAC7C,MAMF,CAAC;AAuBF;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,SACX,OAAO,QACP,MAAM,aACD,KAAK,CAAC,UAAU,CAAC,WACnB,gBAAgB,KACxB,QAkFF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,aAChB,KAAK,CAAC,UAAU,CAAC,QACrB,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,QAAQ,CAUhB,CAAC;AAEF;;;;;;GAMG;AAGH,eAAO,MAAM,mBAAmB,SACxB,OAAO,SACP,KAAK,CAAC,MAAM,CAAC,KAClB,MAkBF,CAAC;AAoBF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,OACpB,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,WACf,gBAAgB,KACxB,MAgCF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,SACpB,OAAO,WACJ,gBAAgB,KACxB,SAAS,GAAG,MAWd,CAAC"}
package/dist/link.js CHANGED
@@ -5,12 +5,14 @@
5
5
  * @packageDocumentation
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- 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;
8
+ exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.getLinkApiGroupFolder = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategoryFolder = exports.getCategoryLocale = exports.hasPrintableDirective = exports.API_GROUPS = void 0;
9
9
  const graphql_1 = require("@graphql-markdown/graphql");
10
10
  const utils_1 = require("@graphql-markdown/utils");
11
11
  const group_1 = require("./group");
12
12
  const strings_1 = require("./const/strings");
13
13
  const options_1 = require("./const/options");
14
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
15
+ // fallow-ignore-next-line unused-export
14
16
  exports.API_GROUPS = {
15
17
  operations: "operations",
16
18
  types: "types",
@@ -76,6 +78,8 @@ exports.getCategoryLocale = getCategoryLocale;
76
78
  * @param operationLocale - The locale of the operation
77
79
  * @returns The folder name for the link category, or `undefined` if not found
78
80
  */
81
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
82
+ // fallow-ignore-next-line unused-export
79
83
  const getLinkCategoryFolder = (type, operationLocale) => {
80
84
  const categoryLocale = (0, exports.getCategoryLocale)(type);
81
85
  if (!categoryLocale) {
@@ -101,6 +105,8 @@ exports.getLinkCategoryFolder = getLinkCategoryFolder;
101
105
  * @param options - The options to check
102
106
  * @returns `true` if the options include `withAttributes`, `false` otherwise
103
107
  */
108
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
109
+ // fallow-ignore-next-line unused-export
104
110
  const hasOptionWithAttributes = (options) => {
105
111
  return "withAttributes" in options && options.withAttributes === true;
106
112
  };
@@ -111,6 +117,8 @@ exports.hasOptionWithAttributes = hasOptionWithAttributes;
111
117
  * @param options - The options to check
112
118
  * @returns `true` if the options include `parentTypePrefix`, `false` otherwise
113
119
  */
120
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
121
+ // fallow-ignore-next-line unused-export
114
122
  const hasOptionParentType = (options) => {
115
123
  return ("parentTypePrefix" in options &&
116
124
  options.parentTypePrefix === true &&
@@ -125,6 +133,8 @@ exports.hasOptionParentType = hasOptionParentType;
125
133
  * @param groups - The group options
126
134
  * @returns The folder name for the API group
127
135
  */
136
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
137
+ // fallow-ignore-next-line unused-export
128
138
  const getLinkApiGroupFolder = (type, groups) => {
129
139
  let folderNames = exports.API_GROUPS;
130
140
  if (groups && typeof groups === "object") {
@@ -143,7 +153,6 @@ exports.getLinkApiGroupFolder = getLinkApiGroupFolder;
143
153
  const getLinkDeprecatedFolder = (type, option) => {
144
154
  return option === "group" && (0, graphql_1.isDeprecated)(type) ? strings_1.DEPRECATED : "";
145
155
  };
146
- exports.getLinkDeprecatedFolder = getLinkDeprecatedFolder;
147
156
  const isHierarchy = (options, hierarchy) => {
148
157
  return options?.hierarchy?.[hierarchy] !== undefined;
149
158
  };
@@ -181,7 +190,7 @@ const toLink = (type, name, operation, options) => {
181
190
  return fallback;
182
191
  }
183
192
  deprecatedFolder = options.deprecated
184
- ? (0, exports.getLinkDeprecatedFolder)(type, options.deprecated)
193
+ ? getLinkDeprecatedFolder(type, options.deprecated)
185
194
  : "";
186
195
  groupFolder = options.groups
187
196
  ? (0, group_1.getGroup)(type, options.groups, category)
@@ -241,6 +250,8 @@ exports.getRelationLink = getRelationLink;
241
250
  * @param text - The text to append attributes to
242
251
  * @returns The text with appended attributes
243
252
  */
253
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
254
+ // fallow-ignore-next-line unused-export
244
255
  const printLinkAttributes = (type, text = "") => {
245
256
  if (typeof type !== "object" || type === null) {
246
257
  return text ?? "";
@@ -14,6 +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> | undefined) => Promise<Readonly<MDXSupportType>>;
17
+ export declare const mdxModule: (mdxPackage?: Record<string, unknown>) => Promise<Readonly<MDXSupportType>>;
18
18
  export default defaultModule;
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,EASd,cAAc,CAAC;AAEpB,eAAO,MAAM,SAAS,gBACP,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAkBlC,CAAC;eAEa,aAAa"}
package/dist/printer.d.ts CHANGED
@@ -7,10 +7,9 @@
7
7
  * @module printer
8
8
  * @packageDocumentation
9
9
  */
10
- import type { CustomDirectiveMap, DeprecatedPrintTypeOptions, Formatter, GraphQLDirective, GraphQLSchema, IPrinter, Maybe, MDXString, MetaInfo, PageSection, PrinterConfigPrintTypeOptions, PrinterEventEmitter, PrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
11
- type InitPrintTypeOptions = DeprecatedPrintTypeOptions & Omit<PrinterConfigPrintTypeOptions, "exampleSection"> & {
12
- exampleSection?: DeprecatedPrintTypeOptions["exampleSection"] | PrinterConfigPrintTypeOptions["exampleSection"];
13
- };
10
+ import type { Formatter, GraphQLSchema, IPrinter, Maybe, MDXString, PageSection, PrinterEventEmitter, PrinterInitOptions, PrintTypeOptions } from "@graphql-markdown/types";
11
+ import { printDescription } from "./common";
12
+ import { printCustomDirectives, printCustomTags } from "./directive";
14
13
  /**
15
14
  * The Printer class implements the core functionality for generating Markdown documentation
16
15
  * from GraphQL schema types.
@@ -33,29 +32,22 @@ export declare class Printer implements IPrinter {
33
32
  /**
34
33
  * Prints type descriptions
35
34
  */
36
- static readonly printDescription: (type: unknown, options: PrintTypeOptions, noText?: string | undefined) => string | MDXString;
35
+ static readonly printDescription: typeof printDescription;
37
36
  /**
38
37
  * Prints custom directives
39
38
  */
40
- static readonly printCustomDirectives: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection>;
39
+ static readonly printCustomDirectives: typeof printCustomDirectives;
41
40
  /**
42
41
  * Prints custom tags
43
42
  */
44
- static readonly printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
43
+ static readonly printCustomTags: typeof printCustomTags;
45
44
  private static _eventEmitter;
46
45
  private static _options;
47
- private static _deprecatedOptions;
48
46
  private static _mdxDeclaration;
49
47
  /**
50
48
  * Global printer configuration options
51
49
  */
52
50
  static get options(): Readonly<Maybe<PrintTypeOptions>>;
53
- /**
54
- * Backward-compat section toggles extracted from legacy config options.
55
- *
56
- * These flags are applied only during section order composition.
57
- */
58
- static get deprecatedOptions(): Readonly<Maybe<DeprecatedPrintTypeOptions>>;
59
51
  /**
60
52
  * Optional event emitter for print events.
61
53
  * When set, the printer will emit events before/after printCode and printType,
@@ -80,17 +72,7 @@ export declare class Printer implements IPrinter {
80
72
  * @param mdxDeclaration - Optional MDX import declaration
81
73
  * @param eventEmitter - Optional event emitter for print events interception
82
74
  */
83
- static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, sectionHeaderId }?: {
84
- customDirectives?: CustomDirectiveMap;
85
- deprecated?: TypeDeprecatedOption;
86
- groups?: SchemaEntitiesGroupMap;
87
- meta?: Maybe<MetaInfo>;
88
- metatags?: Record<string, string>[];
89
- onlyDocDirectives?: GraphQLDirective[];
90
- printTypeOptions?: InitPrintTypeOptions;
91
- skipDocDirectives?: GraphQLDirective[];
92
- sectionHeaderId?: boolean;
93
- }, formatter?: Partial<Formatter>, mdxDeclaration?: Maybe<string>, eventEmitter?: Maybe<PrinterEventEmitter>): Promise<void>;
75
+ static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, deprecated, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, sectionHeaderId, }?: PrinterInitOptions, formatter?: Partial<Formatter>, mdxDeclaration?: Maybe<string>, eventEmitter?: Maybe<PrinterEventEmitter>): Promise<void>;
94
76
  /**
95
77
  * Prints the header section of a type documentation
96
78
  *
@@ -142,7 +124,7 @@ export declare class Printer implements IPrinter {
142
124
  * @param options - Printer configuration options
143
125
  * @returns Metadata section (or section list) for supported types, otherwise undefined
144
126
  */
145
- static readonly printTypeMetadata: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection[] | PageSection>;
127
+ static readonly printTypeMetadata: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection | PageSection[]>;
146
128
  /**
147
129
  * Prints related type information
148
130
  *
@@ -150,7 +132,7 @@ export declare class Printer implements IPrinter {
150
132
  * @param options - Printer configuration options
151
133
  * @returns Formatted relations section as MDX or plain string
152
134
  */
153
- static readonly printRelations: (type: unknown, options: PrintTypeOptions) => string | MDXString;
135
+ static readonly printRelations: (type: unknown, options: PrintTypeOptions) => MDXString | string;
154
136
  /**
155
137
  * Prints HTML meta tags for the documentation
156
138
  *
@@ -158,7 +140,7 @@ export declare class Printer implements IPrinter {
158
140
  * @param options - Printer configuration options containing metatags
159
141
  * @returns Formatted HTML meta tags string
160
142
  */
161
- static readonly printMetaTags: (_type: unknown, { metatags }: PrintTypeOptions) => string | MDXString;
143
+ static readonly printMetaTags: (_type: unknown, { metatags }: PrintTypeOptions) => MDXString | string;
162
144
  /**
163
145
  * Main method to print complete documentation for a GraphQL type
164
146
  *
@@ -195,12 +177,6 @@ export declare class Printer implements IPrinter {
195
177
  * Renders a page section, optionally prefixing a heading when a title is present.
196
178
  */
197
179
  private static readonly renderPageSection;
198
- /**
199
- * Returns the default content section order for type pages.
200
- *
201
- * Applies backward-compatibility toggles from deprecated section flags.
202
- */
203
- private static readonly getDeprecatedTypePageSectionOrder;
204
180
  /**
205
181
  * Runtime guard for built-in page content section keys.
206
182
  */
@@ -220,5 +196,4 @@ export declare class Printer implements IPrinter {
220
196
  */
221
197
  private static readonly normalizePageSection;
222
198
  }
223
- export {};
224
199
  //# sourceMappingURL=printer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,0BAA0B,EAC1B,SAAS,EACT,gBAAgB,EAEhB,aAAa,EACb,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EAER,WAAW,EAEX,6BAA6B,EAC7B,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAsGjC,KAAK,oBAAoB,GAAG,0BAA0B,GACpD,IAAI,CAAC,6BAA6B,EAAE,gBAAgB,CAAC,GAAG;IACtD,cAAc,CAAC,EACX,0BAA0B,CAAC,gBAAgB,CAAC,GAC5C,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;CACrD,CAAC;AAEJ;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IACtC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,gBAAgB,gGAAoB;IAEpD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,qBAAqB,mEAAyB;IAE9D;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe,mEAAmB;IAElD,OAAO,CAAC,MAAM,CAAC,aAAa,CAA6B;IAEzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoC;IAE3D,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAE/B;IAEF,OAAO,CAAC,MAAM,CAAC,eAAe,CAA0B;IAExD;;OAEG;IACH,MAAM,KAAK,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAEtD;IAED;;;;OAIG;IACH,MAAM,KAAK,iBAAiB,IAAI,QAAQ,CAAC,KAAK,CAAC,0BAA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AM,CAcnB;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,SACjB,KAAK,CAAC,MAAM,CAAC,QACb,OAAO,YACH,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,KACzC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CA6G1B;IAEF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAsDvC;IAEF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAO9C;IAEF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAO7C;IAEF;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAgBlD;IAEF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAY1C;CACH"}
package/dist/printer.js CHANGED
@@ -58,6 +58,24 @@ const DEFAULT_INIT_OPTIONS = {
58
58
  groups: undefined,
59
59
  sectionHeaderId: true,
60
60
  };
61
+ const normalizeHierarchy = (hierarchy) => {
62
+ if (!hierarchy) {
63
+ return undefined;
64
+ }
65
+ if (typeof hierarchy !== "string") {
66
+ return hierarchy;
67
+ }
68
+ switch (hierarchy.toLowerCase()) {
69
+ case "entity":
70
+ return { entity: {} };
71
+ case "flat":
72
+ return { flat: {} };
73
+ case "api":
74
+ return { api: {} };
75
+ default:
76
+ return undefined;
77
+ }
78
+ };
61
79
  /**
62
80
  * The Printer class implements the core functionality for generating Markdown documentation
63
81
  * from GraphQL schema types.
@@ -91,7 +109,6 @@ class Printer {
91
109
  static printCustomTags = directive_1.printCustomTags;
92
110
  static _eventEmitter;
93
111
  static _options;
94
- static _deprecatedOptions;
95
112
  static _mdxDeclaration;
96
113
  /**
97
114
  * Global printer configuration options
@@ -99,14 +116,6 @@ class Printer {
99
116
  static get options() {
100
117
  return Printer._options;
101
118
  }
102
- /**
103
- * Backward-compat section toggles extracted from legacy config options.
104
- *
105
- * These flags are applied only during section order composition.
106
- */
107
- static get deprecatedOptions() {
108
- return Printer._deprecatedOptions;
109
- }
110
119
  /**
111
120
  * Optional event emitter for print events.
112
121
  * When set, the printer will emit events before/after printCode and printType,
@@ -141,7 +150,7 @@ class Printer {
141
150
  * @param mdxDeclaration - Optional MDX import declaration
142
151
  * @param eventEmitter - Optional event emitter for print events interception
143
152
  */
144
- static async init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, sectionHeaderId, } = DEFAULT_INIT_OPTIONS, formatter, mdxDeclaration, eventEmitter) {
153
+ static async init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, deprecated, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, sectionHeaderId, } = DEFAULT_INIT_OPTIONS, formatter, mdxDeclaration, eventEmitter) {
145
154
  // Always update eventEmitter regardless of initialization state
146
155
  Printer.eventEmitter = eventEmitter ?? null;
147
156
  if (Printer.options === undefined) {
@@ -155,38 +164,22 @@ class Printer {
155
164
  groups,
156
165
  parentTypePrefix: printTypeOptions?.parentTypePrefix ??
157
166
  options_1.PRINT_TYPE_DEFAULT_OPTIONS.parentTypePrefix,
158
- deprecated: printTypeOptions?.deprecated ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.deprecated,
167
+ deprecated: printTypeOptions?.deprecated ??
168
+ deprecated ??
169
+ options_1.PRINT_TYPE_DEFAULT_OPTIONS.deprecated,
159
170
  schema,
160
171
  onlyDocDirectives: onlyDocDirectives ?? [],
161
172
  skipDocDirectives: skipDocDirectives ?? [],
162
173
  sectionHeaderId: sectionHeaderId ?? options_1.DEFAULT_OPTIONS.sectionHeaderId,
163
174
  typeBadges: printTypeOptions?.typeBadges ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.typeBadges,
164
175
  metatags: metatags ?? [],
165
- hierarchy: printTypeOptions?.hierarchy ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.hierarchy,
176
+ hierarchy: normalizeHierarchy(printTypeOptions?.hierarchy) ??
177
+ options_1.PRINT_TYPE_DEFAULT_OPTIONS.hierarchy,
166
178
  meta: meta,
167
179
  // Merge formatter functions: default formatter with any overrides
168
180
  ...(0, formatter_1.createDefaultFormatter)(),
169
181
  ...formatter,
170
182
  };
171
- const initExampleSection = printTypeOptions?.exampleSection;
172
- let deprecatedExampleSection;
173
- if (typeof initExampleSection === "boolean") {
174
- deprecatedExampleSection = initExampleSection;
175
- }
176
- else if (initExampleSection === undefined) {
177
- deprecatedExampleSection =
178
- options_1.PRINT_TYPE_DEFAULT_DEPRECATED_OPTIONS.exampleSection;
179
- }
180
- else {
181
- deprecatedExampleSection = true;
182
- }
183
- Printer._deprecatedOptions = {
184
- codeSection: printTypeOptions?.codeSection ??
185
- options_1.PRINT_TYPE_DEFAULT_DEPRECATED_OPTIONS.codeSection,
186
- exampleSection: deprecatedExampleSection,
187
- relatedTypeSection: printTypeOptions?.relatedTypeSection ??
188
- options_1.PRINT_TYPE_DEFAULT_DEPRECATED_OPTIONS.relatedTypeSection,
189
- };
190
183
  Printer.mdxDeclaration = mdxDeclaration ?? "";
191
184
  }
192
185
  }
@@ -213,7 +206,7 @@ class Printer {
213
206
  * @returns Formatted code block string with type definition
214
207
  */
215
208
  static printCode = (type, options) => {
216
- let code = "";
209
+ let code;
217
210
  switch (true) {
218
211
  case (0, graphql_1.isOperation)(type):
219
212
  code = (0, graphql_2.printCodeOperation)(type, options);
@@ -395,12 +388,6 @@ class Printer {
395
388
  ...Printer.options,
396
389
  ...options,
397
390
  };
398
- const deprecatedOptions = {
399
- ...Printer.deprecatedOptions,
400
- exampleSection: printTypeOptions.exampleSection
401
- ? true
402
- : Printer.deprecatedOptions?.exampleSection,
403
- };
404
391
  if (!name || !(0, link_1.hasPrintableDirective)(type, printTypeOptions)) {
405
392
  return undefined;
406
393
  }
@@ -418,12 +405,9 @@ class Printer {
418
405
  const header = Printer.printHeader(name, (0, graphql_1.getTypeName)(type), printTypeOptions);
419
406
  const metatags = Printer.printMetaTags(type, printTypeOptions);
420
407
  const description = Printer.printDescription(type, printTypeOptions);
421
- // Generate all sections unconditionally to support event hooks that might re-add
422
- // sections excluded by deprecated toggles. This is a performance trade-off:
423
- // sections excluded by deprecated flags (codeSection, exampleSection, relatedTypeSection)
424
- // are still generated and print events emitted, even if they won't be rendered.
425
- // TODO(perf): Implement lazy section generation based on final composed order
426
- // when no BEFORE_COMPOSE_PAGE_TYPE listeners are registered.
408
+ // Generate all sections unconditionally so that BEFORE_COMPOSE_PAGE_TYPE hooks
409
+ // can add, remove, or reorder them at will.
410
+ // See: https://github.com/graphql-markdown/graphql-markdown/issues/2954
427
411
  const code = await Printer.printCodeAsync(type, name, printTypeOptions);
428
412
  const customDirectives = Printer.printCustomDirectives(type, printTypeOptions);
429
413
  const tags = Printer.printCustomTags(type, printTypeOptions);
@@ -443,7 +427,7 @@ class Printer {
443
427
  example: Printer.normalizePageSection(example),
444
428
  relations: Printer.normalizePageSection(relations),
445
429
  };
446
- let sectionOrder = Printer.getDeprecatedTypePageSectionOrder([...TYPE_PAGE_SECTION_ORDER], deprecatedOptions);
430
+ let sectionOrder = [...TYPE_PAGE_SECTION_ORDER];
447
431
  // Emit BEFORE_COMPOSE_PAGE_TYPE event if emitter is configured
448
432
  if (Printer.eventEmitter) {
449
433
  const beforeComposeEvent = new events_1.BeforeComposePageTypeEvent({ type, name, options: printTypeOptions, sections }, sectionOrder);
@@ -521,25 +505,6 @@ class Printer {
521
505
  }
522
506
  return `${title}${content}`;
523
507
  };
524
- /**
525
- * Returns the default content section order for type pages.
526
- *
527
- * Applies backward-compatibility toggles from deprecated section flags.
528
- */
529
- static getDeprecatedTypePageSectionOrder = (sections, deprecatedOptions) => {
530
- return sections.filter((section) => {
531
- if (section === "code") {
532
- return deprecatedOptions.codeSection !== false;
533
- }
534
- if (section === "example") {
535
- return deprecatedOptions.exampleSection !== false;
536
- }
537
- if (section === "relations") {
538
- return deprecatedOptions.relatedTypeSection !== false;
539
- }
540
- return true;
541
- });
542
- };
543
508
  /**
544
509
  * Runtime guard for built-in page content section keys.
545
510
  */
@@ -28,7 +28,7 @@ export declare const getRootTypeLocaleFromString: (text: string) => Maybe<TypeLo
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) => string | MDXString;
31
+ export declare const printRelationOf: <T>(type: unknown, section: unknown, getRelation: Maybe<IGetRelation<T>>, options: PrintTypeOptions) => MDXString | string;
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,5 +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) => string | MDXString;
43
+ export declare const printRelations: (type: unknown, options: PrintTypeOptions) => MDXString | string;
44
44
  //# sourceMappingURL=relation.d.ts.map
@@ -1 +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"}
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;AAGH,eAAO,MAAM,2BAA2B,SAChC,MAAM,KACX,KAAK,CAAC,UAAU,CAOlB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AAGH,eAAO,MAAM,eAAe,GAAI,CAAC,QACzB,OAAO,WACJ,OAAO,eACH,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,WAC1B,gBAAgB,KACxB,SAAS,GAAG,MAmDd,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,SACnB,OAAO,WACJ,gBAAgB,KACxB,SAAS,GAAG,MAgBd,CAAC"}
package/dist/relation.js CHANGED
@@ -20,6 +20,8 @@ const options_1 = require("./const/options");
20
20
  * const locale = getRootTypeLocaleFromString('Query');
21
21
  * ```
22
22
  */
23
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
24
+ // fallow-ignore-next-line unused-export
23
25
  const getRootTypeLocaleFromString = (text) => {
24
26
  for (const [type, props] of Object.entries(strings_1.ROOT_TYPE_LOCALE)) {
25
27
  if (Object.values(props).includes(text)) {
@@ -43,6 +45,8 @@ exports.getRootTypeLocaleFromString = getRootTypeLocaleFromString;
43
45
  * const mdx = printRelationOf(type, "Member Of", getRelationOfField, options);
44
46
  * ```
45
47
  */
48
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
49
+ // fallow-ignore-next-line unused-export
46
50
  const printRelationOf = (type, section, getRelation, options) => {
47
51
  if (!(0, graphql_1.isNamedType)(type) ||
48
52
  (0, graphql_1.isOperation)(type) ||
package/dist/section.d.ts CHANGED
@@ -13,7 +13,7 @@ import type { Maybe, MDXString, PageSection, PrintTypeOptions } from "@graphql-m
13
13
  *
14
14
  * @template T - Type of the GraphQL element being printed
15
15
  */
16
- export declare const printSectionItem: <T>(type: T, options: PrintTypeOptions) => string | MDXString;
16
+ export declare const printSectionItem: <T>(type: T, options: PrintTypeOptions) => MDXString | string;
17
17
  /**
18
18
  * Prints an array of section items with consistent formatting.
19
19
  *
@@ -23,7 +23,7 @@ export declare const printSectionItem: <T>(type: T, options: PrintTypeOptions) =
23
23
  *
24
24
  * @template V - Type of the values being printed
25
25
  */
26
- export declare const printSectionItems: <V>(values: V | V[], options: PrintTypeOptions) => string | MDXString;
26
+ export declare const printSectionItems: <V>(values: V | V[], options: PrintTypeOptions) => MDXString | string;
27
27
  /**
28
28
  * Prints a complete section with title and content.
29
29
  *
@@ -1 +1 @@
1
- {"version":3,"file":"section.d.ts","sourceRoot":"","sources":["../src/section.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,KAAK,EACL,SAAS,EACT,WAAW,EACX,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAuBjC;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,2DAmDjC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,mEAoBlC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,+FAyC7B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,CAAC,4GA0ExC,CAAC"}
1
+ {"version":3,"file":"section.d.ts","sourceRoot":"","sources":["../src/section.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,KAAK,EACL,SAAS,EACT,WAAW,EACX,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAuBjC;;;;;;;;GAQG;AAGH,eAAO,MAAM,gBAAgB,GAAI,CAAC,QAC1B,CAAC,WACE,gBAAgB,KACxB,SAAS,GAAG,MAgDd,CAAC;AAEF;;;;;;;;GAQG;AAGH,eAAO,MAAM,iBAAiB,GAAI,CAAC,UACzB,CAAC,GAAG,CAAC,EAAE,WACN,gBAAgB,KACxB,SAAS,GAAG,MAiBd,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,UACpB,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,WACjB,MAAM,WACN,gBAAgB,KACxB,KAAK,CAAC,WAAW,CAmCnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,CAAC,QACjC,CAAC,UACC,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,WACrB,MAAM,WACN,gBAAgB,KACxB,KAAK,CAAC,WAAW,CAqEnB,CAAC"}