@graphql-markdown/printer-legacy 1.14.0 → 1.16.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.
Files changed (71) hide show
  1. package/dist/badge.d.ts +10 -3
  2. package/dist/badge.d.ts.map +1 -1
  3. package/dist/badge.js +19 -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 +5 -6
  9. package/dist/const/options.d.ts +11 -2
  10. package/dist/const/options.d.ts.map +1 -1
  11. package/dist/const/options.js +27 -10
  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 +4 -4
  16. package/dist/directive.d.ts.map +1 -1
  17. package/dist/directive.js +9 -12
  18. package/dist/events.d.ts +77 -0
  19. package/dist/events.d.ts.map +1 -0
  20. package/dist/events.js +85 -0
  21. package/dist/example.d.ts.map +1 -1
  22. package/dist/example.js +12 -7
  23. package/dist/format-helpers.d.ts +9 -0
  24. package/dist/format-helpers.d.ts.map +1 -1
  25. package/dist/format-helpers.js +10 -1
  26. package/dist/formatter.d.ts.map +1 -1
  27. package/dist/formatter.js +9 -30
  28. package/dist/frontmatter.d.ts.map +1 -1
  29. package/dist/graphql/directive.d.ts +4 -4
  30. package/dist/graphql/directive.d.ts.map +1 -1
  31. package/dist/graphql/directive.js +3 -3
  32. package/dist/graphql/enum.d.ts +4 -4
  33. package/dist/graphql/enum.d.ts.map +1 -1
  34. package/dist/graphql/enum.js +2 -2
  35. package/dist/graphql/input.d.ts.map +1 -1
  36. package/dist/graphql/input.js +1 -1
  37. package/dist/graphql/interface.d.ts.map +1 -1
  38. package/dist/graphql/interface.js +1 -1
  39. package/dist/graphql/object.d.ts +3 -3
  40. package/dist/graphql/object.d.ts.map +1 -1
  41. package/dist/graphql/object.js +4 -4
  42. package/dist/graphql/operation.d.ts +4 -12
  43. package/dist/graphql/operation.d.ts.map +1 -1
  44. package/dist/graphql/operation.js +43 -11
  45. package/dist/graphql/scalar.d.ts +6 -6
  46. package/dist/graphql/scalar.d.ts.map +1 -1
  47. package/dist/graphql/scalar.js +7 -7
  48. package/dist/graphql/union.d.ts +4 -4
  49. package/dist/graphql/union.d.ts.map +1 -1
  50. package/dist/graphql/union.js +2 -2
  51. package/dist/group.d.ts +2 -2
  52. package/dist/group.d.ts.map +1 -1
  53. package/dist/group.js +7 -6
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +6 -2
  57. package/dist/link.d.ts +6 -14
  58. package/dist/link.d.ts.map +1 -1
  59. package/dist/link.js +9 -9
  60. package/dist/mdx/index.d.ts +1 -1
  61. package/dist/mdx/index.d.ts.map +1 -1
  62. package/dist/mdx/index.js +2 -2
  63. package/dist/printer.d.ts +51 -34
  64. package/dist/printer.d.ts.map +1 -1
  65. package/dist/printer.js +234 -118
  66. package/dist/relation.d.ts +2 -2
  67. package/dist/relation.d.ts.map +1 -1
  68. package/dist/section.d.ts +5 -5
  69. package/dist/section.d.ts.map +1 -1
  70. package/dist/section.js +26 -11
  71. package/package.json +18 -6
package/dist/badge.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * and their properties like deprecation status, nullability, and relationships.
5
5
  * @module
6
6
  */
