@graphql-markdown/printer-legacy 1.12.2 → 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 +10 -10
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, SchemaEntitiesGroupMap } from "@graphql-markdown/types";
7
+ import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntity } 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<SchemaEntitiesGroupMap>) => Badge[];
19
+ export declare const getTypeBadges: (type: unknown, groups?: Maybe<Partial<Record<SchemaEntity, Record<string, Maybe<string>>>>>) => 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
@@ -30,4 +30,5 @@ export declare const printBadge: ({ text, classname }: Badge, options: PrintType
30
30
  * @param options - Options for printing/formatting the badges
31
31
  * @returns Formatted MDX string containing all badges, or empty string if no badges or badges disabled
32
32
  */
33
- export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
33
+ export declare const printBadges: (type: unknown, options: PrintTypeOptions) => string | MDXString;
34
+ //# sourceMappingURL=badge.d.ts.map
@@ -0,0 +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;AAejC,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,0GA6CzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,sEAUtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kEAuBvB,CAAC"}
package/dist/badge.js CHANGED
@@ -24,10 +24,10 @@ exports.CSS_BADGE_CLASSNAME = {
24
24
  * @returns Array of Badge objects containing text and optional classnames
25
25
  */
26
26
  const getTypeBadges = (type, groups) => {
27
- const badges = [];
28
27
  if (typeof type !== "object" || type === null) {
29
- return badges;
28
+ return [];
30
29
  }
30
+ const badges = [];
31
31
  const rootType = ("type" in type ? type.type : type);
32
32
  if ((0, graphql_1.isDeprecated)(type)) {
33
33
  badges.push({
package/dist/code.d.ts CHANGED
@@ -38,4 +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, indentationLevel?: number) => MDXString | string;
41
+ export declare const printCodeField: (type: unknown, options?: PrintTypeOptions | undefined, indentationLevel?: number) => string | MDXString;
42
+ //# sourceMappingURL=code.d.ts.map
@@ -0,0 +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"}
package/dist/code.js CHANGED
@@ -9,6 +9,7 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.printCodeField = exports.printCodeArguments = void 0;
11
11
  const graphql_1 = require("@graphql-markdown/graphql");
12
+ const utils_1 = require("@graphql-markdown/utils");
12
13
  const strings_1 = require("./const/strings");
13
14
  const link_1 = require("./link");
14
15
  /**
@@ -27,28 +28,26 @@ const link_1 = require("./link");
27
28
  * ```
28
29
  */
29
30
  const printCodeArguments = (type, indentationLevel = 1) => {
30
- if (typeof type !== "object" ||
31
- type === null ||
32
- !("args" in type) ||
33
- !Array.isArray(type.args) ||
34
- type.args.length === 0) {
31
+ if (!(0, utils_1.hasNonEmptyArrayProperty)(type, "args")) {
35
32
  return "";
36
33
  }
37
34
  const argIndentation = strings_1.MARKDOWN_CODE_INDENTATION.repeat(indentationLevel);
38
35
  const parentIndentation = indentationLevel === 1 ? "" : strings_1.MARKDOWN_CODE_INDENTATION;
39
- let code = `(${strings_1.MARKDOWN_EOL}`;
40
- code += type.args.reduce((r, v) => {
36
+ const argLines = type.args.map((v) => {
37
+ if (!(0, utils_1.hasProperty)(v, "type") || !(0, utils_1.hasProperty)(v, "name")) {
38
+ return "";
39
+ }
41
40
  const defaultValue = (0, graphql_1.getFormattedDefaultValue)(v);
42
- const hasDefaultValue = typeof defaultValue !== "undefined" && defaultValue !== null;
43
- const printedDefault = hasDefaultValue
44
- ? ` = ${(0, graphql_1.getFormattedDefaultValue)(v)}`
45
- : "";
41
+ let printedDefault = "";
42
+ if (defaultValue !== undefined && defaultValue !== null) {
43
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
44
+ printedDefault = ` = ${String(defaultValue)}`;
45
+ }
46
46
  const propType = String(v.type);
47
47
  const propName = String(v.name);
48
- return `${r}${argIndentation}${propName}: ${propType}${printedDefault}${strings_1.MARKDOWN_EOL}`;
49
- }, "");
50
- code += `${parentIndentation})`;
51
- return code;
48
+ return `${argIndentation}${propName}: ${propType}${printedDefault}`;
49
+ });
50
+ return [`(`, ...argLines, `${parentIndentation})`].join(strings_1.MARKDOWN_EOL);
52
51
  };
53
52
  exports.printCodeArguments = printCodeArguments;
54
53
  /**
@@ -68,17 +67,20 @@ exports.printCodeArguments = printCodeArguments;
68
67
  * ```
69
68
  */
70
69
  const printCodeField = (type, options, indentationLevel = 0) => {
71
- if (typeof type !== "object" || type === null || !("type" in type)) {
70
+ if (!(0, utils_1.hasProperty)(type, "type")) {
72
71
  return "";
73
72
  }
74
73
  if (!(0, link_1.hasPrintableDirective)(type, options)) {
75
74
  return "";
76
75
  }
77
- let code = `${(0, graphql_1.getTypeName)(type)}`;
78
- code += (0, exports.printCodeArguments)(type, indentationLevel + 1);
79
- code += `: ${(0, graphql_1.getTypeName)(type.type)}`;
80
- code += (0, graphql_1.isDeprecated)(type) ? ` @${strings_1.DEPRECATED}` : "";
81
- code += strings_1.MARKDOWN_EOL;
82
- return code;
76
+ const parts = [
77
+ (0, graphql_1.getTypeName)(type),
78
+ (0, exports.printCodeArguments)(type, indentationLevel + 1),
79
+ `: ${(0, graphql_1.getTypeName)(type.type)}`,
80
+ ];
81
+ if ((0, graphql_1.isDeprecated)(type)) {
82
+ parts.push(` @${strings_1.DEPRECATED}`);
83
+ }
84
+ return parts.join("") + strings_1.MARKDOWN_EOL;
83
85
  };
84
86
  exports.printCodeField = printCodeField;
package/dist/common.d.ts CHANGED
@@ -10,7 +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) => string;
13
+ export declare const printCustomDirectives: (type: unknown, options?: PrintTypeOptions | undefined) => string;
14
14
  /**
15
15
  * Formats a GraphQL type description or falls back to a default message.
16
16
  *
@@ -18,18 +18,16 @@ export declare const printCustomDirectives: (type: unknown, options?: PrintTypeO
18
18
  * @param replacement - Optional fallback text if no description exists
19
19
  * @returns Formatted description string or MDX content
20
20
  */
21
- export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => MDXString | string;
21
+ export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => string | MDXString;
22
22
  /**
23
23
  * Generates a warning message block in MDX format.
24
- * @param param0 - Warning configuration object
25
- * @param param0.text - The warning message text
26
- * @param param0.title - Optional title for the warning block
24
+ * @param warningConfig - Warning configuration object with `text` and optional `title` properties
27
25
  * @param options - Configuration options for printing
28
26
  * @returns Formatted warning message as MDX string
29
27
  */
30
28
  export declare const printWarning: ({ text, title }: {
31
- text?: string;
32
- title?: string;
29
+ text?: string | undefined;
30
+ title?: string | undefined;
33
31
  }, options: PrintTypeOptions) => string;
34
32
  /**
35
33
  * Prints deprecation information for a GraphQL type if it is deprecated.
@@ -45,4 +43,5 @@ export declare const printDeprecation: (type: unknown, options: PrintTypeOptions
45
43
  * @param noText - Optional text to display when no description exists
46
44
  * @returns Combined description, deprecation notices, and custom directives as MDX content
47
45
  */
48
- export declare const printDescription: (type: unknown, options: PrintTypeOptions, noText?: string) => MDXString | string;
46
+ export declare const printDescription: (type: unknown, options: PrintTypeOptions, noText?: string | undefined) => string | MDXString;
47
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +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"}
package/dist/common.js CHANGED
@@ -43,10 +43,10 @@ exports.printCustomDirectives = printCustomDirectives;
43
43
  * @returns Formatted description string or MDX content
44
44
  */
45
45
  const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) => {
46
- if (typeof type !== "object" || type === null) {
46
+ if (!(0, utils_1.isTypeObject)(type)) {
47
47
  return `${strings_1.MARKDOWN_EOP}${(0, utils_1.escapeMDX)(replacement)}`;
48
48
  }
49
- const description = "description" in type && typeof type.description === "string"
49
+ const description = (0, utils_1.hasStringProperty)(type, "description")
50
50
  ? type.description
51
51
  : replacement;
52
52
  return `${strings_1.MARKDOWN_EOP}${(0, utils_1.escapeMDX)(description)}`;
@@ -54,9 +54,7 @@ const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) =>
54
54
  exports.formatDescription = formatDescription;
55
55
  /**
56
56
  * Generates a warning message block in MDX format.
57
- * @param param0 - Warning configuration object
58
- * @param param0.text - The warning message text
59
- * @param param0.title - Optional title for the warning block
57
+ * @param warningConfig - Warning configuration object with `text` and optional `title` properties
60
58
  * @param options - Configuration options for printing
61
59
  * @returns Formatted warning message as MDX string
62
60
  */
@@ -9,7 +9,7 @@ export declare enum SectionLevels {
9
9
  LEVEL = "#"
10
10
  }
11
11
  export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<PrinterConfigPrintTypeOptions>;
12
- export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
12
+ export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "formatCategoryFolderName" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
13
13
  collapsible: Maybe<CollapsibleOption>;
14
14
  groups: Maybe<SchemaEntitiesGroupMap>;
15
15
  level: Maybe<SectionLevelValue>;
@@ -18,3 +18,4 @@ export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsib
18
18
  schema: Maybe<GraphQLSchema>;
19
19
  skipDocDirectives: GraphQLDirective[];
20
20
  };
21
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +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,CACtB,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;CAgBvC,CAAC"}
@@ -11,3 +11,4 @@ export declare const MARKDOWN_EOL: "\n";
11
11
  export declare const MARKDOWN_EOP: string;
12
12
  export declare const MARKDOWN_EOC: "\n```\n";
13
13
  export declare const MARKDOWN_SOC: "\n```graphql\n";
14
+ //# sourceMappingURL=strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/const/strings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,eAAO,MAAM,gBAAgB,EAAE,cAYrB,CAAC;AAEX,eAAO,MAAM,UAAU,cAAwB,CAAC;AAChD,eAAO,MAAM,QAAQ,YAAsB,CAAC;AAC5C,eAAO,MAAM,OAAO,WAAqB,CAAC;AAC1C,eAAO,MAAM,mBAAmB,kBAA4B,CAAC;AAC7D,eAAO,MAAM,qBAAqB,OAAiB,CAAC;AACpD,eAAO,MAAM,sBAAsB,OAAiB,CAAC;AAErD,eAAO,MAAM,yBAAyB,MAAgB,CAAC;AACvD,eAAO,MAAM,YAAY,MAAgB,CAAC;AAC1C,eAAO,MAAM,YAAY,QAAuC,CAAC;AACjE,eAAO,MAAM,YAAY,WAC0C,CAAC;AACpE,eAAO,MAAM,YAAY,kBACoD,CAAC"}
@@ -9,7 +9,7 @@ import type { Badge, PrintTypeOptions, MDXString, CustomDirectiveMapItem, Custom
9
9
  * @param type - The GraphQL type to resolve the directive for
10
10
  * @param constDirectiveOption - The directive configuration options
11
11
  * @param fallback - Optional fallback value if resolution fails
12
- * @returns The resolved directive value or fallback/undefined
12
+ * @returns The resolved directive value or `fallback`/`undefined`
13
13
  */
14
14
  export declare const getCustomDirectiveResolver: (resolver: CustomDirectiveResolver, type: unknown, constDirectiveOption: CustomDirectiveMapItem, fallback?: Maybe<string>) => Maybe<string>;
15
15
  /**
@@ -17,7 +17,7 @@ export declare const getCustomDirectiveResolver: (resolver: CustomDirectiveResol
17
17
  * @param type - The GraphQL type to print the directive for
18
18
  * @param constDirectiveOption - The directive configuration options
19
19
  * @param options - General printing options
20
- * @returns Formatted Markdown string for the directive or undefined
20
+ * @returns Formatted Markdown string for the directive or `undefined`
21
21
  */
22
22
  export declare const printCustomDirective: (type: unknown, constDirectiveOption: CustomDirectiveMapItem, options: PrintTypeOptions) => Maybe<string>;
23
23
  /**
@@ -40,4 +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) => MDXString | string;
43
+ export declare const printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
44
+ //# sourceMappingURL=directive.d.ts.map
@@ -0,0 +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,kEAe3B,CAAC"}
package/dist/directive.js CHANGED
@@ -16,11 +16,10 @@ const badge_1 = require("./badge");
16
16
  * @param type - The GraphQL type to resolve the directive for
17
17
  * @param constDirectiveOption - The directive configuration options
18
18
  * @param fallback - Optional fallback value if resolution fails
19
- * @returns The resolved directive value or fallback/undefined
19
+ * @returns The resolved directive value or `fallback`/`undefined`
20
20
  */
21
21
  const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallback) => {
22
- if (typeof constDirectiveOption === "undefined" ||
23
- typeof constDirectiveOption.type !== "object" ||
22
+ if (typeof constDirectiveOption.type !== "object" ||
24
23
  typeof constDirectiveOption[resolver] !== "function") {
25
24
  return fallback;
26
25
  }
@@ -32,7 +31,7 @@ exports.getCustomDirectiveResolver = getCustomDirectiveResolver;
32
31
  * @param type - The GraphQL type to print the directive for
33
32
  * @param constDirectiveOption - The directive configuration options
34
33
  * @param options - General printing options
35
- * @returns Formatted Markdown string for the directive or undefined
34
+ * @returns Formatted Markdown string for the directive or `undefined`
36
35
  */
37
36
  const printCustomDirective = (type, constDirectiveOption, options) => {
38
37
  const typeNameLink = (0, link_1.printLink)(constDirectiveOption.type, {
@@ -54,7 +53,7 @@ exports.printCustomDirective = printCustomDirective;
54
53
  */
55
54
  const printCustomDirectives = (type, options) => {
56
55
  const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
57
- if (!constDirectiveMap || Object.keys(constDirectiveMap).length < 1) {
56
+ if (!constDirectiveMap || Object.keys(constDirectiveMap).length === 0) {
58
57
  return "";
59
58
  }
60
59
  const directives = Object.values(constDirectiveMap)
@@ -62,7 +61,7 @@ const printCustomDirectives = (type, options) => {
62
61
  return (0, exports.printCustomDirective)(type, constDirectiveOption, options);
63
62
  })
64
63
  .filter((value) => {
65
- return typeof value !== "undefined";
64
+ return value !== undefined;
66
65
  });
67
66
  if (directives.length === 0) {
68
67
  return "";
@@ -81,7 +80,7 @@ const getCustomTags = (type, options) => {
81
80
  const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
82
81
  if (typeof constDirectiveMap !== "object" ||
83
82
  constDirectiveMap === null ||
84
- !Object.keys(constDirectiveMap).length) {
83
+ Object.keys(constDirectiveMap).length === 0) {
85
84
  return [];
86
85
  }
87
86
  return Object.values(constDirectiveMap)
@@ -89,7 +88,7 @@ const getCustomTags = (type, options) => {
89
88
  return (0, exports.getCustomDirectiveResolver)("tag", type, constDirectiveOption);
90
89
  })
91
90
  .filter((value) => {
92
- return typeof value !== "undefined";
91
+ return value !== undefined;
93
92
  });
94
93
  };
95
94
  exports.getCustomTags = getCustomTags;
package/dist/example.d.ts CHANGED
@@ -27,3 +27,4 @@ export declare const getDirectiveExampleOption: ({ exampleSection, schema, }: Pr
27
27
  * ```
28
28
  */
29
29
  export declare const printExample: (type: unknown, options: PrintTypeOptions) => Maybe<string>;
30
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Format event helpers for printer-legacy.
3
+ *
4
+ * This module provides helper functions to emit MDX format events and handle
5
+ * fallback to default formatters when no custom handlers are registered.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { AdmonitionType, Badge, CollapsibleOption, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
+ /**
11
+ * Default badge formatter.
12
+ */
13
+ export declare const formatMDXBadge: (badge: Badge) => MDXString;
14
+ /**
15
+ * Default admonition formatter.
16
+ */
17
+ export declare const formatMDXAdmonition: ({ text, title, type, icon }: AdmonitionType, _meta: Maybe<MetaInfo>) => MDXString;
18
+ /**
19
+ * Default bullet formatter.
20
+ */
21
+ export declare const formatMDXBullet: (text?: string) => MDXString;
22
+ /**
23
+ * Default details formatter.
24
+ */
25
+ export declare const formatMDXDetails: ({ dataOpen, }: CollapsibleOption) => MDXString;
26
+ /**
27
+ * Default frontmatter formatter.
28
+ */
29
+ export declare const formatMDXFrontmatter: (_props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
30
+ /**
31
+ * Default link formatter.
32
+ */
33
+ export declare const formatMDXLink: (link: TypeLink) => TypeLink;
34
+ /**
35
+ * Default name entity formatter.
36
+ */
37
+ export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
38
+ /**
39
+ * Default specified-by link formatter.
40
+ */
41
+ export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
42
+ //# sourceMappingURL=format-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-helpers.d.ts","sourceRoot":"","sources":["../src/format-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AASjC;;GAEG;AACH,eAAO,MAAM,cAAc,6BAE1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,oFAK/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,8BAE3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,iDAI5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,8EAShC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,8BAEzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,yDAQ/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,4BAEpC,CAAC"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * Format event helpers for printer-legacy.
4
+ *
5
+ * This module provides helper functions to emit MDX format events and handle
6
+ * fallback to default formatters when no custom handlers are registered.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
12
+ // Import default formatters
13
+ const strings_1 = require("./const/strings");
14
+ /**
15
+ * Default badge formatter.
16
+ */
17
+ const formatMDXBadge = (badge) => {
18
+ return `<mark class="gqlmd-mdx-badge">${badge.text}</mark>`;
19
+ };
20
+ exports.formatMDXBadge = formatMDXBadge;
21
+ /**
22
+ * Default admonition formatter.
23
+ */
24
+ const formatMDXAdmonition = ({ text, title, type, icon }, _meta) => {
25
+ return `${strings_1.MARKDOWN_EOP}<fieldset class="gqlmd-mdx-admonition-fieldset">${strings_1.MARKDOWN_EOL}<legend class="gqlmd-mdx-admonition-legend"><span class="gqlmd-mdx-admonition-legend-type gqlmd-mdx-admonition-legend-type-${type.toLocaleLowerCase()}">${icon ?? type.toUpperCase()} ${title}</span></legend>${strings_1.MARKDOWN_EOL}<span>${text}</span>${strings_1.MARKDOWN_EOL}</fieldset>`;
26
+ };
27
+ exports.formatMDXAdmonition = formatMDXAdmonition;
28
+ /**
29
+ * Default bullet formatter.
30
+ */
31
+ const formatMDXBullet = (text = "") => {
32
+ return `<span class="gqlmd-mdx-bullet">&nbsp;●&nbsp;</span>${text}`;
33
+ };
34
+ exports.formatMDXBullet = formatMDXBullet;
35
+ /**
36
+ * Default details formatter.
37
+ */
38
+ const formatMDXDetails = ({ dataOpen, }) => {
39
+ return `${strings_1.MARKDOWN_EOP}<details class="gqlmd-mdx-details">${strings_1.MARKDOWN_EOL}<summary class="gqlmd-mdx-details-summary"><span className="gqlmd-mdx-details-summary-open">${dataOpen.toUpperCase()}</span></summary>${strings_1.MARKDOWN_EOL}</details>${strings_1.MARKDOWN_EOP}`;
40
+ };
41
+ exports.formatMDXDetails = formatMDXDetails;
42
+ /**
43
+ * Default frontmatter formatter.
44
+ */
45
+ const formatMDXFrontmatter = (_props, formatted) => {
46
+ return formatted
47
+ ? [strings_1.FRONT_MATTER_DELIMITER, ...formatted, strings_1.FRONT_MATTER_DELIMITER].join(strings_1.MARKDOWN_EOL)
48
+ : "";
49
+ };
50
+ exports.formatMDXFrontmatter = formatMDXFrontmatter;
51
+ /**
52
+ * Default link formatter.
53
+ */
54
+ const formatMDXLink = (link) => {
55
+ return link;
56
+ };
57
+ exports.formatMDXLink = formatMDXLink;
58
+ /**
59
+ * Default name entity formatter.
60
+ */
61
+ const formatMDXNameEntity = (name, parentType) => {
62
+ const parentName = parentType
63
+ ? `<code class="gqlmd-mdx-entity-parent">${parentType}</code>.`
64
+ : "";
65
+ return `<span class="gqlmd-mdx-entity">${parentName}<code class="gqlmd-mdx-entity-name">${name}</code></span>`;
66
+ };
67
+ exports.formatMDXNameEntity = formatMDXNameEntity;
68
+ /**
69
+ * Default specified-by link formatter.
70
+ */
71
+ const formatMDXSpecifiedByLink = (url) => {
72
+ return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
73
+ };
74
+ exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Formatter factories for GraphQL documentation output.
3
+ *
4
+ * Provides factory functions to create formatters for different output targets.
5
+ * The default formatter produces HTML-like markup suitable for most Markdown processors.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { Formatter } from "@graphql-markdown/types";
10
+ /**
11
+ * Creates a default formatter for documentation output.
12
+ *
13
+ * The default formatter produces HTML-like markup with CSS classes
14
+ * that can be styled with custom CSS. This is suitable for most
15
+ * Markdown processors that support inline HTML.
16
+ *
17
+ * @returns A complete Formatter implementation
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { createDefaultFormatter } from '@graphql-markdown/printer-legacy';
22
+ *
23
+ * const formatter = createDefaultFormatter();
24
+ * const badge = formatter.formatMDXBadge({ text: 'Required' });
25
+ * ```
26
+ */
27
+ export declare const createDefaultFormatter: () => Formatter;
28
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAIV,SAAS,EAMV,MAAM,yBAAyB,CAAC;AAQjC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,iBAkDlC,CAAC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * Formatter factories for GraphQL documentation output.
4
+ *
5
+ * Provides factory functions to create formatters for different output targets.
6
+ * The default formatter produces HTML-like markup suitable for most Markdown processors.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.createDefaultFormatter = void 0;
12
+ const strings_1 = require("./const/strings");
13
+ /**
14
+ * Creates a default formatter for documentation output.
15
+ *
16
+ * The default formatter produces HTML-like markup with CSS classes
17
+ * that can be styled with custom CSS. This is suitable for most
18
+ * Markdown processors that support inline HTML.
19
+ *
20
+ * @returns A complete Formatter implementation
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { createDefaultFormatter } from '@graphql-markdown/printer-legacy';
25
+ *
26
+ * const formatter = createDefaultFormatter();
27
+ * const badge = formatter.formatMDXBadge({ text: 'Required' });
28
+ * ```
29
+ */
30
+ const createDefaultFormatter = () => {
31
+ return {
32
+ formatMDXBadge: (badge) => {
33
+ return `<mark class="gqlmd-mdx-badge">${badge.text}</mark>`;
34
+ },
35
+ formatMDXAdmonition: ({ text, title, type, icon }, _meta) => {
36
+ return `${strings_1.MARKDOWN_EOP}<fieldset class="gqlmd-mdx-admonition-fieldset">${strings_1.MARKDOWN_EOL}<legend class="gqlmd-mdx-admonition-legend"><span class="gqlmd-mdx-admonition-legend-type gqlmd-mdx-admonition-legend-type-${type.toLocaleLowerCase()}">${icon ?? type.toUpperCase()} ${title}</span></legend>${strings_1.MARKDOWN_EOL}<span>${text}</span>${strings_1.MARKDOWN_EOL}</fieldset>`;
37
+ },
38
+ formatMDXBullet: (text = "") => {
39
+ return `<span class="gqlmd-mdx-bullet">&nbsp;●&nbsp;</span>${text}`;
40
+ },
41
+ formatMDXDetails: ({ dataOpen }) => {
42
+ return `${strings_1.MARKDOWN_EOP}<details class="gqlmd-mdx-details">${strings_1.MARKDOWN_EOL}<summary class="gqlmd-mdx-details-summary"><span className="gqlmd-mdx-details-summary-open">${dataOpen.toUpperCase()}</span></summary>${strings_1.MARKDOWN_EOL}</details>${strings_1.MARKDOWN_EOP}`;
43
+ },
44
+ formatMDXFrontmatter: (_props, formatted) => {
45
+ return formatted
46
+ ? [strings_1.FRONT_MATTER_DELIMITER, ...formatted, strings_1.FRONT_MATTER_DELIMITER].join(strings_1.MARKDOWN_EOL)
47
+ : "";
48
+ },
49
+ formatMDXLink: (link) => {
50
+ return link;
51
+ },
52
+ formatMDXNameEntity: (name, parentType) => {
53
+ const parentName = parentType
54
+ ? `<code class="gqlmd-mdx-entity-parent">${parentType}</code>.`
55
+ : "";
56
+ return `<span class="gqlmd-mdx-entity">${parentName}<code class="gqlmd-mdx-entity-name">${name}</code></span>`;
57
+ },
58
+ formatMDXSpecifiedByLink: (url) => {
59
+ return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
60
+ },
61
+ };
62
+ };
63
+ exports.createDefaultFormatter = createDefaultFormatter;
@@ -13,3 +13,4 @@ import type { FrontMatterOptions, Maybe, PrintTypeOptions } from "@graphql-markd
13
13
  * @returns Formatted frontmatter string, or empty string if formatting is disabled
14
14
  */
15
15
  export declare const printFrontMatter: (title: string, props: Maybe<FrontMatterOptions>, options: PrintTypeOptions) => string;
16
+ //# sourceMappingURL=frontmatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACV,kBAAkB,EAClB,KAAK,EACL,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,wFAY5B,CAAC"}
@@ -13,7 +13,7 @@ import type { PrintDirectiveOptions, GraphQLDirective, MDXString } from "@graphq
13
13
  * @param options - Configuration options for printing directive metadata
14
14
  * @returns Formatted metadata string in MDX format or empty string if no arguments
15
15
  */
16
- export declare const printDirectiveMetadata: (type: GraphQLDirective, options: PrintDirectiveOptions) => MDXString | string;
16
+ export declare const printDirectiveMetadata: (type: GraphQLDirective, options: PrintDirectiveOptions) => string | MDXString;
17
17
  /**
18
18
  * Generates a string representation of a complete GraphQL directive definition.
19
19
  *
@@ -21,4 +21,5 @@ export declare const printDirectiveMetadata: (type: GraphQLDirective, options: P
21
21
  * @param options - Configuration options for printing the directive (optional)
22
22
  * @returns A formatted string containing the complete directive definition
23
23
  */
24
- export declare const printCodeDirective: (type: GraphQLDirective, options?: PrintDirectiveOptions) => string;
24
+ export declare const printCodeDirective: (type: GraphQLDirective, options?: PrintDirectiveOptions | undefined) => string;
25
+ //# sourceMappingURL=directive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../../src/graphql/directive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACV,MAAM,yBAAyB,CAAC;AA4BjC;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,gFASlC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,iFAU9B,CAAC"}
@@ -18,7 +18,7 @@ const code_1 = require("../code");
18
18
  * @returns A formatted string of directive locations or empty string if no locations defined
19
19
  */
20
20
  const printCodeDirectiveLocation = (type) => {
21
- if (typeof type.locations === "undefined" || type.locations.length === 0) {
21
+ if (type.locations === undefined || type.locations.length === 0) {
22
22
  return "";
23
23
  }
24
24
  let code = ` on `;
@@ -10,7 +10,7 @@ import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
10
10
  * @param options - Options for printing the type
11
11
  * @returns A string containing the metadata section in MDX format, or empty string if type is not an enum
12
12
  */
13
- export declare const printEnumMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
13
+ export declare const printEnumMetadata: (type: unknown, options: PrintTypeOptions) => string | MDXString;
14
14
  /**
15
15
  * Generates a GraphQL SDL code block for an enum type.
16
16
  *
@@ -18,4 +18,5 @@ export declare const printEnumMetadata: (type: unknown, options: PrintTypeOption
18
18
  * @param options - Optional printing options that control directive handling
19
19
  * @returns A string containing the enum type definition in GraphQL SDL, or empty string if type is not an enum
20
20
  */
21
- export declare const printCodeEnum: (type: unknown, options?: PrintTypeOptions) => string;
21
+ export declare const printCodeEnum: (type: unknown, options?: PrintTypeOptions | undefined) => string;
22
+ //# sourceMappingURL=enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/graphql/enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAY3E;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,kEAS7B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,mEA0BzB,CAAC"}
@@ -6,3 +6,4 @@ export * from "./object";
6
6
  export * from "./operation";
7
7
  export * from "./scalar";
8
8
  export * from "./union";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import type { PrintTypeOptions } from "@graphql-markdown/types";
2
- export declare const printInputMetadata: (type: unknown, options: PrintTypeOptions) => string;
2
+ export { printObjectMetadata as printInputMetadata } from "./object";
3
3
  export declare const printCodeInput: (type: unknown, options: PrintTypeOptions) => string;
4
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/graphql/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,EAAE,mBAAmB,IAAI,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAErE,eAAO,MAAM,cAAc,sDAK1B,CAAC"}