@graphql-markdown/core 1.20.0 → 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/config.d.ts +9 -57
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +42 -60
  4. package/dist/const/patterns.d.ts.map +1 -1
  5. package/dist/diff.d.ts.map +1 -1
  6. package/dist/directives/normalize.d.ts +2 -2
  7. package/dist/directives/normalize.d.ts.map +1 -1
  8. package/dist/directives/validation.d.ts.map +1 -1
  9. package/dist/directives/validation.js +4 -0
  10. package/dist/event-emitter.d.ts.map +1 -1
  11. package/dist/event-handlers.d.ts.map +1 -1
  12. package/dist/event-map.d.ts +1 -0
  13. package/dist/event-map.d.ts.map +1 -1
  14. package/dist/event-map.js +2 -0
  15. package/dist/events/diff-events.d.ts.map +1 -1
  16. package/dist/events/generate-index-metafile-events.d.ts.map +1 -1
  17. package/dist/events/index.d.ts +2 -1
  18. package/dist/events/index.d.ts.map +1 -1
  19. package/dist/events/index.js +20 -14
  20. package/dist/events/print-type-events.d.ts.map +1 -1
  21. package/dist/events/render-files-events.d.ts +13 -0
  22. package/dist/events/render-files-events.d.ts.map +1 -0
  23. package/dist/events/render-files-events.js +15 -0
  24. package/dist/events/render-files.d.ts +26 -0
  25. package/dist/events/render-files.d.ts.map +1 -0
  26. package/dist/events/render-files.js +20 -0
  27. package/dist/events/render-homepage-events.d.ts.map +1 -1
  28. package/dist/events/render-root-types-events.d.ts.map +1 -1
  29. package/dist/events/render-type-entities-events.d.ts.map +1 -1
  30. package/dist/events/render-type-entities.d.ts +4 -0
  31. package/dist/events/render-type-entities.d.ts.map +1 -1
  32. package/dist/events/schema-events.d.ts.map +1 -1
  33. package/dist/generator.d.ts +3 -14
  34. package/dist/generator.d.ts.map +1 -1
  35. package/dist/generator.js +19 -10
  36. package/dist/graphql-config.d.ts +0 -5
  37. package/dist/graphql-config.d.ts.map +1 -1
  38. package/dist/graphql-config.js +8 -4
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +13 -13
  42. package/dist/printer.d.ts +9 -10
  43. package/dist/printer.d.ts.map +1 -1
  44. package/dist/printer.js +11 -20
  45. package/dist/renderer.d.ts +4 -4
  46. package/dist/renderer.d.ts.map +1 -1
  47. package/dist/renderer.js +11 -4
  48. package/package.json +10 -13
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Render files event class.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { CancellableEventOptions } from "@graphql-markdown/utils";
7
+ import { DataEvent } from "@graphql-markdown/utils";
8
+ /**
9
+ * Event emitted after all output files (entities + homepage) have been written.
10
+ *
11
+ * @category Events
12
+ */
13
+ export declare class RenderFilesEvent extends DataEvent<{
14
+ baseURL: string;
15
+ outputDir: string;
16
+ rootDir: string;
17
+ pages: unknown;
18
+ }> {
19
+ constructor(data: {
20
+ baseURL: string;
21
+ outputDir: string;
22
+ rootDir: string;
23
+ pages: unknown;
24
+ }, options?: CancellableEventOptions);
25
+ }
26
+ //# sourceMappingURL=render-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-files.d.ts","sourceRoot":"","sources":["../../src/events/render-files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,SAAS,CAAC;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;IACA,YACE,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,OAAO,CAAC;KAChB,EACD,OAAO,CAAC,EAAE,uBAAuB,EAGlC;CACF"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * Render files event class.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.RenderFilesEvent = void 0;
9
+ const utils_1 = require("@graphql-markdown/utils");
10
+ /**
11
+ * Event emitted after all output files (entities + homepage) have been written.
12
+ *
13
+ * @category Events
14
+ */
15
+ class RenderFilesEvent extends utils_1.DataEvent {
16
+ constructor(data, options) {
17
+ super(data, options);
18
+ }
19
+ }
20
+ exports.RenderFilesEvent = RenderFilesEvent;
@@ -1 +1 @@
1
- {"version":3,"file":"render-homepage-events.d.ts","sourceRoot":"","sources":["../../src/events/render-homepage-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC/B,wCAAwC;;IAExC,uCAAuC;;CAE/B,CAAC"}
1
+ {"version":3,"file":"render-homepage-events.d.ts","sourceRoot":"","sources":["../../src/events/render-homepage-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC/B,wCAAwC;aACxC,aAAa,EAAE,6BAA6B;IAC5C,uCAAuC;aACvC,YAAY,EAAE,4BAA4B;CAClC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render-root-types-events.d.ts","sourceRoot":"","sources":["../../src/events/render-root-types-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAChC,0CAA0C;;IAE1C,yCAAyC;;CAEjC,CAAC"}
1
+ {"version":3,"file":"render-root-types-events.d.ts","sourceRoot":"","sources":["../../src/events/render-root-types-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAChC,0CAA0C;aAC1C,aAAa,EAAE,8BAA8B;IAC7C,yCAAyC;aACzC,YAAY,EAAE,6BAA6B;CACnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render-type-entities-events.d.ts","sourceRoot":"","sources":["../../src/events/render-type-entities-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;IACnC,6CAA6C;;IAE7C,4CAA4C;;CAEpC,CAAC"}
1
+ {"version":3,"file":"render-type-entities-events.d.ts","sourceRoot":"","sources":["../../src/events/render-type-entities-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;IACnC,6CAA6C;aAC7C,aAAa,EAAE,iCAAiC;IAChD,4CAA4C;aAC5C,YAAY,EAAE,gCAAgC;CACtC,CAAC"}
@@ -11,12 +11,16 @@ import { DataEvent } from "@graphql-markdown/utils";
11
11
  * @category Events
12
12
  */
13
13
  export declare class RenderTypeEntitiesEvent extends DataEvent<{
14
+ baseURL: string;
14
15
  name: string;
15
16
  filePath: string;
17
+ outputDir: string;
16
18
  }> {
17
19
  constructor(data: {
20
+ baseURL: string;
18
21
  name: string;
19
22
  filePath: string;
23
+ outputDir: string;
20
24
  }, options?: CancellableEventOptions);
21
25
  }
22
26
  //# sourceMappingURL=render-type-entities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-type-entities.d.ts","sourceRoot":"","sources":["../../src/events/render-type-entities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,SAAS,CAAC;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;IACA,YACE,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,EACD,OAAO,CAAC,EAAE,uBAAuB,EAGlC;CACF"}
1
+ {"version":3,"file":"render-type-entities.d.ts","sourceRoot":"","sources":["../../src/events/render-type-entities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,SAAS,CAAC;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;IACA,YACE,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,EACD,OAAO,CAAC,EAAE,uBAAuB,EAGlC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema-events.d.ts","sourceRoot":"","sources":["../../src/events/schema-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB,4CAA4C;;IAE5C,2CAA2C;;IAE3C,4CAA4C;;IAE5C,2CAA2C;;CAEnC,CAAC"}
1
+ {"version":3,"file":"schema-events.d.ts","sourceRoot":"","sources":["../../src/events/schema-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB,4CAA4C;aAC5C,WAAW,EAAE,mBAAmB;IAChC,2CAA2C;aAC3C,UAAU,EAAE,kBAAkB;IAC9B,4CAA4C;aAC5C,UAAU,EAAE,kBAAkB;IAC9B,2CAA2C;aAC3C,SAAS,EAAE,iBAAiB;CACpB,CAAC"}
@@ -8,17 +8,6 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  import type { DirectiveName, Formatter, GeneratorOptions, GraphQLDirective, GraphQLSchema, LoaderOption, Maybe, MetaInfo, PackageName, TypeDiffMethod } from "@graphql-markdown/types";
11
- /**
12
- * Supported file extensions for generated documentation files.
13
- *
14
- * @remarks
15
- * - MDX: MDX file extension (.mdx) for React component-enabled markdown
16
- * - MD: Standard markdown file extension (.md)
17
- */
18
- export declare const FILE_EXTENSION: {
19
- readonly MDX: ".mdx";
20
- readonly MD: ".md";
21
- };
22
11
  /**
23
12
  * Asynchronously loads an MDX module dynamically.
24
13
  *
@@ -29,7 +18,7 @@ export declare const FILE_EXTENSION: {
29
18
  *
30
19
  * @internal
31
20
  */
32
- export declare const loadMDXModule: (mdxParser: Maybe<string | PackageName>) => Promise<unknown>;
21
+ export declare const loadMDXModule: (mdxParser: Maybe<PackageName | string>) => Promise<unknown>;
33
22
  /**
34
23
  * Gets a property from an MDX module, checking both the module directly and `module.default`.
35
24
  *
@@ -97,7 +86,7 @@ export declare const checkSchemaDifferences: (schema: GraphQLSchema, schemaLocat
97
86
  * @returns A tuple containing two arrays: the first with resolved "only" directives,
98
87
  * the second with resolved "skip" directives. Only defined directives are included.
99
88
  */
100
- export declare const resolveSkipAndOnlyDirectives: (onlyDocDirective: Maybe<DirectiveName[] | DirectiveName>, skipDocDirective: Maybe<DirectiveName[] | DirectiveName>, schema: GraphQLSchema) => GraphQLDirective[][];
89
+ export declare const resolveSkipAndOnlyDirectives: (onlyDocDirective: Maybe<DirectiveName | DirectiveName[]>, skipDocDirective: Maybe<DirectiveName | DirectiveName[]>, schema: GraphQLSchema) => GraphQLDirective[][];
101
90
  /**
102
91
  * Main entry point for generating Markdown documentation from a GraphQL schema.
103
92
  *
@@ -111,5 +100,5 @@ export declare const resolveSkipAndOnlyDirectives: (onlyDocDirective: Maybe<Dire
111
100
  * @param options - Complete configuration for the documentation generation
112
101
  * @returns Promise that resolves when documentation is fully generated
113
102
  */
114
- export declare const generateDocFromSchema: ({ baseURL, customDirective, diffMethod, docOptions, force, groupByDirective, homepageLocation, linkRoot, loaders: loadersList, loggerModule, mdxParser, metatags, onlyDocDirective, outputDir, prettify, printer: printerModule, printTypeOptions, schemaLocation, skipDocDirective, tmpDir, }: GeneratorOptions) => Promise<void>;
103
+ export declare const generateDocFromSchema: ({ baseURL, customDirective, diffMethod, docOptions, force, groupByDirective, homepageLocation, linkRoot, loaders: loadersList, loggerModule, formatter, metatags, onlyDocDirective, outputDir, prettify, printTypeOptions, schemaLocation, skipDocDirective, tmpDir, }: GeneratorOptions) => Promise<void>;
115
104
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAEV,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,WAAW,EAEX,cAAc,EAEf,MAAM,yBAAyB,CAAC;AA+BjC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAgBX;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,8DAczB,CAAC;AAgBF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,4DAsBrC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,yEAkDrC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,6FAe7B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,wHAgBlC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,qKA0BxC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,qUAwNjC,CAAC"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings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
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.generateDocFromSchema = exports.resolveSkipAndOnlyDirectives = exports.checkSchemaDifferences = exports.loadGraphqlSchema = exports.getFormatterFromMDXModule = exports.getMDXModuleProperty = exports.loadMDXModule = exports.FILE_EXTENSION = void 0;
36
+ exports.generateDocFromSchema = exports.resolveSkipAndOnlyDirectives = exports.checkSchemaDifferences = exports.loadGraphqlSchema = exports.getFormatterFromMDXModule = exports.getMDXModuleProperty = exports.loadMDXModule = void 0;
37
37
  const logger_1 = __importStar(require("@graphql-markdown/logger"));
38
38
  const graphql_1 = require("@graphql-markdown/graphql");
39
39
  const utils_1 = require("@graphql-markdown/utils");
40
+ const node_path_1 = require("node:path");
40
41
  const config_1 = require("./config");
41
42
  const diff_1 = require("./diff");
42
43
  const printer_1 = require("./printer");
@@ -51,7 +52,7 @@ const event_handlers_1 = require("./event-handlers");
51
52
  * - MDX: MDX file extension (.mdx) for React component-enabled markdown
52
53
  * - MD: Standard markdown file extension (.md)
53
54
  */
54
- exports.FILE_EXTENSION = {
55
+ const FILE_EXTENSION = {
55
56
  MDX: ".mdx",
56
57
  MD: ".md",
57
58
  };
@@ -213,6 +214,8 @@ exports.loadGraphqlSchema = loadGraphqlSchema;
213
214
  * @remarks
214
215
  * When no changes are detected, a log message is generated indicating that the schema is unchanged.
215
216
  */
217
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
218
+ // fallow-ignore-next-line unused-export
216
219
  const checkSchemaDifferences = async (schema, schemaLocation, diffMethod, tmpDir) => {
217
220
  let changed = true;
218
221
  if (diffMethod !== config_1.DiffMethod.NONE) {
@@ -237,6 +240,8 @@ exports.checkSchemaDifferences = checkSchemaDifferences;
237
240
  * @returns A tuple containing two arrays: the first with resolved "only" directives,
238
241
  * the second with resolved "skip" directives. Only defined directives are included.
239
242
  */
243
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
244
+ // fallow-ignore-next-line unused-export
240
245
  const resolveSkipAndOnlyDirectives = (onlyDocDirective, skipDocDirective, schema) => {
241
246
  return [onlyDocDirective, skipDocDirective].map((directive) => {
242
247
  // Normalize to array and filter out null/undefined
@@ -273,10 +278,10 @@ exports.resolveSkipAndOnlyDirectives = resolveSkipAndOnlyDirectives;
273
278
  * @param options - Complete configuration for the documentation generation
274
279
  * @returns Promise that resolves when documentation is fully generated
275
280
  */
276
- const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, docOptions, force, groupByDirective, homepageLocation, linkRoot, loaders: loadersList, loggerModule, mdxParser, metatags, onlyDocDirective, outputDir, prettify, printer: printerModule, printTypeOptions, schemaLocation, skipDocDirective, tmpDir, }) => {
281
+ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, docOptions, force, groupByDirective, homepageLocation, linkRoot, loaders: loadersList, loggerModule, formatter, metatags, onlyDocDirective, outputDir, prettify, printTypeOptions, schemaLocation, skipDocDirective, tmpDir, }) => {
277
282
  const start = process.hrtime.bigint();
278
283
  await (0, logger_1.default)(loggerModule);
279
- const mdxModule = await (0, exports.loadMDXModule)(mdxParser);
284
+ const mdxModule = await (0, exports.loadMDXModule)(formatter);
280
285
  // Register MDX lifecycle event handlers if mdxModule loaded successfully
281
286
  // This must be called BEFORE getEvents() because it resets the singleton
282
287
  (0, event_handlers_1.registerMDXEventHandlers)(mdxModule);
@@ -307,12 +312,10 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
307
312
  const customDirectives = (0, graphql_1.getCustomDirectives)(rootTypes, customDirective);
308
313
  const groups = (0, graphql_1.getGroups)(rootTypes, groupByDirective);
309
314
  // Extract formatter from the MDX module (for direct function calls)
310
- const formatter = (0, exports.getFormatterFromMDXModule)(mdxModule, docOptions);
315
+ const mdxFormatter = (0, exports.getFormatterFromMDXModule)(mdxModule, docOptions);
311
316
  // Extract mdxDeclaration from the MDX module (if available)
312
317
  const mdxDeclaration = (0, exports.getMDXModuleProperty)(mdxModule, "mdxDeclaration");
313
318
  const printer = await (0, printer_1.getPrinter)(
314
- // module mandatory
315
- printerModule,
316
319
  // config mandatory
317
320
  {
318
321
  baseURL,
@@ -332,7 +335,7 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
332
335
  printTypeOptions,
333
336
  skipDocDirectives,
334
337
  sectionHeaderId: docOptions?.sectionHeaderId,
335
- }, formatter, mdxDeclaration,
338
+ }, mdxFormatter, mdxDeclaration,
336
339
  // Pass event emitter to enable print events
337
340
  events);
338
341
  // allow mdxModule to specify custom extension
@@ -342,10 +345,10 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
342
345
  mdxExtension = mdxExtensionFromModule;
343
346
  }
344
347
  else if (mdxModule) {
345
- mdxExtension = exports.FILE_EXTENSION.MDX;
348
+ mdxExtension = FILE_EXTENSION.MDX;
346
349
  }
347
350
  else {
348
- mdxExtension = exports.FILE_EXTENSION.MD;
351
+ mdxExtension = FILE_EXTENSION.MD;
349
352
  }
350
353
  const renderer = await (0, renderer_1.getRenderer)(printer, outputDir, baseURL, groups, prettify, {
351
354
  ...docOptions,
@@ -376,6 +379,12 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
376
379
  outputDir,
377
380
  });
378
381
  await events.emitAsync(events_1.RenderHomepageEvents.AFTER_RENDER, afterRenderHomepageEvent);
382
+ await events.emitAsync(events_1.RenderFilesEvents.AFTER_RENDER, new events_1.RenderFilesEvent({
383
+ baseURL,
384
+ outputDir,
385
+ rootDir: (0, node_path_1.dirname)(outputDir),
386
+ pages,
387
+ }));
379
388
  const duration = (Number(process.hrtime.bigint() - start) / NS_PER_SEC).toFixed(SEC_DECIMALS);
380
389
  (0, logger_1.log)(`Documentation successfully generated in "${outputDir}" with base URL "${baseURL}".`, "success");
381
390
  (0, logger_1.log)(`${pages.flat().length} pages generated in ${duration}s from schema "${(0, utils_1.toString)(schemaLocation)}".`);
@@ -7,11 +7,6 @@
7
7
  * @module graphql-config
8
8
  */
9
9
  import type { ExtensionProjectConfig, GraphQLExtensionDeclaration, LoaderOption, Maybe, PackageOptionsConfig } from "@graphql-markdown/types";
10
- /**
11
- * The name of the GraphQL Markdown extension.
12
- * Used to identify the extension in graphql-config.
13
- */
14
- export declare const EXTENSION_NAME: "graphql-markdown";
15
10
  /**
16
11
  * GraphQL extension declaration for graphql-config.
17
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"graphql-config.d.ts","sourceRoot":"","sources":["../src/graphql-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAEV,sBAAsB,EACtB,2BAA2B,EAC3B,YAAY,EACZ,KAAK,EAEL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAUjC;;;GAGG;AACH,eAAO,MAAM,cAAc,oBAA8B,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,EAAE,2BAEpC,CAAC;AAEF;;;;;;GAMG;AACH,UAAU,YAAY;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAWD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,gBAAgB,wEAkB5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,iKAsD7B,CAAC"}
1
+ {"version":3,"file":"graphql-config.d.ts","sourceRoot":"","sources":["../src/graphql-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAEV,sBAAsB,EACtB,2BAA2B,EAC3B,YAAY,EACZ,KAAK,EAEL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAgBjC;;;;;;;;;;;;GAYG;AAGH,eAAO,MAAM,sBAAsB,EAAE,2BAEpC,CAAC;AAEF;;;;;;GAMG;AACH,UAAU,YAAY;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAWD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,eAAO,MAAM,gBAAgB,YAClB,YAAY,WACZ,oBAAoB,KAC5B,YAeF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,OACxB,KAAK,CAAC,MAAM,CAAC,YACP,KAAK,CAAC,oBAAoB,CAAC,qCACH,YAAY,KAC7C,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAkDjD,CAAC"}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadConfiguration = exports.setLoaderOptions = exports.graphQLConfigExtension = exports.EXTENSION_NAME = void 0;
3
+ exports.loadConfiguration = exports.setLoaderOptions = exports.graphQLConfigExtension = void 0;
4
4
  const logger_1 = require("@graphql-markdown/logger");
5
5
  const validation_1 = require("./directives/validation");
6
6
  /**
7
7
  * The name of the GraphQL Markdown extension.
8
8
  * Used to identify the extension in graphql-config.
9
9
  */
10
- exports.EXTENSION_NAME = "graphql-markdown";
10
+ const EXTENSION_NAME = "graphql-markdown";
11
11
  /**
12
12
  * GraphQL extension declaration for graphql-config.
13
13
  *
@@ -21,8 +21,10 @@ exports.EXTENSION_NAME = "graphql-markdown";
21
21
  * });
22
22
  * ```
23
23
  */
24
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
25
+ // fallow-ignore-next-line unused-export
24
26
  const graphQLConfigExtension = () => {
25
- return { name: exports.EXTENSION_NAME };
27
+ return { name: EXTENSION_NAME };
26
28
  };
27
29
  exports.graphQLConfigExtension = graphQLConfigExtension;
28
30
  /**
@@ -56,6 +58,8 @@ const DEFAULT_THROW_OPTIONS = {
56
58
  * // Result: loaders with { baseDir: "./src", outputDir: "./docs" }
57
59
  * ```
58
60
  */
61
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
62
+ // fallow-ignore-next-line unused-export
59
63
  const setLoaderOptions = (loaders, options) => {
60
64
  for (const loader in loaders) {
61
65
  if ((0, validation_1.isLoaderString)(loaders[loader])) {
@@ -126,7 +130,7 @@ const loadConfiguration = async (id, options, { throwOnMissing, throwOnEmpty } =
126
130
  try {
127
131
  const projectConfig = config
128
132
  .getProject(id)
129
- .extension(exports.EXTENSION_NAME);
133
+ .extension(EXTENSION_NAME);
130
134
  if (Array.isArray(projectConfig.schema)) {
131
135
  const schema = projectConfig.schema[0];
132
136
  if ((0, validation_1.isSchemaString)(schema)) {
package/dist/index.d.ts CHANGED
@@ -19,6 +19,6 @@ export type { RenderRootTypesEvent } from "./events/render-root-types";
19
19
  export type { RenderHomepageEvent } from "./events/render-homepage";
20
20
  export type { RenderTypeEntitiesEvent } from "./events/render-type-entities";
21
21
  export type { GenerateIndexMetafileEvent } from "./events/generate-index-metafile";
22
- export type { ComposePageTypeEventData, IPrintCodeEvent, IPrintTypeEvent, PageSection, PageSections, PrintCodeEvent, PrintCodeEventData, PrintTypeEvent, PrintTypeEventData, } from "@graphql-markdown/types";
22
+ export type { ComposePageTypeEventData, IPrintCodeEvent, IPrintTypeEvent, PageSection, PageSections, PrintCodeEventData, PrintTypeEventData, } from "@graphql-markdown/types";
23
23
  export { CancellableEvent } from "@graphql-markdown/utils";
24
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;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AAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,YAAY,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC3E,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,YAAY,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -5,32 +5,32 @@
5
5
  /* istanbul ignore file */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.CancellableEvent = exports.PrintTypeEvents = exports.GenerateIndexMetafileEvents = exports.RenderTypeEntitiesEvents = exports.RenderHomepageEvents = exports.RenderRootTypesEvents = exports.DiffEvents = exports.SchemaEvents = exports.EVENT_CALLBACK_MAP = exports.registerMDXEventHandlers = exports.resetEvents = exports.getEvents = exports.buildConfig = exports.generateDocFromSchema = void 0;
8
- const generator_1 = require("./generator");
8
+ var generator_1 = require("./generator");
9
9
  Object.defineProperty(exports, "generateDocFromSchema", { enumerable: true, get: function () { return generator_1.generateDocFromSchema; } });
10
- const config_1 = require("./config");
10
+ var config_1 = require("./config");
11
11
  Object.defineProperty(exports, "buildConfig", { enumerable: true, get: function () { return config_1.buildConfig; } });
12
12
  // Event system exports
13
- const event_emitter_1 = require("./event-emitter");
13
+ var event_emitter_1 = require("./event-emitter");
14
14
  Object.defineProperty(exports, "getEvents", { enumerable: true, get: function () { return event_emitter_1.getEvents; } });
15
15
  Object.defineProperty(exports, "resetEvents", { enumerable: true, get: function () { return event_emitter_1.resetEvents; } });
16
- const event_handlers_1 = require("./event-handlers");
16
+ var event_handlers_1 = require("./event-handlers");
17
17
  Object.defineProperty(exports, "registerMDXEventHandlers", { enumerable: true, get: function () { return event_handlers_1.registerMDXEventHandlers; } });
18
- const event_map_1 = require("./event-map");
18
+ var event_map_1 = require("./event-map");
19
19
  Object.defineProperty(exports, "EVENT_CALLBACK_MAP", { enumerable: true, get: function () { return event_map_1.EVENT_CALLBACK_MAP; } });
20
20
  // Event constant exports
21
- const schema_events_1 = require("./events/schema-events");
21
+ var schema_events_1 = require("./events/schema-events");
22
22
  Object.defineProperty(exports, "SchemaEvents", { enumerable: true, get: function () { return schema_events_1.SchemaEvents; } });
23
- const diff_events_1 = require("./events/diff-events");
23
+ var diff_events_1 = require("./events/diff-events");
24
24
  Object.defineProperty(exports, "DiffEvents", { enumerable: true, get: function () { return diff_events_1.DiffEvents; } });
25
- const render_root_types_events_1 = require("./events/render-root-types-events");
25
+ var render_root_types_events_1 = require("./events/render-root-types-events");
26
26
  Object.defineProperty(exports, "RenderRootTypesEvents", { enumerable: true, get: function () { return render_root_types_events_1.RenderRootTypesEvents; } });
27
- const render_homepage_events_1 = require("./events/render-homepage-events");
27
+ var render_homepage_events_1 = require("./events/render-homepage-events");
28
28
  Object.defineProperty(exports, "RenderHomepageEvents", { enumerable: true, get: function () { return render_homepage_events_1.RenderHomepageEvents; } });
29
- const render_type_entities_events_1 = require("./events/render-type-entities-events");
29
+ var render_type_entities_events_1 = require("./events/render-type-entities-events");
30
30
  Object.defineProperty(exports, "RenderTypeEntitiesEvents", { enumerable: true, get: function () { return render_type_entities_events_1.RenderTypeEntitiesEvents; } });
31
- const generate_index_metafile_events_1 = require("./events/generate-index-metafile-events");
31
+ var generate_index_metafile_events_1 = require("./events/generate-index-metafile-events");
32
32
  Object.defineProperty(exports, "GenerateIndexMetafileEvents", { enumerable: true, get: function () { return generate_index_metafile_events_1.GenerateIndexMetafileEvents; } });
33
- const print_type_events_1 = require("./events/print-type-events");
33
+ var print_type_events_1 = require("./events/print-type-events");
34
34
  Object.defineProperty(exports, "PrintTypeEvents", { enumerable: true, get: function () { return print_type_events_1.PrintTypeEvents; } });
35
- const utils_1 = require("@graphql-markdown/utils");
35
+ var utils_1 = require("@graphql-markdown/utils");
36
36
  Object.defineProperty(exports, "CancellableEvent", { enumerable: true, get: function () { return utils_1.CancellableEvent; } });
package/dist/printer.d.ts CHANGED
@@ -7,26 +7,23 @@
7
7
  * @module printer
8
8
  *
9
9
  * This module provides the functionality to load and initialize a printer for GraphQL schema documentation.
10
- * It dynamically imports a printer module and configures it with the provided schema and options.
10
+ * It resolves a supported printer module and configures it with the provided schema and options.
11
11
  */
12
- import type { Formatter, IPrinter, Maybe, PackageName, PrinterConfig, PrinterEventEmitter, PrinterOptions } from "@graphql-markdown/types";
12
+ import type { Formatter, IPrinter, Maybe, PrinterConfig, PrinterEventEmitter, PrinterOptions } from "@graphql-markdown/types";
13
13
  /**
14
14
  * Loads and initializes a printer module for GraphQL schema documentation.
15
15
  *
16
- * This function dynamically imports the specified printer module and initializes it
16
+ * This function resolves the specified printer module and initializes it
17
17
  * with the provided configuration and options. The printer is responsible for rendering
18
18
  * GraphQL schema documentation in the desired format.
19
19
  *
20
- * @param printerModule - The name/path of the printer module to load
21
20
  * @param config - Configuration for the printer including schema, baseURL, and linkRoot
22
21
  * @param options - Additional options for customizing the printer's behavior
23
22
  * @param formatter - Optional formatter functions for customizing output format (e.g., MDX)
24
23
  *
25
24
  * @returns A promise that resolves to the initialized Printer instance
26
25
  *
27
- * @throws Will throw an error if printerModule is not a string
28
26
  * @throws Will throw an error if config is not provided
29
- * @throws Will throw an error if the module specified by printerModule cannot be found
30
27
  *
31
28
  * @example
32
29
  * ```typescript
@@ -40,19 +37,21 @@ import type { Formatter, IPrinter, Maybe, PackageName, PrinterConfig, PrinterEve
40
37
  * `);
41
38
  *
42
39
  * const printer = await getPrinter(
43
- * '@graphql-markdown/printer-legacy',
44
40
  * {
45
41
  * schema,
46
42
  * baseURL: '/docs',
47
43
  * linkRoot: 'graphql'
48
44
  * },
49
45
  * {
50
- * printTypeOptions: { includeDeprecationReasons: true }
46
+ * printTypeOptions: { deprecated: 'group' }
51
47
  * }
52
48
  * );
53
49
  *
54
- * const output = printer.printSchema();
50
+ * const queryType = schema.getQueryType();
51
+ * if (queryType) {
52
+ * const output = await printer.printType('Query', queryType);
53
+ * }
55
54
  * ```
56
55
  */
57
- export declare const getPrinter: (printerModule?: Maybe<PackageName>, config?: Maybe<PrinterConfig>, options?: Maybe<PrinterOptions>, formatter?: Partial<Formatter> | undefined, mdxDeclaration?: Maybe<string>, eventEmitter?: Maybe<PrinterEventEmitter>) => Promise<typeof IPrinter>;
56
+ export declare const getPrinter: (config?: Maybe<PrinterConfig>, options?: Maybe<PrinterOptions>, formatter?: Partial<Formatter>, mdxDeclaration?: Maybe<string>, eventEmitter?: Maybe<PrinterEventEmitter>) => Promise<typeof IPrinter>;
58
57
  //# sourceMappingURL=printer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,WAAW,EAEX,aAAa,EACb,mBAAmB,EACnB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,UAAU,yPAoCtB,CAAC"}
1
+ {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,aAAa,EACb,mBAAmB,EACnB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,UAAU,YACZ,KAAK,CAAC,aAAa,CAAC,YACnB,KAAK,CAAC,cAAc,CAAC,cACnB,OAAO,CAAC,SAAS,CAAC,mBACb,KAAK,CAAC,MAAM,CAAC,iBACf,KAAK,CAAC,mBAAmB,CAAC,KACxC,OAAO,CAAC,OAAO,QAAQ,CAiBzB,CAAC"}
package/dist/printer.js CHANGED
@@ -1,23 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPrinter = void 0;
4
+ const printer_legacy_1 = require("@graphql-markdown/printer-legacy");
4
5
  /**
5
6
  * Loads and initializes a printer module for GraphQL schema documentation.
6
7
  *
7
- * This function dynamically imports the specified printer module and initializes it
8
+ * This function resolves the specified printer module and initializes it
8
9
  * with the provided configuration and options. The printer is responsible for rendering
9
10
  * GraphQL schema documentation in the desired format.
10
11
  *
11
- * @param printerModule - The name/path of the printer module to load
12
12
  * @param config - Configuration for the printer including schema, baseURL, and linkRoot
13
13
  * @param options - Additional options for customizing the printer's behavior
14
14
  * @param formatter - Optional formatter functions for customizing output format (e.g., MDX)
15
15
  *
16
16
  * @returns A promise that resolves to the initialized Printer instance
17
17
  *
18
- * @throws Will throw an error if printerModule is not a string
19
18
  * @throws Will throw an error if config is not provided
20
- * @throws Will throw an error if the module specified by printerModule cannot be found
21
19
  *
22
20
  * @example
23
21
  * ```typescript
@@ -31,35 +29,28 @@ exports.getPrinter = void 0;
31
29
  * `);
32
30
  *
33
31
  * const printer = await getPrinter(
34
- * '@graphql-markdown/printer-legacy',
35
32
  * {
36
33
  * schema,
37
34
  * baseURL: '/docs',
38
35
  * linkRoot: 'graphql'
39
36
  * },
40
37
  * {
41
- * printTypeOptions: { includeDeprecationReasons: true }
38
+ * printTypeOptions: { deprecated: 'group' }
42
39
  * }
43
40
  * );
44
41
  *
45
- * const output = printer.printSchema();
42
+ * const queryType = schema.getQueryType();
43
+ * if (queryType) {
44
+ * const output = await printer.printType('Query', queryType);
45
+ * }
46
46
  * ```
47
47
  */
48
- const getPrinter = async (printerModule, config, options, formatter, mdxDeclaration, eventEmitter) => {
49
- if (typeof printerModule !== "string") {
50
- throw new TypeError("Invalid printer module name.");
51
- }
48
+ const getPrinter = async (config, options, formatter, mdxDeclaration, eventEmitter) => {
52
49
  if (!config) {
53
50
  throw new Error("Invalid printer config.");
54
51
  }
55
- try {
56
- const { Printer } = await import(printerModule);
57
- const { schema, baseURL, linkRoot } = config;
58
- await Printer.init(schema, baseURL, linkRoot, { ...options }, formatter, mdxDeclaration, eventEmitter);
59
- return Printer;
60
- }
61
- catch {
62
- throw new Error(`Cannot find module '${printerModule}'.`);
63
- }
52
+ const { schema, baseURL, linkRoot } = config;
53
+ await printer_legacy_1.Printer.init(schema, baseURL, linkRoot, options ?? undefined, formatter, mdxDeclaration, eventEmitter);
54
+ return printer_legacy_1.Printer;
64
55
  };
65
56
  exports.getPrinter = getPrinter;
@@ -1,4 +1,4 @@
1
- import type { ApiGroupOverrideType, Category, Maybe, Printer, RendererDocOptions, SchemaEntitiesGroupMap, SchemaEntity } from "@graphql-markdown/types";
1
+ import type { ApiGroupOverrideType, Category, Maybe, IPrinter, RendererDocOptions, SchemaEntitiesGroupMap, SchemaEntity } from "@graphql-markdown/types";
2
2
  /**
3
3
  * Default group names for API types and non-API types.
4
4
  * This constant provides the base folder structure for organizing GraphQL schema entities.
@@ -36,7 +36,7 @@ export declare const API_GROUPS: Required<ApiGroupOverrideType>;
36
36
  * const folder = getApiGroupFolder(objectType, { operations: "queries" }); // Returns appropriate folder
37
37
  * ```
38
38
  */
39
- export declare const getApiGroupFolder: (type: unknown, groups?: Maybe<boolean | ApiGroupOverrideType>) => string;
39
+ export declare const getApiGroupFolder: (type: unknown, groups?: Maybe<ApiGroupOverrideType | boolean>) => string;
40
40
  /**
41
41
  * Configuration options for category metafiles in the documentation.
42
42
  * These options control the appearance and behavior of category sections in the sidebar.
@@ -96,7 +96,7 @@ export declare class Renderer {
96
96
  * @param mdxExtension - Optional MDX file extension to use
97
97
  * @example
98
98
  */
99
- constructor(printer: Printer, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<RendererDocOptions>, mdxExtension: string);
99
+ constructor(printer: typeof IPrinter, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<RendererDocOptions>, mdxExtension: string);
100
100
  /**
101
101
  * Generates an index metafile for a category directory if MDX support is available.
102
102
  *
@@ -243,5 +243,5 @@ export declare class Renderer {
243
243
  * );
244
244
  * ```
245
245
  */
246
- export declare const getRenderer: (printer: typeof import("@graphql-markdown/types").IPrinter, outputDir: string, baseURL: string, group: Maybe<Partial<Record<SchemaEntity, Record<string, Maybe<string>>>>>, prettify: boolean, docOptions: Maybe<RendererDocOptions>, mdxExtension: string) => Promise<Renderer>;
246
+ export declare const getRenderer: (printer: typeof IPrinter, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<RendererDocOptions>, mdxExtension: string) => Promise<InstanceType<typeof Renderer>>;
247
247
  //# sourceMappingURL=renderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,QAAQ,EAER,KAAK,EAEL,OAAO,EACP,kBAAk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,aACb,MAAM,WACR,MAAM,SACR,KAAK,CAAC,sBAAsB,CAAC,YAC1B,OAAO,cACL,KAAK,CAAC,kBAAkB,CAAC,gBACvB,MAAM,KACnB,OAAO,CAAC,YAAY,CAAC,OAAO,QAAQ,CAAC,CAWvC,CAAC"}
package/dist/renderer.js CHANGED
@@ -89,6 +89,8 @@ var SidebarPosition;
89
89
  *
90
90
  * @see {@link getApiGroupFolder} For usage with type categorization
91
91
  */
92
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
93
+ // fallow-ignore-next-line unused-export
92
94
  exports.API_GROUPS = {
93
95
  operations: "operations",
94
96
  types: "types",
@@ -109,6 +111,8 @@ exports.API_GROUPS = {
109
111
  * const folder = getApiGroupFolder(objectType, { operations: "queries" }); // Returns appropriate folder
110
112
  * ```
111
113
  */
114
+ // Used only by unit tests for direct whitebox coverage; not part of the production public API.
115
+ // fallow-ignore-next-line unused-export
112
116
  const getApiGroupFolder = (type, groups) => {
113
117
  let folderNames = exports.API_GROUPS;
114
118
  if ((0, validation_1.isGroupsObject)(groups)) {
@@ -254,6 +258,9 @@ class CategoryPositionManager {
254
258
  * Each level has its own CategoryPositionManager that restarts numbering at 1.
255
259
  * @example
256
260
  */
261
+ // Value export used only by unit tests for direct whitebox coverage; the type is used
262
+ // elsewhere via getRenderer()'s return type.
263
+ // fallow-ignore-next-line unused-export
257
264
  class Renderer {
258
265
  group;
259
266
  outputDir;
@@ -512,19 +519,19 @@ class Renderer {
512
519
  const extractedCategory = isFlat
513
520
  ? page.groups.pageId
514
521
  : stripNumericPrefix(page.groups.category);
515
- const slug = isFlat
516
- ? page.groups.pageId
517
- : utils_1.pathUrl.join(extractedCategory, page.groups.pageId);
518
522
  const category = isFlat ? "schema" : (0, utils_1.startCase)(extractedCategory);
519
523
  const events = (0, event_emitter_1.getEvents)();
520
524
  const event = new events_1.RenderTypeEntitiesEvent({
525
+ baseURL: this.baseURL,
521
526
  name,
522
527
  filePath,
528
+ outputDir: this.outputDir,
523
529
  });
524
530
  await events.emitAsync(events_1.RenderTypeEntitiesEvents.AFTER_RENDER, event);
525
531
  return {
526
532
  category,
527
- slug,
533
+ filePath,
534
+ name,
528
535
  };
529
536
  }
530
537
  /**