7
- import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntity } from "@graphql-markdown/types";
7
+ import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntitiesGroupMap } from "@graphql-markdown/types";
8
8
  export declare const CSS_BADGE_CLASSNAME: {
9
9
  DEPRECATED: string;
10
10
  RELATION: string;
@@ -16,7 +16,7 @@ export declare const CSS_BADGE_CLASSNAME: {
16
16
  * @param groups - Optional map of schema entities to their groups
17
17
  * @returns Array of Badge objects containing text and optional classnames
18
18
  */
19
- export declare const getTypeBadges: (type: unknown, groups?: Maybe<Partial<Record<SchemaEntity, Record<string, Maybe<string>>>>>) => Badge[];
19
+ export declare const getTypeBadges: (type: unknown, groups?: Maybe<SchemaEntitiesGroupMap>) => Badge[];
20
20
  /**
21
21
  * Formats a single badge into MDX string format.
22
22
  * @param badge - The badge object containing text and optional classname
@@ -24,11 +24,18 @@ export declare const getTypeBadges: (type: unknown, groups?: Maybe<Partial<Recor
24
24
  * @returns Formatted MDX string representation of the badge
25
25
  */
26
26
  export declare const printBadge: ({ text, classname }: Badge, options: PrintTypeOptions) => MDXString;
27
+ /**
28
+ * Formats an array of badges into a space-joined MDX string.
29
+ * @param badges - Array of badge objects to format
30
+ * @param options - Options containing the formatter for badges
31
+ * @returns Space-joined MDX string of all badges, or empty string if none
32
+ */
33
+ export declare const formatBadges: (badges: Badge[], options: PrintTypeOptions) => MDXString | string;
27
34
  /**
28
35
  * Generates and formats all applicable badges for a GraphQL type.
29
36
  * @param type - The GraphQL type to generate badges for
30
37
  * @param options - Options for printing/formatting the badges
31
38
  * @returns Formatted MDX string containing all badges, or empty string if no badges or badges disabled
32
39
  */
33
- export declare const printBadges: (type: unknown, options: PrintTypeOptions) => string | MDXString;
40
+ export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
34
41
  //# sourceMappingURL=badge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../src/badge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,KAAK,EAEL,SAAS,EACT,KAAK,EACL,gBAAgB,EAEhB,YAAY,EACb,MAAM,yBAAyB,CAAC;AAgBjC,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,0GA6CzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,sEActB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kEAsBvB,CAAC"}
1
+ {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../src/badge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,KAAK,EAEL,SAAS,EACT,KAAK,EACL,gBAAgB,EAChB,sBAAsB,EAEvB,MAAM,yBAAyB,CAAC;AAgBjC,eAAO,MAAM,mBAAmB;IAC9B,UAAU;IACV,QAAQ;IACR,QAAQ;CACT,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAClB,OAAO,WACJ,KAAK,CAAC,sBAAsB,CAAC,KACrC,KAAK,EA0CP,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,wBACA,KAAK,WACjB,gBAAgB,KACxB,SAWF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,WACf,KAAK,EAAE,WACN,gBAAgB,KACxB,SAAS,GAAG,MASd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SAChB,OAAO,WACJ,gBAAgB,KACxB,SAAS,GAAG,MAUd,CAAC"}
package/dist/badge.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * @module
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.printBadges = exports.printBadge = exports.getTypeBadges = exports.CSS_BADGE_CLASSNAME = void 0;
9
+ exports.printBadges = exports.formatBadges = exports.printBadge = exports.getTypeBadges = exports.CSS_BADGE_CLASSNAME = void 0;
10
10
  const utils_1 = require("@graphql-markdown/utils");
11
11
  const graphql_1 = require("@graphql-markdown/graphql");
12
12
  const link_1 = require("./link");
@@ -76,6 +76,23 @@ const printBadge = ({ text, classname }, options) => {
76
76
  return (0, formatter_1.createDefaultFormatter)().formatMDXBadge(badge);
77
77
  };
78
78
  exports.printBadge = printBadge;
79
+ /**
80
+ * Formats an array of badges into a space-joined MDX string.
81
+ * @param badges - Array of badge objects to format
82
+ * @param options - Options containing the formatter for badges
83
+ * @returns Space-joined MDX string of all badges, or empty string if none
84
+ */
85
+ const formatBadges = (badges, options) => {
86
+ if (badges.length === 0) {
87
+ return "";
88
+ }
89
+ return badges
90
+ .map((badge) => {
91
+ return (0, exports.printBadge)(badge, options);
92
+ })
93
+ .join(" ");
94
+ };
95
+ exports.formatBadges = formatBadges;
79
96
  /**
80
97
  * Generates and formats all applicable badges for a GraphQL type.
81
98
  * @param type - The GraphQL type to generate badges for
@@ -88,13 +105,6 @@ const printBadges = (type, options) => {
88
105
  !options.typeBadges) {
89
106
  return "";
90
107
  }
91
- const badges = (0, exports.getTypeBadges)(type, options.groups);
92
- if (badges.length === 0) {
93
- return "";
94
- }
95
- const formattedBadges = badges.map((badge) => {
96
- return (0, exports.printBadge)(badge, options);
97
- });
98
- return formattedBadges.join(" ");
108
+ return (0, exports.formatBadges)((0, exports.getTypeBadges)(type, options.groups), options);
99
109
  };
100
110
  exports.printBadges = printBadges;
package/dist/code.d.ts CHANGED
@@ -38,5 +38,5 @@ export declare const printCodeArguments: (type: unknown, indentationLevel?: numb
38
38
  * // ): User!
39
39
  * ```
40
40
  */
41
- export declare const printCodeField: (type: unknown, options?: PrintTypeOptions | undefined, indentationLevel?: number) => string | MDXString;
41
+ export declare const printCodeField: (type: unknown, options?: PrintTypeOptions, indentationLevel?: number) => MDXString | string;
42
42
  //# sourceMappingURL=code.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../src/code.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAiB3E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,sDA4B9B,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,0GAwB1B,CAAC"}
1
+ {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../src/code.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAiB3E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,SACvB,OAAO,qBACK,MAAM,KACvB,MAyBF,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,SACnB,OAAO,YACH,gBAAgB,qBACR,MAAM,KACvB,SAAS,GAAG,MAoBd,CAAC"}
package/dist/common.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Common printer utility functions for handling descriptions, directives, and warnings.
3
3
  * @module
4
4
  */
5
- import type { Maybe, MDXString, PrintTypeOptions } from "@graphql-markdown/types";
5
+ import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
6
6
  /**
7
7
  * Prints documentation for custom directives applied to a type.
8
8
  *
@@ -10,15 +10,7 @@ import type { Maybe, MDXString, PrintTypeOptions } from "@graphql-markdown/types
10
10
  * @param options - Printer configuration options
11
11
  * @returns Formatted directive documentation string
12
12
  */
13
- export declare const printCustomDirectives: (type: unknown, options?: PrintTypeOptions | undefined) => string;
14
- /**
15
- * Formats a GraphQL type description or falls back to a default message.
16
- *
17
- * @param type - GraphQL type to get description from
18
- * @param replacement - Optional fallback text if no description exists
19
- * @returns Formatted description string or MDX content
20
- */
21
- export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => string | MDXString;
13
+ export declare const getCustomDirectivesText: (type: unknown, options?: PrintTypeOptions) => string;
22
14
  /**
23
15
  * Generates a warning message block in MDX format.
24
16
  * @param warningConfig - Warning configuration object with `text` and optional `title` properties
@@ -26,8 +18,8 @@ export declare const formatDescription: (type: unknown, replacement?: Maybe<stri
26
18
  * @returns Formatted warning message as MDX string
27
19
  */
28
20
  export declare const printWarning: ({ text, title }: {
29
- text?: string | undefined;
30
- title?: string | undefined;
21
+ text?: string;
22
+ title?: string;
31
23
  }, options: PrintTypeOptions) => string;
32
24
  /**
33
25
  * Prints deprecation information for a GraphQL type if it is deprecated.
@@ -43,5 +35,5 @@ export declare const printDeprecation: (type: unknown, options: PrintTypeOptions
43
35
  * @param noText - Optional text to display when no description exists
44
36
  * @returns Combined description, deprecation notices, and custom directives as MDX content
45
37
  */
46
- export declare const printDescription: (type: unknown, options: PrintTypeOptions, noText?: string | undefined) => string | MDXString;
38
+ export declare const printDescription: (type: unknown, options: PrintTypeOptions, noText?: string) => MDXString | string;
47
39
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAGV,KAAK,EACL,SAAS,EACT,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAcjC;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,mEA+BjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,oEAY7B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;uCAaxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,sDAiB5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,+FAS5B,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAIV,SAAS,EACT,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAcjC;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,SAC5B,OAAO,YACH,gBAAgB,KACzB,MA4BF,CAAC;AAuBF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,oBACN;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,WACzC,gBAAgB,KACxB,MAUF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,SACrB,OAAO,WACJ,gBAAgB,KACxB,MAcF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,SACrB,OAAO,WACJ,gBAAgB,WAChB,MAAM,KACd,SAAS,GAAG,MAKd,CAAC"}
package/dist/common.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @module
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.printDescription = exports.printDeprecation = exports.printWarning = exports.formatDescription = exports.printCustomDirectives = void 0;
7
+ exports.printDescription = exports.printDeprecation = exports.printWarning = exports.getCustomDirectivesText = void 0;
8
8
  const utils_1 = require("@graphql-markdown/utils");
9
9
  const graphql_1 = require("@graphql-markdown/graphql");
10
10
  const strings_1 = require("./const/strings");
@@ -16,7 +16,7 @@ const directive_1 = require("./directive");
16
16
  * @param options - Printer configuration options
17
17
  * @returns Formatted directive documentation string
18
18
  */
19
- const printCustomDirectives = (type, options) => {
19
+ const getCustomDirectivesText = (type, options) => {
20
20
  const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
21
21
  if ((0, utils_1.isEmpty)(constDirectiveMap)) {
22
22
  return "";
@@ -34,7 +34,7 @@ const printCustomDirectives = (type, options) => {
34
34
  .join(strings_1.MARKDOWN_EOP);
35
35
  return `${strings_1.MARKDOWN_EOP}${content}`;
36
36
  };
37
- exports.printCustomDirectives = printCustomDirectives;
37
+ exports.getCustomDirectivesText = getCustomDirectivesText;
38
38
  /**
39
39
  * Formats a GraphQL type description or falls back to a default message.
40
40
  *
@@ -51,7 +51,6 @@ const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) =>
51
51
  : replacement;
52
52
  return `${strings_1.MARKDOWN_EOP}${(0, utils_1.escapeMDX)(description)}`;
53
53
  };
54
- exports.formatDescription = formatDescription;
55
54
  /**
56
55
  * Generates a warning message block in MDX format.
57
56
  * @param warningConfig - Warning configuration object with `text` and optional `title` properties
@@ -89,8 +88,8 @@ exports.printDeprecation = printDeprecation;
89
88
  * @returns Combined description, deprecation notices, and custom directives as MDX content
90
89
  */
91
90
  const printDescription = (type, options, noText) => {
92
- const description = (0, exports.formatDescription)(type, noText);
93
- const customDirectives = (0, exports.printCustomDirectives)(type, options);
91
+ const description = formatDescription(type, noText);
92
+ const customDirectives = (0, exports.getCustomDirectivesText)(type, options);
94
93
  const deprecation = (0, exports.printDeprecation)(type, options);
95
94
  return `${deprecation}${description}${customDirectives}`;
96
95
  };
@@ -5,12 +5,21 @@ export declare enum TypeHierarchy {
5
5
  FLAT = "flat"
6
6
  }
7
7
  export declare enum SectionLevels {
8
+ /**
9
+ * @deprecated Use `SectionLevels.LEVEL` instead.
10
+ */
8
11
  NONE = "",
9
12
  LEVEL = "#"
10
13
  }
11
- export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<PrinterConfigPrintTypeOptions>;
12
- export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "formatCategoryFolderName" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives" | "beforeSchemaLoadHook" | "afterSchemaLoadHook" | "beforeDiffCheckHook" | "afterDiffCheckHook" | "beforeRenderRootTypesHook" | "afterRenderRootTypesHook" | "beforeRenderHomepageHook" | "afterRenderHomepageHook" | "beforeRenderTypeEntitiesHook" | "afterRenderTypeEntitiesHook" | "beforeGenerateIndexMetafileHook" | "afterGenerateIndexMetafileHook">> & {
14
+ export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<Omit<PrinterConfigPrintTypeOptions, "exampleSection">> & {
15
+ exampleSection: PrintTypeOptions["exampleSection"];
16
+ };
17
+ /**
18
+ * Clean runtime options passed through the printer.
19
+ */
20
+ export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "afterDiffCheckHook" | "afterGenerateIndexMetafileHook" | "afterRenderHomepageHook" | "afterRenderRootTypesHook" | "afterRenderTypeEntitiesHook" | "afterSchemaLoadHook" | "beforeDiffCheckHook" | "beforeGenerateIndexMetafileHook" | "beforeRenderHomepageHook" | "beforeRenderRootTypesHook" | "beforeRenderTypeEntitiesHook" | "beforeSchemaLoadHook" | "collapsible" | "exampleSection" | "formatCategoryFolderName" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
13
21
  collapsible: Maybe<CollapsibleOption>;
22
+ exampleSection: PrintTypeOptions["exampleSection"];
14
23
  groups: Maybe<SchemaEntitiesGroupMap>;
15
24
  level: Maybe<SectionLevelValue>;
16
25
  onlyDocDirectives: GraphQLDirective[];
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/const/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAIjC,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,oBAAY,aAAa;IACvB,IAAI,KAAK;IACT,KAAK,MAAM;CACZ;AAED,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,6BAA6B,CAU5E,CAAC;AAEJ,eAAO,MAAM,eAAe,EAAE,QAAQ,CACpC,IAAI,CACF,gBAAgB,EACd,aAAa,GACb,0BAA0B,GAC1B,QAAQ,GACR,OAAO,GACP,MAAM,GACN,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,2BAA2B,GAC3B,0BAA0B,GAC1B,0BAA0B,GAC1B,yBAAyB,GACzB,8BAA8B,GAC9B,6BAA6B,GAC7B,iCAAiC,GACjC,gCAAgC,CACnC,CACF,GAAG;IACF,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACtC,MAAM,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7B,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CAiBvC,CAAC"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/const/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAajC,oBAAY,aAAa;IACvB,GAAG,QAAQ;IAIX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,oBAAY,aAAa;IACvB;;OAEG;IAEH,IAAI,KAAK;IACT,KAAK,MAAM;CACZ;AAED,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAC/C,IAAI,CAAC,6BAA6B,EAAE,gBAAgB,CAAC,CACtD,GAAG;IACF,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAQpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CACpC,IAAI,CACF,gBAAgB,EACd,oBAAoB,GACpB,gCAAgC,GAChC,yBAAyB,GACzB,0BAA0B,GAC1B,6BAA6B,GAC7B,qBAAqB,GACrB,qBAAqB,GACrB,iCAAiC,GACjC,0BAA0B,GAC1B,2BAA2B,GAC3B,8BAA8B,GAC9B,sBAAsB,GACtB,aAAa,GACb,gBAAgB,GAChB,0BAA0B,GAC1B,QAAQ,GACR,OAAO,GACP,MAAM,GACN,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,mBAAmB,CACtB,CACF,GAAG;IACF,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACtC,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACnD,MAAM,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7B,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CA6BvC,CAAC"}
@@ -1,45 +1,62 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.DEFAULT_OPTIONS = exports.PRINT_TYPE_DEFAULT_OPTIONS = exports.SectionLevels = exports.TypeHierarchy = void 0;
7
- const mdx_1 = __importDefault(require("../mdx"));
4
+ const defaults_1 = require("@graphql-markdown/formatters/defaults");
8
5
  var TypeHierarchy;
9
6
  (function (TypeHierarchy) {
10
7
  TypeHierarchy["API"] = "api";
8
+ // Used cross-package in packages/core/src/renderer.ts and config.ts;
9
+ // fallow can't trace cross-workspace callers when dist/ is excluded.
10
+ // fallow-ignore-next-line unused-enum-member
11
11
  TypeHierarchy["ENTITY"] = "entity";
12
12
  TypeHierarchy["FLAT"] = "flat";
13
13
  })(TypeHierarchy || (exports.TypeHierarchy = TypeHierarchy = {}));
14
14
  var SectionLevels;
15
15
  (function (SectionLevels) {
16
+ /**
17
+ * @deprecated Use `SectionLevels.LEVEL` instead.
18
+ */
19
+ // fallow-ignore-next-line unused-enum-member
16
20
  SectionLevels["NONE"] = "";
17
21
  SectionLevels["LEVEL"] = "#";
18
22
  })(SectionLevels || (exports.SectionLevels = SectionLevels = {}));
19
23
  exports.PRINT_TYPE_DEFAULT_OPTIONS = {
20
- codeSection: true,
21
24
  deprecated: "default",
22
- exampleSection: false,
25
+ exampleSection: undefined,
23
26
  metatags: [],
24
27
  parentTypePrefix: true,
25
- relatedTypeSection: true,
26
28
  typeBadges: true,
27
29
  hierarchy: { [TypeHierarchy.API]: {} },
28
30
  };
31
+ /**
32
+ * Clean runtime options passed through the printer.
33
+ */
29
34
  exports.DEFAULT_OPTIONS = {
30
- ...exports.PRINT_TYPE_DEFAULT_OPTIONS,
35
+ deprecated: exports.PRINT_TYPE_DEFAULT_OPTIONS.deprecated,
31
36
  basePath: "/",
32
37
  collapsible: undefined,
33
38
  customDirectives: {},
39
+ exampleSection: undefined,
34
40
  groups: undefined,
35
41
  frontMatter: {},
36
42
  level: undefined,
37
- metatags: [],
43
+ metatags: exports.PRINT_TYPE_DEFAULT_OPTIONS.metatags,
38
44
  onlyDocDirectives: [],
45
+ operationNamespaceParts: null,
39
46
  parentType: undefined,
47
+ parentTypePrefix: exports.PRINT_TYPE_DEFAULT_OPTIONS.parentTypePrefix,
40
48
  schema: undefined,
41
49
  skipDocDirectives: [],
50
+ typeBadges: exports.PRINT_TYPE_DEFAULT_OPTIONS.typeBadges,
42
51
  withAttributes: false,
43
52
  sectionHeaderId: true,
44
- ...mdx_1.default,
53
+ hierarchy: exports.PRINT_TYPE_DEFAULT_OPTIONS.hierarchy,
54
+ formatMDXAdmonition: defaults_1.formatMDXAdmonition,
55
+ formatMDXBadge: defaults_1.formatMDXBadge,
56
+ formatMDXBullet: defaults_1.formatMDXBullet,
57
+ formatMDXDetails: defaults_1.formatMDXDetails,
58
+ formatMDXFrontmatter: defaults_1.formatMDXFrontmatter,
59
+ formatMDXLink: defaults_1.formatMDXLink,
60
+ formatMDXNameEntity: defaults_1.formatMDXNameEntity,
61
+ formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
45
62
  };
@@ -5,7 +5,7 @@
5
5
  * @packageDocumentation
6
6
  */
7
7
  import type { RootTypeLocale } from "@graphql-markdown/types";
8
- export { FRONT_MATTER_DELIMITER, MARKDOWN_CODE_INDENTATION, MARKDOWN_CODE_SNIPPET, MARKDOWN_EOL, MARKDOWN_EOP, } from "@graphql-markdown/utils";
8
+ export { MARKDOWN_CODE_INDENTATION, MARKDOWN_EOL, MARKDOWN_EOP, } from "@graphql-markdown/utils";
9
9
  /**
10
10
  * Human-readable labels for each GraphQL root type used when rendering copy or badges.
11
11
  */
@@ -14,8 +14,6 @@ export declare const ROOT_TYPE_LOCALE: RootTypeLocale;
14
14
  export declare const DEPRECATED: "deprecated";
15
15
  /** Copy fragment describing a non-null GraphQL modifier. */
16
16
  export declare const NON_NULL: "non-null";
17
- /** Short identifier for the GraphQL language tag used in fenced blocks. */
18
- export declare const GRAPHQL: "graphql";
19
17
  /** Default placeholder when no schema description is provided. */
20
18
  export declare const NO_DESCRIPTION_TEXT: "No description";
21
19
  /** Helper for inserting the code-block end delimiter in generated Markdown. */
@@ -1 +1 @@
1
- {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/const/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,EACrB,YAAY,EACZ,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,cAYrB,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,UAAU,cAAwB,CAAC;AAEhD,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,YAAsB,CAAC;AAE5C,2EAA2E;AAC3E,eAAO,MAAM,OAAO,WAAqB,CAAC;AAE1C,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,kBAA4B,CAAC;AAE7D,+EAA+E;AAC/E,eAAO,MAAM,YAAY,WAC0C,CAAC;AAEpE,oFAAoF;AACpF,eAAO,MAAM,YAAY,kBACoD,CAAC"}
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/const/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,cAYrB,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,UAAU,EAAG,YAAqB,CAAC;AAEhD,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,EAAG,UAAmB,CAAC;AAK5C,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,EAAG,gBAAyB,CAAC;AAE7D,+EAA+E;AAC/E,eAAO,MAAM,YAAY,WAC0C,CAAC;AAEpE,oFAAoF;AACpF,eAAO,MAAM,YAAY,kBACoD,CAAC"}
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MARKDOWN_SOC = exports.MARKDOWN_EOC = exports.NO_DESCRIPTION_TEXT = exports.GRAPHQL = exports.NON_NULL = exports.DEPRECATED = exports.ROOT_TYPE_LOCALE = exports.MARKDOWN_EOP = exports.MARKDOWN_EOL = exports.MARKDOWN_CODE_SNIPPET = exports.MARKDOWN_CODE_INDENTATION = exports.FRONT_MATTER_DELIMITER = void 0;
3
+ exports.MARKDOWN_SOC = exports.MARKDOWN_EOC = exports.NO_DESCRIPTION_TEXT = exports.NON_NULL = exports.DEPRECATED = exports.ROOT_TYPE_LOCALE = exports.MARKDOWN_EOP = exports.MARKDOWN_EOL = exports.MARKDOWN_CODE_INDENTATION = void 0;
4
4
  const utils_1 = require("@graphql-markdown/utils");
5
- const utils_2 = require("@graphql-markdown/utils");
6
- Object.defineProperty(exports, "FRONT_MATTER_DELIMITER", { enumerable: true, get: function () { return utils_2.FRONT_MATTER_DELIMITER; } });
5
+ var utils_2 = require("@graphql-markdown/utils");
7
6
  Object.defineProperty(exports, "MARKDOWN_CODE_INDENTATION", { enumerable: true, get: function () { return utils_2.MARKDOWN_CODE_INDENTATION; } });
8
- Object.defineProperty(exports, "MARKDOWN_CODE_SNIPPET", { enumerable: true, get: function () { return utils_2.MARKDOWN_CODE_SNIPPET; } });
9
7
  Object.defineProperty(exports, "MARKDOWN_EOL", { enumerable: true, get: function () { return utils_2.MARKDOWN_EOL; } });
10
8
  Object.defineProperty(exports, "MARKDOWN_EOP", { enumerable: true, get: function () { return utils_2.MARKDOWN_EOP; } });
11
9
  /**
@@ -29,10 +27,10 @@ exports.DEPRECATED = "deprecated";
29
27
  /** Copy fragment describing a non-null GraphQL modifier. */
30
28
  exports.NON_NULL = "non-null";
31
29
  /** Short identifier for the GraphQL language tag used in fenced blocks. */
32
- exports.GRAPHQL = "graphql";
30
+ const GRAPHQL = "graphql";
33
31
  /** Default placeholder when no schema description is provided. */
34
32
  exports.NO_DESCRIPTION_TEXT = "No description";
35
33
  /** Helper for inserting the code-block end delimiter in generated Markdown. */
36
34
  exports.MARKDOWN_EOC = `${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_CODE_SNIPPET}${utils_1.MARKDOWN_EOL}`;
37
35
  /** Helper for inserting the code-block start delimiter targeting GraphQL syntax. */
38
- exports.MARKDOWN_SOC = `${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_CODE_SNIPPET}${exports.GRAPHQL}${utils_1.MARKDOWN_EOL}`;
36
+ exports.MARKDOWN_SOC = `${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_CODE_SNIPPET}${GRAPHQL}${utils_1.MARKDOWN_EOL}`;
@@ -2,7 +2,7 @@
2
2
  * Provides utilities for handling and printing GraphQL directives in Markdown format
3
3
  * @module
4
4
  */
5
- import type { Badge, PrintTypeOptions, MDXString, CustomDirectiveMapItem, CustomDirectiveResolver, Maybe } from "@graphql-markdown/types";
5
+ import type { Badge, PrintTypeOptions, MDXString, CustomDirectiveMapItem, CustomDirectiveResolver, Maybe, PageSection } from "@graphql-markdown/types";
6
6
  /**
7
7
  * Resolves a custom directive using the provided resolver function
8
8
  * @param resolver - The resolver function name to execute
@@ -24,9 +24,9 @@ export declare const printCustomDirective: (type: unknown, constDirectiveOption:
24
24
  * Prints all custom directives for a type as a Markdown section
25
25
  * @param type - The GraphQL type to print directives for
26
26
  * @param options - General printing options
27
- * @returns Markdown string containing all formatted directives
27
+ * @returns A "Directives" PageSection, or undefined when no directives are printable
28
28
  */
29
- export declare const printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
29
+ export declare const printCustomDirectives: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection>;
30
30
  /**
31
31
  * Extracts custom tags from directives for a given type
32
32
  * @param type - The GraphQL type to get tags for
@@ -40,5 +40,5 @@ export declare const getCustomTags: (type: unknown, options: PrintTypeOptions) =
40
40
  * @param options - General printing options
41
41
  * @returns Formatted Markdown string of badges or empty string
42
42
  */
43
- export declare const printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
43
+ export declare const printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
44
44
  //# sourceMappingURL=directive.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../src/directive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,KAAK,EACL,gBAAgB,EAChB,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,EACN,MAAM,yBAAyB,CAAC;AASjC;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,6IAiBtC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,2GAoBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,sDA4BjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,uDAwBzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,kEAc3B,CAAC"}
1
+ {"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../src/directive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,KAAK,EACL,gBAAgB,EAChB,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,EACL,WAAW,EACZ,MAAM,yBAAyB,CAAC;AASjC;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,aAC3B,uBAAuB,QAC3B,OAAO,wBACS,sBAAsB,aACjC,KAAK,CAAC,MAAM,CAAC,KACvB,KAAK,CAAC,MAAM,CAYd,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,SACzB,OAAO,wBACS,sBAAsB,WACnC,gBAAgB,KACxB,KAAK,CAAC,MAAM,CAgBd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,SAC1B,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,WAAW,CA6BnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAClB,OAAO,WACJ,gBAAgB,KACxB,KAAK,EAqBP,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,SACpB,OAAO,WACJ,gBAAgB,KACxB,SAAS,GAAG,MAEd,CAAC"}
package/dist/directive.js CHANGED
@@ -49,12 +49,12 @@ exports.printCustomDirective = printCustomDirective;
49
49
  * Prints all custom directives for a type as a Markdown section
50
50
  * @param type - The GraphQL type to print directives for
51
51
  * @param options - General printing options
52
- * @returns Markdown string containing all formatted directives
52
+ * @returns A "Directives" PageSection, or undefined when no directives are printable
53
53
  */
54
54
  const printCustomDirectives = (type, options) => {
55
55
  const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
56
56
  if (!constDirectiveMap || Object.keys(constDirectiveMap).length === 0) {
57
- return "";
57
+ return undefined;
58
58
  }
59
59
  const directives = Object.values(constDirectiveMap)
60
60
  .map((constDirectiveOption) => {
@@ -64,10 +64,14 @@ const printCustomDirectives = (type, options) => {
64
64
  return value !== undefined;
65
65
  });
66
66
  if (directives.length === 0) {
67
- return "";
67
+ return undefined;
68
68
  }
69
69
  const content = directives.join(strings_1.MARKDOWN_EOP);
70
- return `${options_1.SectionLevels.LEVEL.repeat(3)} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
70
+ return {
71
+ title: "Directives",
72
+ content: `${content}${strings_1.MARKDOWN_EOP}`,
73
+ level: 3,
74
+ };
71
75
  };
72
76
  exports.printCustomDirectives = printCustomDirectives;
73
77
  /**
@@ -99,13 +103,6 @@ exports.getCustomTags = getCustomTags;
99
103
  * @returns Formatted Markdown string of badges or empty string
100
104
  */
101
105
  const printCustomTags = (type, options) => {
102
- const badges = (0, exports.getCustomTags)(type, options);
103
- if (badges.length === 0) {
104
- return "";
105
- }
106
- const formattedBadges = badges.map((badge) => {
107
- return (0, badge_1.printBadge)(badge, options);
108
- });
109
- return formattedBadges.join(" ");
106
+ return (0, badge_1.formatBadges)((0, exports.getCustomTags)(type, options), options);
110
107
  };
111
108
  exports.printCustomTags = printCustomTags;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Print type event classes.
3
+ *
4
+ * Event classes for print operations that allow handlers to modify the generated output.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { IPrintCodeEvent, IPrintTypeEvent, MDXString, Maybe, ComposePageTypeEventData, PageSections, PrintCodeEventData, PrintTypeEventData } from "@graphql-markdown/types";
9
+ export type { ComposePageTypeEventData, PageSection, PageSections, PrintCodeEventData, PrintTypeEventData, } from "@graphql-markdown/types";
10
+ import type { CancellableEventOptions } from "@graphql-markdown/utils";
11
+ import { DataOutputEvent } from "@graphql-markdown/utils";
12
+ /**
13
+ * Event emitted around code block generation for a GraphQL type.
14
+ *
15
+ * The `output` property is mutable, allowing event handlers to modify
16
+ * the generated code before it's included in the documentation.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * events.on(PrintTypeEvents.AFTER_PRINT_CODE, (event: PrintCodeEvent) => {
21
+ * // Add a comment to all generated code
22
+ * event.output = `# Auto-generated\n${event.output}`;
23
+ * });
24
+ * ```
25
+ *
26
+ * @category Events
27
+ */
28
+ export declare class PrintCodeEvent extends DataOutputEvent<PrintCodeEventData, string> implements IPrintCodeEvent {
29
+ constructor(data: PrintCodeEventData, initialOutput: string, options?: CancellableEventOptions);
30
+ }
31
+ /**
32
+ * Event emitted around full documentation generation for a GraphQL type.
33
+ *
34
+ * The `output` property is mutable, allowing event handlers to modify
35
+ * the complete generated documentation.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * events.on(PrintTypeEvents.AFTER_PRINT_TYPE, (event: PrintTypeEvent) => {
40
+ * // Add a footer to all type documentation
41
+ * event.output = `${event.output}\n\n---\nGenerated by GraphQL-Markdown`;
42
+ * });
43
+ * ```
44
+ *
45
+ * @category Events
46
+ */
47
+ export declare class PrintTypeEvent extends DataOutputEvent<PrintTypeEventData, Maybe<MDXString>> implements IPrintTypeEvent {
48
+ constructor(data: PrintTypeEventData, initialOutput: Maybe<MDXString>, options?: CancellableEventOptions);
49
+ }
50
+ /**
51
+ * Event emitted before composing page sections for a GraphQL type.
52
+ *
53
+ * This event fires after section content is generated and before sections are joined into final output.
54
+ * The `output` property contains an array of content section keys that will be included in the final page,
55
+ * in addition to fixed header sections (`header`, `metatags`, `mdxDeclaration`) which are managed separately
56
+ * by the printer and always prepended. Handlers can reorder, filter, or append to this array to control the
57
+ * structure of the content portion of the page.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * events.on(PrintTypeEvents.BEFORE_COMPOSE_PAGE_TYPE, (event: BeforeComposePageTypeEvent) => {
62
+ * // Move relations section before metadata
63
+ * const idx = event.output.indexOf('relations');
64
+ * if (idx > -1) {
65
+ * event.output.splice(idx, 1);
66
+ * const metaidx = event.output.indexOf('metadata');
67
+ * event.output.splice(metaidx, 0, 'relations');
68
+ * }
69
+ * });
70
+ * ```
71
+ *
72
+ * @category Events
73
+ */
74
+ export declare class BeforeComposePageTypeEvent extends DataOutputEvent<ComposePageTypeEventData, (keyof PageSections)[]> {
75
+ constructor(data: ComposePageTypeEventData, initialOutput: (keyof PageSections)[], options?: CancellableEventOptions);
76
+ }
77
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,SAAS,EACT,KAAK,EACL,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,wBAAwB,EACxB,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cACX,SAAQ,eAAe,CAAC,kBAAkB,EAAE,MAAM,CAClD,YAAW,eAAe;IAE1B,YACE,IAAI,EAAE,kBAAkB,EACxB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,uBAAuB,EAGlC;CACF;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cACX,SAAQ,eAAe,CAAC,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,CAC5D,YAAW,eAAe;IAE1B,YACE,IAAI,EAAE,kBAAkB,EACxB,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,EAC/B,OAAO,CAAC,EAAE,uBAAuB,EAGlC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,0BAA2B,SAAQ,eAAe,CAC7D,wBAAwB,EACxB,CAAC,MAAM,YAAY,CAAC,EAAE,CACvB;IACC,YACE,IAAI,EAAE,wBAAwB,EAC9B,aAAa,EAAE,CAAC,MAAM,YAAY,CAAC,EAAE,EACrC,OAAO,CAAC,EAAE,uBAAuB,EAGlC;CACF"}
package/dist/events.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /**
3
+ * Print type event classes.
4
+ *
5
+ * Event classes for print operations that allow handlers to modify the generated output.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.BeforeComposePageTypeEvent = exports.PrintTypeEvent = exports.PrintCodeEvent = void 0;
11
+ const utils_1 = require("@graphql-markdown/utils");
12
+ /**
13
+ * Event emitted around code block generation for a GraphQL type.
14
+ *
15
+ * The `output` property is mutable, allowing event handlers to modify
16
+ * the generated code before it's included in the documentation.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * events.on(PrintTypeEvents.AFTER_PRINT_CODE, (event: PrintCodeEvent) => {
21
+ * // Add a comment to all generated code
22
+ * event.output = `# Auto-generated\n${event.output}`;
23
+ * });
24
+ * ```
25
+ *
26
+ * @category Events
27
+ */
28
+ class PrintCodeEvent extends utils_1.DataOutputEvent {
29
+ constructor(data, initialOutput, options) {
30
+ super(data, initialOutput, options);
31
+ }
32
+ }
33
+ exports.PrintCodeEvent = PrintCodeEvent;
34
+ /**
35
+ * Event emitted around full documentation generation for a GraphQL type.
36
+ *
37
+ * The `output` property is mutable, allowing event handlers to modify
38
+ * the complete generated documentation.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * events.on(PrintTypeEvents.AFTER_PRINT_TYPE, (event: PrintTypeEvent) => {
43
+ * // Add a footer to all type documentation
44
+ * event.output = `${event.output}\n\n---\nGenerated by GraphQL-Markdown`;
45
+ * });
46
+ * ```
47
+ *
48
+ * @category Events
49
+ */
50
+ class PrintTypeEvent extends utils_1.DataOutputEvent {
51
+ constructor(data, initialOutput, options) {
52
+ super(data, initialOutput, options);
53
+ }
54
+ }
55
+ exports.PrintTypeEvent = PrintTypeEvent;
56
+ /**
57
+ * Event emitted before composing page sections for a GraphQL type.
58
+ *
59
+ * This event fires after section content is generated and before sections are joined into final output.
60
+ * The `output` property contains an array of content section keys that will be included in the final page,
61
+ * in addition to fixed header sections (`header`, `metatags`, `mdxDeclaration`) which are managed separately
62
+ * by the printer and always prepended. Handlers can reorder, filter, or append to this array to control the
63
+ * structure of the content portion of the page.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * events.on(PrintTypeEvents.BEFORE_COMPOSE_PAGE_TYPE, (event: BeforeComposePageTypeEvent) => {
68
+ * // Move relations section before metadata
69
+ * const idx = event.output.indexOf('relations');
70
+ * if (idx > -1) {
71
+ * event.output.splice(idx, 1);
72
+ * const metaidx = event.output.indexOf('metadata');
73
+ * event.output.splice(metaidx, 0, 'relations');
74
+ * }
75
+ * });
76
+ * ```
77
+ *
78
+ * @category Events
79
+ */
80
+ class BeforeComposePageTypeEvent extends utils_1.DataOutputEvent {
81
+ constructor(data, initialOutput, options) {
82
+ super(data, initialOutput, options);
83
+ }
84
+ }
85
+ exports.BeforeComposePageTypeEvent = BeforeComposePageTypeEvent;
@@ -1 +1 @@
1
- {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAIV,KAAK,EACL,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAwBjC;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,gFAgCrC,CAAC;AA4JF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,6DAmBxB,CAAC"}
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAIV,KAAK,EACL,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAwBjC;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,gCAGnC,gBAAgB,KAAG,KAAK,CAAC,oBAAoB,CA6B/C,CAAC;AAiKF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,SACjB,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,MAAM,CAgBd,CAAC"}