@graphql-markdown/printer-legacy 1.17.0 → 1.19.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.
@@ -1 +1 @@
1
- {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAEV,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,EACL,SAAS,EACT,WAAW,EAEX,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAiDjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwFrE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IACtC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,gBAAgB,0BAAoB;IAEpD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,qBAAqB,+BAAyB;IAE9D;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe,yBAAmB;IAElD,OAAO,CAAC,MAAM,CAAC,aAAa,CAA6B;IAEzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoC;IAE3D,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,YAAY,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAEpD;IAED;;OAEG;IACH,MAAM,KAAK,cAAc,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAEnD;IAED,MAAM,KAAK,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,EAE5D;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O,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAqH1B;IAEF;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAsDvC;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAO9C;IAEF;;;;;;OAMG;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
@@ -31,7 +31,6 @@ const TYPE_PAGE_SECTION_ORDER = [
31
31
  "tags",
32
32
  "description",
33
33
  "code",
34
- "customDirectives",
35
34
  "metadata",
36
35
  "example",
37
36
  "relations",
@@ -39,22 +38,21 @@ const TYPE_PAGE_SECTION_ORDER = [
39
38
  const graphql_1 = require("@graphql-markdown/graphql");
40
39
  const utils_1 = require("@graphql-markdown/utils");
41
40
  const relation_1 = require("./relation");
41
+ const badge_1 = require("./badge");
42
42
  const common_1 = require("./common");
43
- const directive_1 = require("./directive");
43
+ const decorator_1 = require("./decorator");
44
44
  const frontmatter_1 = require("./frontmatter");
45
45
  const graphql_2 = require("./graphql");
46
46
  const link_1 = require("./link");
47
47
  const strings_1 = require("./const/strings");
48
48
  const formatter_1 = require("./formatter");
49
49
  const options_1 = require("./const/options");
50
- const example_1 = require("./example");
51
50
  const events_1 = require("./events");
52
51
  /**
53
52
  * Default initialization options for the Printer class.
54
53
  * @internal
55
54
  */
56
55
  const DEFAULT_INIT_OPTIONS = {
57
- customDirectives: undefined,
58
56
  groups: undefined,
59
57
  sectionHeaderId: true,
60
58
  };
@@ -114,13 +112,9 @@ class Printer {
114
112
  */
115
113
  static printDescription = common_1.printDescription;
116
114
  /**
117
- * Prints custom directives
115
+ * Prints predicate-driven decorators
118
116
  */
119
- static printCustomDirectives = directive_1.printCustomDirectives;
120
- /**
121
- * Prints custom tags
122
- */
123
- static printCustomTags = directive_1.printCustomTags;
117
+ static printDecorators = decorator_1.printDecorators;
124
118
  static _eventEmitter;
125
119
  static _options;
126
120
  static _mdxDeclaration;
@@ -164,14 +158,14 @@ class Printer {
164
158
  * @param mdxDeclaration - Optional MDX import declaration
165
159
  * @param eventEmitter - Optional event emitter for print events interception
166
160
  */
167
- static async init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, deprecated, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, sectionHeaderId, } = DEFAULT_INIT_OPTIONS, formatter, mdxDeclaration, eventEmitter) {
161
+ static async init(schema, baseURL = "schema", linkRoot = "/", { decorators, deprecated, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, sectionHeaderId, } = DEFAULT_INIT_OPTIONS, formatter, mdxDeclaration, eventEmitter) {
168
162
  // Always update eventEmitter regardless of initialization state
169
163
  Printer.eventEmitter = eventEmitter ?? null;
170
164
  if (Printer.options === undefined) {
171
165
  Printer.options = {
172
166
  ...options_1.DEFAULT_OPTIONS,
173
167
  basePath: utils_1.pathUrl.join(linkRoot ?? "", baseURL ?? ""),
174
- customDirectives,
168
+ decorators,
175
169
  exampleSection: typeof printTypeOptions?.exampleSection === "object"
176
170
  ? printTypeOptions.exampleSection
177
171
  : undefined,
@@ -251,6 +245,18 @@ class Printer {
251
245
  }
252
246
  return strings_1.MARKDOWN_SOC + code.trim() + strings_1.MARKDOWN_EOC;
253
247
  };
248
+ /**
249
+ * Formats a single badge into MDX string format
250
+ *
251
+ * @param badge - Badge object containing text and optional classname
252
+ * @param options - Printer configuration options
253
+ * @returns Formatted MDX string, using the configured formatter's
254
+ * `formatMDXBadge` when set and falling back to the default formatter
255
+ * otherwise
256
+ */
257
+ static printBadge = (badge, options) => {
258
+ return (0, badge_1.printBadge)(badge, options);
259
+ };
254
260
  /**
255
261
  * Prints the GraphQL type definition as code block with event emission support.
256
262
  *
@@ -298,14 +304,7 @@ class Printer {
298
304
  * @returns Example page section or undefined when no example is available
299
305
  */
300
306
  static printExample = (type, options) => {
301
- const example = (0, example_1.printExample)(type, options);
302
- if (!example) {
303
- return undefined;
304
- }
305
- return {
306
- content: `${strings_1.MARKDOWN_SOC}${example}${strings_1.MARKDOWN_EOC}${strings_1.MARKDOWN_EOP}`,
307
- title: "Example",
308
- };
307
+ return (0, decorator_1.printDecorator)(type, (0, decorator_1.getExampleSectionDefinition)(), options);
309
308
  };
310
309
  /**
311
310
  * Prints metadata information for a GraphQL type
@@ -423,12 +422,20 @@ class Printer {
423
422
  // can add, remove, or reorder them at will.
424
423
  // See: https://github.com/graphql-markdown/graphql-markdown/issues/2954
425
424
  const code = await Printer.printCodeAsync(type, name, printTypeOptions);
426
- const customDirectives = Printer.printCustomDirectives(type, printTypeOptions);
427
- const tags = Printer.printCustomTags(type, printTypeOptions);
425
+ // `customDirective`'s `tag` handlers reach this line via the decorators
426
+ // pipeline (`printSlotDecorators`, not a dedicated call) — see
427
+ // `buildCustomDirectiveDecorators` in `./decorator`.
428
+ const tags = (0, decorator_1.printSlotDecorators)("tags", type, printTypeOptions)
429
+ .filter(Boolean)
430
+ .join(" ");
428
431
  const metadata = Printer.printTypeMetadata(type, printTypeOptions);
429
432
  const relations = Printer.printRelations(type, printTypeOptions);
430
433
  const example = Printer.printExample(type, printTypeOptions);
431
- // Create sections map for composition events
434
+ // Create sections map for composition events. The built-in "Directives"
435
+ // section reaches this map via the `...Printer.printDecorators(...)`
436
+ // spread below (it is `customDirective`'s adapter, unconditionally
437
+ // present under the reserved `customDirectives` id — see
438
+ // `buildCustomDirectiveDecorators`), not a dedicated field here.
432
439
  const sections = {
433
440
  header: { content: header },
434
441
  metatags: { content: metatags },
@@ -436,12 +443,12 @@ class Printer {
436
443
  tags: Printer.normalizePageSection(tags),
437
444
  description: Printer.normalizePageSection(description),
438
445
  code: Printer.normalizePageSection(code),
439
- customDirectives: Printer.normalizePageSection(customDirectives),
440
446
  metadata: Printer.normalizePageSection(metadata),
441
447
  example: Printer.normalizePageSection(example),
442
448
  relations: Printer.normalizePageSection(relations),
449
+ ...Printer.printDecorators(type, printTypeOptions),
443
450
  };
444
- let sectionOrder = [...TYPE_PAGE_SECTION_ORDER];
451
+ let sectionOrder = (0, decorator_1.getDecoratorsOrder)(TYPE_PAGE_SECTION_ORDER, printTypeOptions);
445
452
  // Emit BEFORE_COMPOSE_PAGE_TYPE event if emitter is configured
446
453
  if (Printer.eventEmitter) {
447
454
  const beforeComposeEvent = new events_1.BeforeComposePageTypeEvent({ type, name, options: printTypeOptions, sections }, sectionOrder);
@@ -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;AA8CjC;;;;;;;;GAQG;AAEH,eAAO,MAAM,gBAAgB,GAAI,CAAC,QAC1B,CAAC,WACE,gBAAgB,KACxB,SAAS,GAAG,MA6Cd,CAAC;AAEF;;;;;;;;GAQG;AAEH,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"}
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;AA8CjC;;;;;;;;GAQG;AAEH,eAAO,MAAM,gBAAgB,GAAI,CAAC,QAC1B,CAAC,WACE,gBAAgB,KACxB,SAAS,GAAG,MAmEd,CAAC;AAEF;;;;;;;;GAQG;AAEH,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"}
package/dist/section.js CHANGED
@@ -10,8 +10,8 @@ const utils_1 = require("@graphql-markdown/utils");
10
10
  const graphql_1 = require("@graphql-markdown/graphql");
11
11
  const common_1 = require("./common");
12
12
  const badge_1 = require("./badge");
13
+ const decorator_1 = require("./decorator");
13
14
  const link_1 = require("./link");
14
- const directive_1 = require("./directive");
15
15
  const strings_1 = require("./const/strings");
16
16
  const options_1 = require("./const/options");
17
17
  /**
@@ -50,11 +50,33 @@ const printSectionItem = (type, options) => {
50
50
  ...options,
51
51
  withAttributes: false,
52
52
  });
53
- const badges = (0, badge_1.printBadges)(type, options);
54
- const tags = (0, directive_1.printCustomTags)(type, options);
53
+ const badges = [
54
+ (0, badge_1.printBadges)(type, options),
55
+ ...(0, decorator_1.printSlotDecorators)("badges", type, options),
56
+ ]
57
+ .filter(Boolean)
58
+ .join(" ");
59
+ // `customDirective`'s `tag` handlers reach this line via the decorators
60
+ // pipeline (`printSlotDecorators`), not a dedicated call — see
61
+ // `buildCustomDirectiveDecorators` in `./decorator`.
62
+ const tags = (0, decorator_1.printSlotDecorators)("tags", type, options)
63
+ .filter(Boolean)
64
+ .join(" ");
55
65
  const parentTypeLink = (0, link_1.printParentLink)(type, options);
56
- const permalink = printPermalink(link.id, options);
57
- const metadata = [badges, tags, permalink].filter(Boolean).join(" ");
66
+ const permalink = [
67
+ printPermalink(link.id, options),
68
+ ...(0, decorator_1.printSlotDecorators)("permalink", type, options),
69
+ ]
70
+ .filter(Boolean)
71
+ .join(" ");
72
+ const metadata = [
73
+ badges,
74
+ tags,
75
+ permalink,
76
+ ...(0, decorator_1.printSlotDecorators)("metadata", type, options),
77
+ ]
78
+ .filter(Boolean)
79
+ .join(" ");
58
80
  const title = `${options_1.SectionLevels.LEVEL.repeat(level)} ${typeNameLink}${parentTypeLink} ${metadata} ${strings_1.MARKDOWN_EOL}`;
59
81
  const description = (0, common_1.printDescription)(type, options, "")
60
82
  .trim()
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "bugs": {
6
6
  "url": "https://github.com/graphql-markdown/graphql-markdown/issues"
7
7
  },
8
- "version": "1.17.0",
8
+ "version": "1.19.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -1,44 +0,0 @@
1
- /**
2
- * Provides utilities for handling and printing GraphQL directives in Markdown format
3
- * @module
4
- */
5
- import type { Badge, PrintTypeOptions, MDXString, CustomDirectiveMapItem, CustomDirectiveResolver, Maybe, PageSection } from "@graphql-markdown/types";
6
- /**
7
- * Resolves a custom directive using the provided resolver function
8
- * @param resolver - The resolver function name to execute
9
- * @param type - The GraphQL type to resolve the directive for
10
- * @param constDirectiveOption - The directive configuration options
11
- * @param fallback - Optional fallback value if resolution fails
12
- * @returns The resolved directive value or `fallback`/`undefined`
13
- */
14
- export declare const getCustomDirectiveResolver: (resolver: CustomDirectiveResolver, type: unknown, constDirectiveOption: CustomDirectiveMapItem, fallback?: Maybe<string>) => Maybe<string>;
15
- /**
16
- * Prints a custom directive as a Markdown string
17
- * @param type - The GraphQL type to print the directive for
18
- * @param constDirectiveOption - The directive configuration options
19
- * @param options - General printing options
20
- * @returns Formatted Markdown string for the directive or `undefined`
21
- */
22
- export declare const printCustomDirective: (type: unknown, constDirectiveOption: CustomDirectiveMapItem, options: PrintTypeOptions) => Maybe<string>;
23
- /**
24
- * Prints all custom directives for a type as a Markdown section
25
- * @param type - The GraphQL type to print directives for
26
- * @param options - General printing options
27
- * @returns A "Directives" PageSection, or undefined when no directives are printable
28
- */
29
- export declare const printCustomDirectives: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection>;
30
- /**
31
- * Extracts custom tags from directives for a given type
32
- * @param type - The GraphQL type to get tags for
33
- * @param options - General printing options
34
- * @returns Array of badge configurations from directive tags
35
- */
36
- export declare const getCustomTags: (type: unknown, options: PrintTypeOptions) => Badge[];
37
- /**
38
- * Prints custom directive tags as Markdown badges
39
- * @param type - The GraphQL type to print tags for
40
- * @param options - General printing options
41
- * @returns Formatted Markdown string of badges or empty string
42
- */
43
- export declare const printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
44
- //# sourceMappingURL=directive.d.ts.map
@@ -1 +0,0 @@
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;AAEH,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;AAEH,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 DELETED
@@ -1,110 +0,0 @@
1
- "use strict";
2
- /**
3
- * Provides utilities for handling and printing GraphQL directives in Markdown format
4
- * @module
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.printCustomTags = exports.getCustomTags = exports.printCustomDirectives = exports.printCustomDirective = exports.getCustomDirectiveResolver = void 0;
8
- const graphql_1 = require("@graphql-markdown/graphql");
9
- const strings_1 = require("./const/strings");
10
- const options_1 = require("./const/options");
11
- const link_1 = require("./link");
12
- const badge_1 = require("./badge");
13
- /**
14
- * Resolves a custom directive using the provided resolver function
15
- * @param resolver - The resolver function name to execute
16
- * @param type - The GraphQL type to resolve the directive for
17
- * @param constDirectiveOption - The directive configuration options
18
- * @param fallback - Optional fallback value if resolution fails
19
- * @returns The resolved directive value or `fallback`/`undefined`
20
- */
21
- const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallback) => {
22
- if (typeof constDirectiveOption.type !== "object" ||
23
- typeof constDirectiveOption[resolver] !== "function") {
24
- return fallback;
25
- }
26
- return constDirectiveOption[resolver](constDirectiveOption.type, type);
27
- };
28
- exports.getCustomDirectiveResolver = getCustomDirectiveResolver;
29
- /**
30
- * Prints a custom directive as a Markdown string
31
- * @param type - The GraphQL type to print the directive for
32
- * @param constDirectiveOption - The directive configuration options
33
- * @param options - General printing options
34
- * @returns Formatted Markdown string for the directive or `undefined`
35
- */
36
- // Used only by unit tests for direct whitebox coverage; not part of the production public API.
37
- const printCustomDirective = (type, constDirectiveOption, options) => {
38
- const typeNameLink = (0, link_1.printLink)(constDirectiveOption.type, {
39
- ...options,
40
- withAttributes: false,
41
- });
42
- const description = (0, exports.getCustomDirectiveResolver)("descriptor", type, constDirectiveOption);
43
- if (typeof description !== "string") {
44
- return undefined;
45
- }
46
- return `${options_1.SectionLevels.LEVEL.repeat(4)} ${typeNameLink}${strings_1.MARKDOWN_EOL} ${description}${strings_1.MARKDOWN_EOL} `;
47
- };
48
- exports.printCustomDirective = printCustomDirective;
49
- /**
50
- * Prints all custom directives for a type as a Markdown section
51
- * @param type - The GraphQL type to print directives for
52
- * @param options - General printing options
53
- * @returns A "Directives" PageSection, or undefined when no directives are printable
54
- */
55
- const printCustomDirectives = (type, options) => {
56
- const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
57
- if (!constDirectiveMap || Object.keys(constDirectiveMap).length === 0) {
58
- return undefined;
59
- }
60
- const directives = Object.values(constDirectiveMap)
61
- .map((constDirectiveOption) => {
62
- return (0, exports.printCustomDirective)(type, constDirectiveOption, options);
63
- })
64
- .filter((value) => {
65
- return value !== undefined;
66
- });
67
- if (directives.length === 0) {
68
- return undefined;
69
- }
70
- const content = directives.join(strings_1.MARKDOWN_EOP);
71
- return {
72
- title: "Directives",
73
- content: `${content}${strings_1.MARKDOWN_EOP}`,
74
- level: 3,
75
- };
76
- };
77
- exports.printCustomDirectives = printCustomDirectives;
78
- /**
79
- * Extracts custom tags from directives for a given type
80
- * @param type - The GraphQL type to get tags for
81
- * @param options - General printing options
82
- * @returns Array of badge configurations from directive tags
83
- */
84
- // Used only by unit tests for direct whitebox coverage; not part of the production public API.
85
- const getCustomTags = (type, options) => {
86
- const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
87
- if (typeof constDirectiveMap !== "object" ||
88
- constDirectiveMap === null ||
89
- Object.keys(constDirectiveMap).length === 0) {
90
- return [];
91
- }
92
- return Object.values(constDirectiveMap)
93
- .map((constDirectiveOption) => {
94
- return (0, exports.getCustomDirectiveResolver)("tag", type, constDirectiveOption);
95
- })
96
- .filter((value) => {
97
- return value !== undefined;
98
- });
99
- };
100
- exports.getCustomTags = getCustomTags;
101
- /**
102
- * Prints custom directive tags as Markdown badges
103
- * @param type - The GraphQL type to print tags for
104
- * @param options - General printing options
105
- * @returns Formatted Markdown string of badges or empty string
106
- */
107
- const printCustomTags = (type, options) => {
108
- return (0, badge_1.formatBadges)((0, exports.getCustomTags)(type, options), options);
109
- };
110
- exports.printCustomTags = printCustomTags;