@graphql-markdown/core 1.22.0 → 1.24.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.
- package/README.md +47 -0
- package/dist/config.d.ts +30 -22
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +149 -10
- package/dist/event-emitter.d.ts +1 -2
- package/dist/event-emitter.d.ts.map +1 -1
- package/dist/event-emitter.js +2 -1
- package/dist/event-map.d.ts +1 -0
- package/dist/event-map.d.ts.map +1 -1
- package/dist/event-map.js +2 -0
- package/dist/events/config-build-events.d.ts +13 -0
- package/dist/events/config-build-events.d.ts.map +1 -0
- package/dist/events/config-build-events.js +15 -0
- package/dist/events/config-build.d.ts +21 -0
- package/dist/events/config-build.d.ts.map +1 -0
- package/dist/events/config-build.js +20 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +5 -1
- package/dist/events/schema-load.d.ts +5 -5
- package/dist/events/schema-load.d.ts.map +1 -1
- package/dist/generator.d.ts +1 -1
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +32 -11
- package/dist/graphql-config.d.ts +1 -2
- package/dist/graphql-config.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/renderer.d.ts +37 -26
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +37 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,3 +5,50 @@
|
|
|
5
5
|
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_core)
|
|
6
6
|
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_core)
|
|
7
7
|
[](https://dashboard.stryker-mutator.io/reports/github.com/graphql-markdown/graphql-markdown/main?module=core)
|
|
8
|
+
|
|
9
|
+
Core engine for generating **Markdown documentation** from a **GraphQL schema**. It orchestrates schema loading, diffing, rendering, and the event lifecycle used by [`@graphql-markdown/cli`](https://www.npmjs.com/package/@graphql-markdown/cli) and [`@graphql-markdown/docusaurus`](https://www.npmjs.com/package/@graphql-markdown/docusaurus). Most users should install one of those packages instead of depending on `core` directly.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
npm install @graphql-markdown/core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { buildConfig, generateDocFromSchema } from "@graphql-markdown/core";
|
|
21
|
+
|
|
22
|
+
const config = await buildConfig({
|
|
23
|
+
schema: "./schema.graphql",
|
|
24
|
+
rootPath: "./docs",
|
|
25
|
+
baseURL: "api",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await generateDocFromSchema(config);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Event system
|
|
32
|
+
|
|
33
|
+
`core` exposes a cancellable event emitter so that formatters, printers, and custom scripts can hook into schema loading, diff checks, and rendering:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { getEvents, SchemaEvents } from "@graphql-markdown/core";
|
|
37
|
+
|
|
38
|
+
getEvents().on(SchemaEvents.SCHEMA_LOAD, (event) => {
|
|
39
|
+
console.log("Schema loaded", event);
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
See the [event handlers documentation](https://graphql-markdown.dev/docs/advanced/lifecycle-events) for the full list of lifecycle events and their payloads.
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
- [Configuration Options](https://graphql-markdown.dev/docs/settings)
|
|
48
|
+
- [Lifecycle Events](https://graphql-markdown.dev/docs/advanced/lifecycle-events)
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
GraphQL-Markdown packages are 100% free and open-source, under the [MIT license](https://github.com/graphql-markdown/graphql-markdown/blob/main/LICENSE).
|
|
53
|
+
|
|
54
|
+
This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/graphql-markdown/graphql-markdown) to thank us for our work. By contributing to the Treeware forest, you'll be creating employment for local families and restoring wildlife habitats.
|
package/dist/config.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @packageDocumentation
|
|
17
17
|
*/
|
|
18
|
-
import type { CliOptions, ConfigDocOptions, ConfigOptions, ConfigPrintTypeOptions, CustomDirective, DirectiveName, GroupByDirectiveOptions, Maybe, Options, TypeDiffMethod, TypeHierarchyObjectType, TypeHierarchyType, TypeHierarchyValueType } from "@graphql-markdown/types";
|
|
18
|
+
import type { CliOptions, ConfigDocOptions, ConfigOptions, ConfigPrintTypeOptions, CustomDirective, Decorators, DirectiveName, GroupByDirectiveOptions, Maybe, Options, TypeDiffMethod, TypeHierarchyObjectType, TypeHierarchyType, TypeHierarchyValueType } from "@graphql-markdown/types";
|
|
19
19
|
/**
|
|
20
20
|
* Type hierarchy options for organizing schema documentation.
|
|
21
21
|
*
|
|
@@ -97,7 +97,7 @@ export declare const DEFAULT_HIERARCHY: {
|
|
|
97
97
|
* @public
|
|
98
98
|
* @see {@link Options} for the complete configuration interface
|
|
99
99
|
*/
|
|
100
|
-
export declare const DEFAULT_OPTIONS: Readonly<Pick<ConfigOptions, "customDirective" | "groupByDirective" | "loaders" | "outputAdapter"> & Required<Omit<ConfigOptions, "customDirective" | "formatter" | "groupByDirective" | "loaders" | "mdxParser" | "outputAdapter" | "printTypeOptions">>> & {
|
|
100
|
+
export declare const DEFAULT_OPTIONS: Readonly<Pick<ConfigOptions, "customDirective" | "decorators" | "groupByDirective" | "loaders" | "outputAdapter"> & Required<Omit<ConfigOptions, "customDirective" | "decorators" | "formatter" | "groupByDirective" | "loaders" | "mdxParser" | "outputAdapter" | "printTypeOptions">>> & {
|
|
101
101
|
printTypeOptions: Required<Omit<ConfigPrintTypeOptions, "exampleSection" | "hierarchy">> & {
|
|
102
102
|
exampleSection: ConfigPrintTypeOptions["exampleSection"];
|
|
103
103
|
hierarchy: Required<Pick<TypeHierarchyObjectType, TypeHierarchy.API>>;
|
|
@@ -236,26 +236,6 @@ export declare const getCustomDirectives: (customDirectiveOptions: Maybe<CustomD
|
|
|
236
236
|
export declare const getForcedDiffMethod: () => TypeDiffMethod;
|
|
237
237
|
export declare const getDiffMethod: (diff: TypeDiffMethod) => TypeDiffMethod;
|
|
238
238
|
export declare const parseDeprecatedDocOptions: (_cliOpts?: Maybe<CliOptions>, _configOptions?: Maybe<ConfigDocOptions>) => Record<string, never>;
|
|
239
|
-
/**
|
|
240
|
-
* Builds the document options by merging CLI options, config file options, and defaults.
|
|
241
|
-
* Handles index generation flag and front matter configuration.
|
|
242
|
-
*
|
|
243
|
-
* @param cliOpts - CLI options for document generation
|
|
244
|
-
* @param configOptions - Config file options for document generation
|
|
245
|
-
* @returns The resolved document options with all required fields
|
|
246
|
-
* @example
|
|
247
|
-
* ```typescript
|
|
248
|
-
* const cliOptions = { index: true };
|
|
249
|
-
* const configOptions = { frontMatter: { sidebar_label: 'API' } };
|
|
250
|
-
*
|
|
251
|
-
* const docOptions = getDocOptions(cliOptions, configOptions);
|
|
252
|
-
* console.log(docOptions);
|
|
253
|
-
* // {
|
|
254
|
-
* // index: true,
|
|
255
|
-
* // frontMatter: { sidebar_label: 'API' }
|
|
256
|
-
* // }
|
|
257
|
-
* ```
|
|
258
|
-
*/
|
|
259
239
|
export declare const getDocOptions: (cliOpts?: Maybe<CliOptions>, configOptions?: Maybe<ConfigDocOptions>) => Required<ConfigDocOptions>;
|
|
260
240
|
/**
|
|
261
241
|
* Resolves the type hierarchy configuration by merging CLI and config file options.
|
|
@@ -284,6 +264,34 @@ export declare const getDocOptions: (cliOpts?: Maybe<CliOptions>, configOptions?
|
|
|
284
264
|
export declare const getTypeHierarchyOption: (cliOption?: Maybe<TypeHierarchyValueType>, configOption?: Maybe<TypeHierarchyType>) => Maybe<TypeHierarchyObjectType>;
|
|
285
265
|
export declare const parseDeprecatedFormatterOption: (cliOpts?: Maybe<CliOptions>, configOptions?: Maybe<ConfigOptions>) => Maybe<string>;
|
|
286
266
|
export declare const parseDeprecatedPrintTypeOptions: (_cliOpts?: Maybe<CliOptions>, _configOptions?: Maybe<ConfigPrintTypeOptions>) => Record<string, never>;
|
|
267
|
+
/**
|
|
268
|
+
* Validates the top-level `decorators` option.
|
|
269
|
+
*
|
|
270
|
+
* The option is keyed by a free-form id — it is not required to name a
|
|
271
|
+
* schema directive — and every entry must declare a `render` callback. An
|
|
272
|
+
* invalid entry is a configuration error rather than something to silently
|
|
273
|
+
* drop, as it would otherwise produce a page missing a section without any
|
|
274
|
+
* indication why.
|
|
275
|
+
*
|
|
276
|
+
* @param decorators - the `decorators` option declared in the config file.
|
|
277
|
+
*
|
|
278
|
+
* @returns the validated decorators, or `undefined` when none is declared.
|
|
279
|
+
*
|
|
280
|
+
* @throws Error if an entry is malformed or claims a built-in section name.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```js
|
|
284
|
+
* getDecoratorsOption({
|
|
285
|
+
* responses: {
|
|
286
|
+
* predicate: hasDirectiveNamed("httpResponse"),
|
|
287
|
+
* title: "Responses",
|
|
288
|
+
* position: { after: "metadata" },
|
|
289
|
+
* render: (values) => values.map((v) => `- \`${v.code}\` ${v.description}`).join("\n"),
|
|
290
|
+
* },
|
|
291
|
+
* });
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
export declare const getDecoratorsOption: (decorators: Maybe<Decorators>) => Maybe<Decorators>;
|
|
287
295
|
/**
|
|
288
296
|
* Parses and validates the groupByDirective option string format.
|
|
289
297
|
* The format should be \@directive(field|=fallback) where:
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,eAAe,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,eAAe,EAGf,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,KAAK,EACL,OAAO,EAGP,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAUjC;;;;;;;;;;;;GAYG;AACH,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED;;;;;;;;;;;GAWG;AACH,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,oBAAY,gBAAgB;IAC1B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAG,mCAA4C,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAG,8BAAuC,CAAC;AACpE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAKnC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;CAA8B,CAAC;AAK7D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CACpC,IAAI,CACF,aAAa,EACX,iBAAiB,GACjB,YAAY,GACZ,kBAAkB,GAClB,SAAS,GACT,eAAe,CAClB,GACC,QAAQ,CACN,IAAI,CACF,aAAa,EACX,iBAAiB,GACjB,YAAY,GACZ,WAAW,GACX,kBAAkB,GAClB,SAAS,GACT,WAAW,GACX,eAAe,GACf,kBAAkB,CACrB,CACF,CACJ,GAAG;IACF,gBAAgB,EAAE,QAAQ,CACxB,IAAI,CAAC,sBAAsB,EA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AAU,CAAC,OACvB,KAAK,CAAC,MAAM,CAAC,KAChB,OAAO,CAAC,OAAO,CAoGjB,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.buildConfig = exports.parseHomepageOption = exports.parseGroupByOption = exports.parseDeprecatedPrintTypeOptions = exports.parseDeprecatedFormatterOption = exports.getTypeHierarchyOption = exports.getDocOptions = exports.parseDeprecatedDocOptions = exports.getDiffMethod = exports.getForcedDiffMethod = exports.getCustomDirectives = exports.getVisibilityDirectives = exports.getSkipDocDirectives = exports.getOnlyDocDirectives = exports.getDocDirective = exports.DEFAULT_OPTIONS = exports.DEFAULT_HIERARCHY = exports.ASSET_HOMEPAGE_LOCATION = exports.PACKAGE_NAME = exports.DOCS_URL = exports.DeprecatedOption = exports.DiffMethod = exports.TypeHierarchy = void 0;
|
|
20
|
+
exports.buildConfig = exports.parseHomepageOption = exports.parseGroupByOption = exports.getDecoratorsOption = exports.parseDeprecatedPrintTypeOptions = exports.parseDeprecatedFormatterOption = exports.getTypeHierarchyOption = exports.getDocOptions = exports.parseDeprecatedDocOptions = exports.getDiffMethod = exports.getForcedDiffMethod = exports.getCustomDirectives = exports.getVisibilityDirectives = exports.getSkipDocDirectives = exports.getOnlyDocDirectives = exports.getDocDirective = exports.DEFAULT_OPTIONS = exports.DEFAULT_HIERARCHY = exports.ASSET_HOMEPAGE_LOCATION = exports.PACKAGE_NAME = exports.DOCS_URL = exports.DeprecatedOption = exports.DiffMethod = exports.TypeHierarchy = void 0;
|
|
21
21
|
const node_path_1 = require("node:path");
|
|
22
22
|
const node_os_1 = require("node:os");
|
|
23
23
|
const deepmerge_1 = require("@fastify/deepmerge");
|
|
24
24
|
const logger_1 = require("@graphql-markdown/logger");
|
|
25
|
+
const printer_legacy_1 = require("@graphql-markdown/printer-legacy");
|
|
25
26
|
const graphql_config_1 = require("./graphql-config");
|
|
26
27
|
const patterns_1 = require("./const/patterns");
|
|
27
28
|
const validation_1 = require("./directives/validation");
|
|
@@ -114,6 +115,7 @@ exports.DEFAULT_OPTIONS = {
|
|
|
114
115
|
id: "default",
|
|
115
116
|
baseURL: "schema",
|
|
116
117
|
customDirective: undefined,
|
|
118
|
+
decorators: undefined,
|
|
117
119
|
diffMethod: DiffMethod.NONE,
|
|
118
120
|
docOptions: {
|
|
119
121
|
categorySort: undefined,
|
|
@@ -304,6 +306,7 @@ const getCustomDirectives = (customDirectiveOptions, skipDocDirective) => {
|
|
|
304
306
|
Object.keys(customDirectiveOptions).length === 0) {
|
|
305
307
|
return undefined;
|
|
306
308
|
}
|
|
309
|
+
(0, logger_1.log)(`Setting "customDirective" is deprecated and will be removed in a future version. Use "decorators" instead.`, logger_1.LogLevel.warn);
|
|
307
310
|
for (const [name, option] of Object.entries(customDirectiveOptions)) {
|
|
308
311
|
if (Array.isArray(skipDocDirective) &&
|
|
309
312
|
skipDocDirective.includes(name)) {
|
|
@@ -370,16 +373,29 @@ exports.parseDeprecatedDocOptions = parseDeprecatedDocOptions;
|
|
|
370
373
|
* // }
|
|
371
374
|
* ```
|
|
372
375
|
*/
|
|
376
|
+
/**
|
|
377
|
+
* Resolves a boolean option that defaults to `true` and can only be turned off,
|
|
378
|
+
* either via a CLI negation flag (e.g. `--noParentType`) or an explicit `false`
|
|
379
|
+
* in the config file.
|
|
380
|
+
*
|
|
381
|
+
* @param cliNegated - the CLI negation flag value (e.g. `cliOpts.noParentType`)
|
|
382
|
+
* @param configValue - the corresponding config file option value
|
|
383
|
+
* @param defaultValue - the value used when neither source turns the option off
|
|
384
|
+
* @returns the resolved boolean value
|
|
385
|
+
*/
|
|
386
|
+
const resolveNegatableOption = (cliNegated, configValue, defaultValue) => {
|
|
387
|
+
if (cliNegated === true) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
return typeof configValue === "boolean" ? configValue : defaultValue;
|
|
391
|
+
};
|
|
373
392
|
// Used only by unit tests for direct whitebox coverage; not part of the production public API.
|
|
374
393
|
const getDocOptions = (cliOpts, configOptions) => {
|
|
375
394
|
const deprecated = (0, exports.parseDeprecatedDocOptions)(cliOpts, configOptions);
|
|
376
395
|
const cliIndex = typeof cliOpts?.index === "boolean" ? cliOpts.index : undefined;
|
|
377
396
|
const configIndex = typeof configOptions?.index === "boolean" ? configOptions.index : undefined;
|
|
378
397
|
const index = cliIndex ?? configIndex ?? exports.DEFAULT_OPTIONS.docOptions.index;
|
|
379
|
-
const
|
|
380
|
-
? configOptions.sectionHeaderId
|
|
381
|
-
: exports.DEFAULT_OPTIONS.docOptions.sectionHeaderId;
|
|
382
|
-
const sectionHeaderId = cliOpts?.noSectionId === true ? false : configSectionHeaderId;
|
|
398
|
+
const sectionHeaderId = resolveNegatableOption(cliOpts?.noSectionId, configOptions?.sectionHeaderId, exports.DEFAULT_OPTIONS.docOptions.sectionHeaderId);
|
|
383
399
|
return {
|
|
384
400
|
categorySort: configOptions?.categorySort,
|
|
385
401
|
frontMatter: {
|
|
@@ -495,6 +511,129 @@ exports.parseDeprecatedPrintTypeOptions = parseDeprecatedPrintTypeOptions;
|
|
|
495
511
|
* @see {@link DeprecatedOption} for deprecated handling options
|
|
496
512
|
* @see {@link getTypeHierarchyOption} for hierarchy resolution
|
|
497
513
|
*/
|
|
514
|
+
/**
|
|
515
|
+
* Section keys owned by the printer, which a custom section/decorator cannot
|
|
516
|
+
* claim. Shares `@graphql-markdown/printer-legacy`'s `RESERVED_SECTION_NAMES`
|
|
517
|
+
* — the single source of truth for the built-in names — plus `"__proto__"`,
|
|
518
|
+
* reserved only here: a config file declaring it is almost certainly a
|
|
519
|
+
* mistake, whereas the printer deliberately supports it as a section id when
|
|
520
|
+
* built directly (not via a config file), guarded by `Object.create(null)`.
|
|
521
|
+
*
|
|
522
|
+
* @internal
|
|
523
|
+
*/
|
|
524
|
+
const RESERVED_SECTION_NAMES = [
|
|
525
|
+
...printer_legacy_1.RESERVED_SECTION_NAMES,
|
|
526
|
+
"__proto__",
|
|
527
|
+
];
|
|
528
|
+
/**
|
|
529
|
+
* Validates an optional callback-typed decorator field (`predicate`, `resolve`).
|
|
530
|
+
*
|
|
531
|
+
* @internal
|
|
532
|
+
*
|
|
533
|
+
* @throws TypeError if the field is set and is not a function.
|
|
534
|
+
*/
|
|
535
|
+
const validateDecoratorCallback = (id, field, value) => {
|
|
536
|
+
if (value !== undefined && typeof value !== "function") {
|
|
537
|
+
throw new TypeError(`Decorator '${id}' option '${field}' must be a function.`);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Validates a decorator's optional `position`.
|
|
542
|
+
*
|
|
543
|
+
* An invalid `position` fails silently downstream — a typo'd slot name never
|
|
544
|
+
* matches in `printSlotDecorators`, and an unknown anchor is absorbed by
|
|
545
|
+
* `getDecoratorsOrder`'s "append when not found" fallback — so it is checked
|
|
546
|
+
* here instead, where a mistake can be reported.
|
|
547
|
+
*
|
|
548
|
+
* @internal
|
|
549
|
+
*
|
|
550
|
+
* @throws TypeError if `position` is set and is not exactly one of
|
|
551
|
+
* `after`/`before`/`into`, as a non-empty string.
|
|
552
|
+
*/
|
|
553
|
+
const validateDecoratorPosition = (id, position) => {
|
|
554
|
+
if (position === undefined || position === null) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
const anchors = ["after", "before", "into"].filter((key) => {
|
|
558
|
+
return position[key] !== undefined;
|
|
559
|
+
});
|
|
560
|
+
const value = anchors.length === 1 ? position[anchors[0]] : undefined;
|
|
561
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
562
|
+
throw new TypeError(`Decorator '${id}' option 'position' must set exactly one of 'after', 'before', or 'into' to a non-empty string.`);
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* Validates a single decorator declaration.
|
|
567
|
+
*
|
|
568
|
+
* A config file is untrusted runtime JavaScript, so every malformed field is
|
|
569
|
+
* a configuration error to report, not a value to silently ignore or coerce.
|
|
570
|
+
*
|
|
571
|
+
* @internal
|
|
572
|
+
*
|
|
573
|
+
* @throws Error or TypeError if the decorator id or any of its fields is malformed.
|
|
574
|
+
*/
|
|
575
|
+
const validateDecoratorEntry = (id, decorator) => {
|
|
576
|
+
if (id.length === 0) {
|
|
577
|
+
throw new TypeError("Option 'decorators' requires a non-empty id for each decorator.");
|
|
578
|
+
}
|
|
579
|
+
if (RESERVED_SECTION_NAMES.includes(id)) {
|
|
580
|
+
throw new Error(`Decorator id '${id}' is reserved, please use another id.`);
|
|
581
|
+
}
|
|
582
|
+
// The `!decorator` half narrows `decorator` from `Maybe<DecoratorDefinition>`
|
|
583
|
+
// for every check below, and also catches a non-object entry (`null`, or
|
|
584
|
+
// `undefined` from a conditional spread).
|
|
585
|
+
if (!decorator || typeof decorator.render !== "function") {
|
|
586
|
+
throw new TypeError(`Decorator '${id}' requires a 'render' function.`);
|
|
587
|
+
}
|
|
588
|
+
validateDecoratorCallback(id, "predicate", decorator.predicate);
|
|
589
|
+
validateDecoratorCallback(id, "resolve", decorator.resolve);
|
|
590
|
+
validateDecoratorPosition(id, decorator.position);
|
|
591
|
+
};
|
|
592
|
+
/**
|
|
593
|
+
* Validates the top-level `decorators` option.
|
|
594
|
+
*
|
|
595
|
+
* The option is keyed by a free-form id — it is not required to name a
|
|
596
|
+
* schema directive — and every entry must declare a `render` callback. An
|
|
597
|
+
* invalid entry is a configuration error rather than something to silently
|
|
598
|
+
* drop, as it would otherwise produce a page missing a section without any
|
|
599
|
+
* indication why.
|
|
600
|
+
*
|
|
601
|
+
* @param decorators - the `decorators` option declared in the config file.
|
|
602
|
+
*
|
|
603
|
+
* @returns the validated decorators, or `undefined` when none is declared.
|
|
604
|
+
*
|
|
605
|
+
* @throws Error if an entry is malformed or claims a built-in section name.
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```js
|
|
609
|
+
* getDecoratorsOption({
|
|
610
|
+
* responses: {
|
|
611
|
+
* predicate: hasDirectiveNamed("httpResponse"),
|
|
612
|
+
* title: "Responses",
|
|
613
|
+
* position: { after: "metadata" },
|
|
614
|
+
* render: (values) => values.map((v) => `- \`${v.code}\` ${v.description}`).join("\n"),
|
|
615
|
+
* },
|
|
616
|
+
* });
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
const getDecoratorsOption = (decorators) => {
|
|
620
|
+
// Only an absent option selects the default: a configuration file is runtime
|
|
621
|
+
// JavaScript, so a falsy non-object such as `false` or `""` is a mistake worth
|
|
622
|
+
// reporting rather than a silent way to disable the decorators.
|
|
623
|
+
if (decorators === null || decorators === undefined) {
|
|
624
|
+
return exports.DEFAULT_OPTIONS.decorators;
|
|
625
|
+
}
|
|
626
|
+
if (typeof decorators !== "object" || Array.isArray(decorators)) {
|
|
627
|
+
throw new TypeError("Option 'decorators' must be a map of decorator ids.");
|
|
628
|
+
}
|
|
629
|
+
// `Object.entries` skips the `__proto__` key of an object literal, which never
|
|
630
|
+
// becomes an own property, so a decorator cannot claim it here either.
|
|
631
|
+
Object.entries(decorators).forEach(([id, decorator]) => {
|
|
632
|
+
validateDecoratorEntry(id, decorator);
|
|
633
|
+
});
|
|
634
|
+
return decorators;
|
|
635
|
+
};
|
|
636
|
+
exports.getDecoratorsOption = getDecoratorsOption;
|
|
498
637
|
const getPrintTypeOptions = (cliOpts, configOptions) => {
|
|
499
638
|
return {
|
|
500
639
|
deprecated: (cliOpts?.deprecated ??
|
|
@@ -502,10 +641,8 @@ const getPrintTypeOptions = (cliOpts, configOptions) => {
|
|
|
502
641
|
exports.DEFAULT_OPTIONS.printTypeOptions.deprecated).toLocaleLowerCase(),
|
|
503
642
|
exampleSection: configOptions?.exampleSection ??
|
|
504
643
|
exports.DEFAULT_OPTIONS.printTypeOptions.exampleSection,
|
|
505
|
-
parentTypePrefix: (
|
|
506
|
-
|
|
507
|
-
typeBadges: (!cliOpts?.noTypeBadges && configOptions?.typeBadges) ??
|
|
508
|
-
exports.DEFAULT_OPTIONS.printTypeOptions.typeBadges,
|
|
644
|
+
parentTypePrefix: resolveNegatableOption(cliOpts?.noParentType, configOptions?.parentTypePrefix, exports.DEFAULT_OPTIONS.printTypeOptions.parentTypePrefix),
|
|
645
|
+
typeBadges: resolveNegatableOption(cliOpts?.noTypeBadges, configOptions?.typeBadges, exports.DEFAULT_OPTIONS.printTypeOptions.typeBadges),
|
|
509
646
|
hierarchy: (0, exports.getTypeHierarchyOption)(cliOpts?.hierarchy, configOptions?.hierarchy),
|
|
510
647
|
};
|
|
511
648
|
};
|
|
@@ -610,9 +747,11 @@ const buildConfig = async (configFileOpts, cliOpts, id = "default") => {
|
|
|
610
747
|
.addFromConfig(config.tmpDir, "tmpDir")
|
|
611
748
|
.addFromCli(cliOpts.tmp, "tmpDir")
|
|
612
749
|
.build();
|
|
750
|
+
const printTypeOptions = getPrintTypeOptions(cliOpts, config.printTypeOptions);
|
|
613
751
|
return {
|
|
614
752
|
baseURL,
|
|
615
753
|
customDirective: (0, exports.getCustomDirectives)(config.customDirective, skipDocDirective),
|
|
754
|
+
decorators: (0, exports.getDecoratorsOption)(config.decorators),
|
|
616
755
|
diffMethod: force
|
|
617
756
|
? (0, exports.getForcedDiffMethod)()
|
|
618
757
|
: (0, exports.getDiffMethod)(cliOpts.diff ?? config.diffMethod),
|
|
@@ -629,7 +768,7 @@ const buildConfig = async (configFileOpts, cliOpts, id = "default") => {
|
|
|
629
768
|
outputAdapter,
|
|
630
769
|
outputDir: (0, node_path_1.join)(rootPath, baseURL),
|
|
631
770
|
prettify,
|
|
632
|
-
printTypeOptions
|
|
771
|
+
printTypeOptions,
|
|
633
772
|
schemaLocation,
|
|
634
773
|
skipDocDirective,
|
|
635
774
|
tmpDir,
|
package/dist/event-emitter.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface EmitResult {
|
|
|
28
28
|
*
|
|
29
29
|
* @category Events
|
|
30
30
|
*/
|
|
31
|
-
declare class CancellableEventEmitter extends EventEmitter {
|
|
31
|
+
export declare class CancellableEventEmitter extends EventEmitter {
|
|
32
32
|
private static toError;
|
|
33
33
|
private static isDefaultPrevented;
|
|
34
34
|
/**
|
|
@@ -110,5 +110,4 @@ export declare const getEvents: () => CancellableEventEmitter;
|
|
|
110
110
|
* @category Events
|
|
111
111
|
*/
|
|
112
112
|
export declare const resetEvents: () => void;
|
|
113
|
-
export {};
|
|
114
113
|
//# sourceMappingURL=event-emitter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../src/event-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB;;;OAGG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,
|
|
1
|
+
{"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../src/event-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB;;;OAGG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAO,CAAC,MAAM,CAAC,OAAO;IAItB,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAMjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,SAAS,CACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,UAAU,CAAC,CAgBrB;YAEa,cAAc;YAOd,eAAe;YAsBf,gBAAgB;CAgB/B;AAQD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,SAAS,QAAO,uBAG5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,QAAO,IAK9B,CAAC"}
|
package/dist/event-emitter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetEvents = exports.getEvents = void 0;
|
|
3
|
+
exports.resetEvents = exports.getEvents = exports.CancellableEventEmitter = void 0;
|
|
4
4
|
const node_events_1 = require("node:events");
|
|
5
5
|
/**
|
|
6
6
|
* Custom EventEmitter that supports cancellable events with sequential handler execution.
|
|
@@ -96,6 +96,7 @@ class CancellableEventEmitter extends node_events_1.EventEmitter {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
exports.CancellableEventEmitter = CancellableEventEmitter;
|
|
99
100
|
/**
|
|
100
101
|
* Singleton instance of the CancellableEventEmitter.
|
|
101
102
|
* Shared across the entire application.
|
package/dist/event-map.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* They are pure transformations handled via the Formatter interface, not events.
|
|
7
7
|
*/
|
|
8
8
|
export declare const EVENT_CALLBACK_MAP: {
|
|
9
|
+
readonly "config:afterBuild": "afterConfigBuildHook";
|
|
9
10
|
readonly "schema:beforeLoad": "beforeLoadSchemaHook";
|
|
10
11
|
readonly "schema:afterLoad": "afterLoadSchemaHook";
|
|
11
12
|
readonly "diff:beforeCheck": "beforeCheckDiffHook";
|
package/dist/event-map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-map.d.ts","sourceRoot":"","sources":["../src/event-map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-map.d.ts","sourceRoot":"","sources":["../src/event-map.ts"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;kCACI,sBAAsB;kCAC3B,sBAAsB;iCACvB,qBAAqB;iCACrB,qBAAqB;gCACtB,oBAAoB;6CACP,2BAA2B;4CAC5B,0BAA0B;4CAC1B,0BAA0B;2CAC3B,yBAAyB;gDACpB,8BAA8B;+CAC/B,6BAA6B;mDAEpE,iCAAiC;kDAEjC,gCAAgC;wCACA,sBAAsB;sCACnB,qBAAqB;qCACtB,oBAAoB;sCACnB,qBAAqB;qCACtB,oBAAoB;4CACZ,2BAA2B;CAC/D,CAAC"}
|
package/dist/event-map.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.EVENT_CALLBACK_MAP = void 0;
|
|
|
9
9
|
*
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
12
|
+
const config_build_events_1 = require("./events/config-build-events");
|
|
12
13
|
const schema_events_1 = require("./events/schema-events");
|
|
13
14
|
const diff_events_1 = require("./events/diff-events");
|
|
14
15
|
const render_root_types_events_1 = require("./events/render-root-types-events");
|
|
@@ -25,6 +26,7 @@ const print_type_events_1 = require("./events/print-type-events");
|
|
|
25
26
|
* They are pure transformations handled via the Formatter interface, not events.
|
|
26
27
|
*/
|
|
27
28
|
exports.EVENT_CALLBACK_MAP = {
|
|
29
|
+
[config_build_events_1.ConfigBuildEvents.AFTER_BUILD]: "afterConfigBuildHook",
|
|
28
30
|
[schema_events_1.SchemaEvents.BEFORE_LOAD]: "beforeLoadSchemaHook",
|
|
29
31
|
[schema_events_1.SchemaEvents.AFTER_LOAD]: "afterLoadSchemaHook",
|
|
30
32
|
[diff_events_1.DiffEvents.BEFORE_CHECK]: "beforeCheckDiffHook",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config build event constants.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Event name fired once after the final configuration has been resolved.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ConfigBuildEvents: {
|
|
10
|
+
/** Emitted after the final Options object has been resolved, before generation starts */
|
|
11
|
+
readonly AFTER_BUILD: "config:afterBuild";
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=config-build-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-build-events.d.ts","sourceRoot":"","sources":["../../src/events/config-build-events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC5B,yFAAyF;aACzF,WAAW,EAAE,mBAAmB;CACxB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Config build event constants.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ConfigBuildEvents = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Event name fired once after the final configuration has been resolved.
|
|
11
|
+
*/
|
|
12
|
+
exports.ConfigBuildEvents = {
|
|
13
|
+
/** Emitted after the final Options object has been resolved, before generation starts */
|
|
14
|
+
AFTER_BUILD: "config:afterBuild",
|
|
15
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config build event class.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { Options } from "@graphql-markdown/types";
|
|
7
|
+
import type { CancellableEventOptions } from "@graphql-markdown/utils";
|
|
8
|
+
import { DataEvent } from "@graphql-markdown/utils";
|
|
9
|
+
/**
|
|
10
|
+
* Event emitted after the final configuration has been resolved.
|
|
11
|
+
*
|
|
12
|
+
* @category Events
|
|
13
|
+
*/
|
|
14
|
+
export declare class ConfigBuildEvent extends DataEvent<{
|
|
15
|
+
config: Options;
|
|
16
|
+
}> {
|
|
17
|
+
constructor(data: {
|
|
18
|
+
config: Options;
|
|
19
|
+
}, options?: CancellableEventOptions);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=config-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-build.d.ts","sourceRoot":"","sources":["../../src/events/config-build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,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,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;IACA,YACE,IAAI,EAAE;QACJ,MAAM,EAAE,OAAO,CAAC;KACjB,EACD,OAAO,CAAC,EAAE,uBAAuB,EAGlC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Config build event class.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ConfigBuildEvent = void 0;
|
|
9
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
10
|
+
/**
|
|
11
|
+
* Event emitted after the final configuration has been resolved.
|
|
12
|
+
*
|
|
13
|
+
* @category Events
|
|
14
|
+
*/
|
|
15
|
+
class ConfigBuildEvent extends utils_1.DataEvent {
|
|
16
|
+
constructor(data, options) {
|
|
17
|
+
super(data, options);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ConfigBuildEvent = ConfigBuildEvent;
|
package/dist/events/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
+
export { ConfigBuildEvents } from "./config-build-events";
|
|
6
7
|
export { SchemaEvents } from "./schema-events";
|
|
7
8
|
export { DiffEvents } from "./diff-events";
|
|
8
9
|
export { RenderRootTypesEvents } from "./render-root-types-events";
|
|
@@ -11,6 +12,7 @@ export { RenderFilesEvents } from "./render-files-events";
|
|
|
11
12
|
export { RenderTypeEntitiesEvents } from "./render-type-entities-events";
|
|
12
13
|
export { GenerateIndexMetafileEvents } from "./generate-index-metafile-events";
|
|
13
14
|
export { PrintTypeEvents } from "./print-type-events";
|
|
15
|
+
export { ConfigBuildEvent } from "./config-build";
|
|
14
16
|
export { SchemaEvent } from "./schema-load";
|
|
15
17
|
export { DiffCheckEvent } from "./diff-check";
|
|
16
18
|
export { RenderRootTypesEvent } from "./render-root-types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,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|
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.GenerateIndexMetafileEvent = exports.RenderTypeEntitiesEvent = exports.RenderFilesEvent = exports.RenderHomepageEvent = exports.RenderRootTypesEvent = exports.DiffCheckEvent = exports.SchemaEvent = exports.PrintTypeEvents = exports.GenerateIndexMetafileEvents = exports.RenderTypeEntitiesEvents = exports.RenderFilesEvents = exports.RenderHomepageEvents = exports.RenderRootTypesEvents = exports.DiffEvents = exports.SchemaEvents = void 0;
|
|
8
|
+
exports.GenerateIndexMetafileEvent = exports.RenderTypeEntitiesEvent = exports.RenderFilesEvent = exports.RenderHomepageEvent = exports.RenderRootTypesEvent = exports.DiffCheckEvent = exports.SchemaEvent = exports.ConfigBuildEvent = exports.PrintTypeEvents = exports.GenerateIndexMetafileEvents = exports.RenderTypeEntitiesEvents = exports.RenderFilesEvents = exports.RenderHomepageEvents = exports.RenderRootTypesEvents = exports.DiffEvents = exports.SchemaEvents = exports.ConfigBuildEvents = void 0;
|
|
9
9
|
// Event constants
|
|
10
|
+
var config_build_events_1 = require("./config-build-events");
|
|
11
|
+
Object.defineProperty(exports, "ConfigBuildEvents", { enumerable: true, get: function () { return config_build_events_1.ConfigBuildEvents; } });
|
|
10
12
|
var schema_events_1 = require("./schema-events");
|
|
11
13
|
Object.defineProperty(exports, "SchemaEvents", { enumerable: true, get: function () { return schema_events_1.SchemaEvents; } });
|
|
12
14
|
var diff_events_1 = require("./diff-events");
|
|
@@ -25,6 +27,8 @@ Object.defineProperty(exports, "GenerateIndexMetafileEvents", { enumerable: true
|
|
|
25
27
|
var print_type_events_1 = require("./print-type-events");
|
|
26
28
|
Object.defineProperty(exports, "PrintTypeEvents", { enumerable: true, get: function () { return print_type_events_1.PrintTypeEvents; } });
|
|
27
29
|
// Event classes
|
|
30
|
+
var config_build_1 = require("./config-build");
|
|
31
|
+
Object.defineProperty(exports, "ConfigBuildEvent", { enumerable: true, get: function () { return config_build_1.ConfigBuildEvent; } });
|
|
28
32
|
var schema_load_1 = require("./schema-load");
|
|
29
33
|
Object.defineProperty(exports, "SchemaEvent", { enumerable: true, get: function () { return schema_load_1.SchemaEvent; } });
|
|
30
34
|
var diff_check_1 = require("./diff-check");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import type { GraphQLSchema,
|
|
6
|
+
import type { GraphQLSchema, SchemaMap } from "@graphql-markdown/types";
|
|
7
7
|
import type { CancellableEventOptions } from "@graphql-markdown/utils";
|
|
8
8
|
import { DataEvent } from "@graphql-markdown/utils";
|
|
9
9
|
/**
|
|
@@ -13,13 +13,13 @@ import { DataEvent } from "@graphql-markdown/utils";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class SchemaEvent extends DataEvent<{
|
|
15
15
|
schemaLocation?: string;
|
|
16
|
-
schema?:
|
|
17
|
-
rootTypes?:
|
|
16
|
+
schema?: GraphQLSchema | null;
|
|
17
|
+
rootTypes?: SchemaMap;
|
|
18
18
|
}> {
|
|
19
19
|
constructor(data: {
|
|
20
20
|
schemaLocation?: string;
|
|
21
|
-
schema?:
|
|
22
|
-
rootTypes?:
|
|
21
|
+
schema?: GraphQLSchema | null;
|
|
22
|
+
rootTypes?: SchemaMap;
|
|
23
23
|
}, options?: CancellableEventOptions);
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=schema-load.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-load.d.ts","sourceRoot":"","sources":["../../src/events/schema-load.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"schema-load.d.ts","sourceRoot":"","sources":["../../src/events/schema-load.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,SAAS,CAAC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;IACA,YACE,IAAI,EAAE;QACJ,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;QAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;KACvB,EACD,OAAO,CAAC,EAAE,uBAAuB,EAGlC;CACF"}
|
package/dist/generator.d.ts
CHANGED
|
@@ -100,5 +100,5 @@ export declare const resolveSkipAndOnlyDirectives: (onlyDocDirective: Maybe<Dire
|
|
|
100
100
|
* @param options - Complete configuration for the documentation generation
|
|
101
101
|
* @returns Promise that resolves when documentation is fully generated
|
|
102
102
|
*/
|
|
103
|
-
export declare const generateDocFromSchema: (
|
|
103
|
+
export declare const generateDocFromSchema: (options: GeneratorOptions) => Promise<void>;
|
|
104
104
|
//# sourceMappingURL=generator.d.ts.map
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AAiEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,cACb,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,KACrC,OAAO,CAAC,OAAO,CAYjB,CAAC;AAiBF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,aACzB,OAAO,gBACJ,MAAM,KACnB,CAAC,GAAG,SAmBN,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,cACzB,OAAO,SACX,QAAQ,KACd,OAAO,CAAC,SAAS,CAAC,GAAG,SA+CvB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,mBACZ,MAAM,eACT,KAAK,CAAC,YAAY,CAAC,KAC/B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAY9B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,sBAAsB,WACzB,aAAa,kBACL,MAAM,cACV,KAAK,CAAC,cAAc,CAAC,UACzB,MAAM,KACb,OAAO,CAAC,OAAO,CAWjB,CAAC;AAEF;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,4BAA4B,qBACrB,KAAK,CAAC,aAAa,GAAG,aAAa,EAAE,CAAC,oBACtC,KAAK,CAAC,aAAa,GAAG,aAAa,EAAE,CAAC,UAChD,aAAa,KACpB,gBAAgB,EAAE,EAsBpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,YACvB,gBAAgB,KACxB,OAAO,CAAC,IAAI,CA+Pd,CAAC"}
|
package/dist/generator.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
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
|
+
const printer_legacy_1 = require("@graphql-markdown/printer-legacy");
|
|
39
40
|
const utils_1 = require("@graphql-markdown/utils");
|
|
40
41
|
const node_path_1 = require("node:path");
|
|
41
42
|
const config_1 = require("./config");
|
|
@@ -277,15 +278,19 @@ exports.resolveSkipAndOnlyDirectives = resolveSkipAndOnlyDirectives;
|
|
|
277
278
|
* @param options - Complete configuration for the documentation generation
|
|
278
279
|
* @returns Promise that resolves when documentation is fully generated
|
|
279
280
|
*/
|
|
280
|
-
const generateDocFromSchema = async (
|
|
281
|
+
const generateDocFromSchema = async (options) => {
|
|
281
282
|
const start = process.hrtime.bigint();
|
|
282
|
-
await (0, logger_1.default)(loggerModule);
|
|
283
|
-
const mdxModule = await (0, exports.loadMDXModule)(formatter);
|
|
283
|
+
await (0, logger_1.default)(options.loggerModule);
|
|
284
|
+
const mdxModule = await (0, exports.loadMDXModule)(options.formatter);
|
|
284
285
|
// Register MDX lifecycle event handlers if mdxModule loaded successfully
|
|
285
286
|
// This must be called BEFORE getEvents() because it resets the singleton
|
|
286
287
|
(0, event_handlers_1.registerMDXEventHandlers)(mdxModule);
|
|
287
288
|
// Get events AFTER registration (registerMDXEventHandlers resets and recreates the singleton)
|
|
288
289
|
const events = (0, event_emitter_1.getEvents)();
|
|
290
|
+
// Emitted before destructuring `options` below, so a hook that mutates
|
|
291
|
+
// `event.data.config` (same object reference as `options`) is picked up.
|
|
292
|
+
await events.emitAsync(events_1.ConfigBuildEvents.AFTER_BUILD, new events_1.ConfigBuildEvent({ config: options }));
|
|
293
|
+
const { baseURL, customDirective, decorators, diffMethod, docOptions, force, groupByDirective, homepageLocation, linkRoot, loaders: loadersList, metatags, onlyDocDirective, outputAdapter, outputDir, prettify, printTypeOptions, schemaLocation, skipDocDirective, tmpDir, } = options;
|
|
289
294
|
await events.emitAsync(events_1.SchemaEvents.BEFORE_LOAD, new events_1.SchemaEvent({
|
|
290
295
|
schemaLocation: schemaLocation,
|
|
291
296
|
}));
|
|
@@ -308,7 +313,14 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
|
|
|
308
313
|
events.emit(events_1.SchemaEvents.BEFORE_MAP, new events_1.SchemaEvent({ schema }));
|
|
309
314
|
const rootTypes = (0, graphql_1.getSchemaMap)(schema);
|
|
310
315
|
events.emit(events_1.SchemaEvents.AFTER_MAP, new events_1.SchemaEvent({ schema, rootTypes }));
|
|
311
|
-
|
|
316
|
+
// `customDirective` is schema-resolved here, then immediately converted
|
|
317
|
+
// into decorators and merged into `decorators` itself: the printer never
|
|
318
|
+
// sees `customDirective` or the resolved `CustomDirectiveMap` it produces,
|
|
319
|
+
// only the merged decorators (see `buildCustomDirectiveDecorators`).
|
|
320
|
+
const decoratorsWithCustomDirective = {
|
|
321
|
+
...(0, printer_legacy_1.buildCustomDirectiveDecorators)((0, graphql_1.getCustomDirectives)(rootTypes, customDirective)),
|
|
322
|
+
...decorators,
|
|
323
|
+
};
|
|
312
324
|
const groups = (0, graphql_1.getGroups)(rootTypes, groupByDirective);
|
|
313
325
|
// Extract formatter from the MDX module (for direct function calls)
|
|
314
326
|
const mdxFormatter = (0, exports.getFormatterFromMDXModule)(mdxModule, docOptions);
|
|
@@ -323,7 +335,7 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
|
|
|
323
335
|
},
|
|
324
336
|
// options
|
|
325
337
|
{
|
|
326
|
-
|
|
338
|
+
decorators: decoratorsWithCustomDirective,
|
|
327
339
|
groups,
|
|
328
340
|
meta: {
|
|
329
341
|
generatorFrameworkName: docOptions?.generatorFrameworkName,
|
|
@@ -349,12 +361,21 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
|
|
|
349
361
|
else {
|
|
350
362
|
mdxExtension = FILE_EXTENSION.MD;
|
|
351
363
|
}
|
|
352
|
-
const renderer = await (0, renderer_1.getRenderer)(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
364
|
+
const renderer = await (0, renderer_1.getRenderer)({
|
|
365
|
+
printer,
|
|
366
|
+
outputDir,
|
|
367
|
+
baseURL,
|
|
368
|
+
group: groups,
|
|
369
|
+
prettify,
|
|
370
|
+
docOptions: {
|
|
371
|
+
...docOptions,
|
|
372
|
+
deprecated: printTypeOptions?.deprecated,
|
|
373
|
+
force,
|
|
374
|
+
hierarchy: printTypeOptions?.hierarchy,
|
|
375
|
+
},
|
|
376
|
+
mdxExtension,
|
|
377
|
+
outputAdapter,
|
|
378
|
+
});
|
|
358
379
|
// Pre-collect all categories before rendering to ensure consistent positions
|
|
359
380
|
renderer.preCollectCategories(Object.keys(rootTypes));
|
|
360
381
|
const beforeRenderRootTypesEvent = new events_1.RenderRootTypesEvent({
|
package/dist/graphql-config.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const graphQLConfigExtension: GraphQLExtensionDeclaration;
|
|
|
28
28
|
* @property throwOnMissing Whether to throw when the config file is missing.
|
|
29
29
|
* @property throwOnEmpty Whether to throw when the config is empty.
|
|
30
30
|
*/
|
|
31
|
-
interface ThrowOptions {
|
|
31
|
+
export interface ThrowOptions {
|
|
32
32
|
throwOnMissing?: boolean;
|
|
33
33
|
throwOnEmpty?: boolean;
|
|
34
34
|
}
|
|
@@ -85,5 +85,4 @@ export declare const setLoaderOptions: (loaders: LoaderOption, options: PackageO
|
|
|
85
85
|
* ```
|
|
86
86
|
*/
|
|
87
87
|
export declare const loadConfiguration: (id: Maybe<string>, options?: Maybe<PackageOptionsConfig>, { throwOnMissing, throwOnEmpty }?: ThrowOptions) => Promise<Maybe<Readonly<ExtensionProjectConfig>>>;
|
|
88
|
-
export {};
|
|
89
88
|
//# sourceMappingURL=graphql-config.d.ts.map
|
|
@@ -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;AAgBjC;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,sBAAsB,EAAE,2BAEpC,CAAC;AAEF;;;;;;GAMG;AACH,
|
|
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;AAEH,eAAO,MAAM,sBAAsB,EAAE,2BAEpC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAWD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { generateDocFromSchema } from "./generator";
|
|
5
5
|
export { buildConfig } from "./config";
|
|
6
|
-
export { getEvents, resetEvents, type EmitResult } from "./event-emitter";
|
|
6
|
+
export { getEvents, resetEvents, type CancellableEventEmitter, type EmitResult, } from "./event-emitter";
|
|
7
7
|
export { registerMDXEventHandlers } from "./event-handlers";
|
|
8
8
|
export { EVENT_CALLBACK_MAP } from "./event-map";
|
|
9
9
|
export { SchemaEvents } from "./events/schema-events";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EACL,SAAS,EACT,WAAW,EACX,KAAK,uBAAuB,EAC5B,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,YAAY,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
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @primaryExport
|
|
4
4
|
*/
|
|
5
|
-
/* istanbul ignore file */
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
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
7
|
var generator_1 = require("./generator");
|
package/dist/renderer.d.ts
CHANGED
|
@@ -73,6 +73,27 @@ export interface CategoryMetafileOptions {
|
|
|
73
73
|
* @param errors - Errors collected from the handlers
|
|
74
74
|
*/
|
|
75
75
|
export declare const logHandlerErrors: (eventName: string, errors: Error[]) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Constructor options for {@link Renderer}, and input to {@link getRenderer}.
|
|
78
|
+
*/
|
|
79
|
+
export interface RendererOptions {
|
|
80
|
+
/** The printer instance used to convert GraphQL types to markdown */
|
|
81
|
+
printer: typeof IPrinter;
|
|
82
|
+
/** Directory where documentation will be generated */
|
|
83
|
+
outputDir: string;
|
|
84
|
+
/** Base URL for the documentation */
|
|
85
|
+
baseURL: string;
|
|
86
|
+
/** Optional grouping configuration for schema entities */
|
|
87
|
+
group: Maybe<SchemaEntitiesGroupMap>;
|
|
88
|
+
/** Whether to format the generated markdown */
|
|
89
|
+
prettify: boolean;
|
|
90
|
+
/** Additional documentation options */
|
|
91
|
+
docOptions: Maybe<RendererDocOptions>;
|
|
92
|
+
/** Optional MDX file extension to use */
|
|
93
|
+
mdxExtension: string;
|
|
94
|
+
/** Destination for generated pages; defaults to the local filesystem */
|
|
95
|
+
outputAdapter?: OutputAdapter | null;
|
|
96
|
+
}
|
|
76
97
|
/**
|
|
77
98
|
* Core renderer class responsible for generating documentation files from GraphQL schema entities.
|
|
78
99
|
* Handles the conversion of schema types to markdown/MDX documentation with proper organization.
|
|
@@ -98,17 +119,10 @@ export declare class Renderer {
|
|
|
98
119
|
/**
|
|
99
120
|
* Creates a new Renderer instance.
|
|
100
121
|
*
|
|
101
|
-
* @param
|
|
102
|
-
* @param outputDir - Directory where documentation will be generated
|
|
103
|
-
* @param baseURL - Base URL for the documentation
|
|
104
|
-
* @param group - Optional grouping configuration for schema entities
|
|
105
|
-
* @param prettify - Whether to format the generated markdown
|
|
106
|
-
* @param docOptions - Additional documentation options
|
|
107
|
-
* @param mdxExtension - Optional MDX file extension to use
|
|
108
|
-
* @param outputAdapter - Destination for generated pages; defaults to the local filesystem
|
|
122
|
+
* @param options - Renderer construction options
|
|
109
123
|
* @example
|
|
110
124
|
*/
|
|
111
|
-
constructor(printer
|
|
125
|
+
constructor({ printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension, outputAdapter, }: RendererOptions);
|
|
112
126
|
/**
|
|
113
127
|
* Generates an index metafile for a category directory if MDX support is available.
|
|
114
128
|
*
|
|
@@ -152,10 +166,12 @@ export declare class Renderer {
|
|
|
152
166
|
* @param dirPath - The directory path where the file should be saved
|
|
153
167
|
* @param name - The name of the type entity
|
|
154
168
|
* @param type - The type entity to render
|
|
169
|
+
* @param operationNamespaceParts - The namespace parts for a namespaced operation
|
|
170
|
+
* @param entity - The schema entity kind being rendered, e.g. `queries`
|
|
155
171
|
* @returns The category information for the rendered entity or undefined
|
|
156
172
|
* @example
|
|
157
173
|
*/
|
|
158
|
-
renderTypeEntities(dirPath: string, name: string, type: unknown, operationNamespaceParts?: string[]): Promise<Maybe<Category>>;
|
|
174
|
+
renderTypeEntities(dirPath: string, name: string, type: unknown, operationNamespaceParts?: string[], entity?: SchemaEntity): Promise<Maybe<Category>>;
|
|
159
175
|
/**
|
|
160
176
|
* Pre-collects all category names that will be generated during rendering.
|
|
161
177
|
* This allows the position manager to assign consistent positions before
|
|
@@ -245,26 +261,21 @@ export declare class Renderer {
|
|
|
245
261
|
* Factory function to create and initialize a Renderer instance.
|
|
246
262
|
* Creates the output directory and returns a configured renderer.
|
|
247
263
|
*
|
|
248
|
-
* @param
|
|
249
|
-
* @param outputDir - The output directory for generated documentation
|
|
250
|
-
* @param baseURL - The base URL for the documentation
|
|
251
|
-
* @param group - Optional grouping configuration
|
|
252
|
-
* @param prettify - Whether to prettify the output markdown
|
|
253
|
-
* @param docOptions - Additional documentation options
|
|
254
|
-
* @param mdxExtension - Extension to use for MDX files
|
|
264
|
+
* @param options - Renderer construction options
|
|
255
265
|
* @returns A configured Renderer instance
|
|
256
266
|
*
|
|
257
267
|
* @example
|
|
258
268
|
* ```typescript
|
|
259
|
-
* const renderer = await getRenderer(
|
|
260
|
-
* myPrinter,
|
|
261
|
-
* './docs',
|
|
262
|
-
* '/api',
|
|
263
|
-
* groupConfig,
|
|
264
|
-
* true,
|
|
265
|
-
* { force: true, index: true }
|
|
266
|
-
*
|
|
269
|
+
* const renderer = await getRenderer({
|
|
270
|
+
* printer: myPrinter,
|
|
271
|
+
* outputDir: './docs',
|
|
272
|
+
* baseURL: '/api',
|
|
273
|
+
* group: groupConfig,
|
|
274
|
+
* prettify: true,
|
|
275
|
+
* docOptions: { force: true, index: true },
|
|
276
|
+
* mdxExtension: '.mdx',
|
|
277
|
+
* });
|
|
267
278
|
* ```
|
|
268
279
|
*/
|
|
269
|
-
export declare const getRenderer: (printer
|
|
280
|
+
export declare const getRenderer: ({ printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension, outputAdapter, }: RendererOptions) => Promise<InstanceType<typeof Renderer>>;
|
|
270
281
|
//# sourceMappingURL=renderer.d.ts.map
|
package/dist/renderer.d.ts.map
CHANGED
|
@@ -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,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EAGb,MAAM,yBAAyB,CAAC;AA0FjC;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,oBAAoB,CAG5C,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,iBAAiB,SACtB,OAAO,WACJ,KAAK,CAAC,oBAAoB,GAAG,OAAO,CAAC,KAC7C,MAMF,CAAC;AA6CF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAoGD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,cAAe,MAAM,UAAU,KAAK,EAAE,KAAG,IAIrE,CAAC;AAEF;;;;;;;;;;GAUG;AAGH,qBAAa,QAAQ;IACnB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAA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AI,EAAE,MAAM,EACZ,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,MAAM,CAAC,CAsEjB;IAED;;;;;;;OAOG;IACG,eAAe,CACnB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAsDnC;IAED;;;;;;;;;;OAUG;IACG,kBAAkB,CACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,uBAAuB,CAAC,EAAE,MAAM,EAAE,EAClC,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CA4H1B;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,IAAI,CAwClD;IAED;;;;;;;OAOG;IACG,cAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCnE;IAED;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;IAiClC;;;;;;;OAOG;IACH,OAAO,CAAC,wBAAwB;IAiBhC;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAiCtC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,wBAAwB;IAgChC;;;;;;;;;OASG;YACW,WAAW;CAM1B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,WAAW,+FASrB,eAAe,KAAG,OAAO,CAAC,YAAY,CAAC,OAAO,QAAQ,CAAC,CAezD,CAAC"}
|
package/dist/renderer.js
CHANGED
|
@@ -289,17 +289,10 @@ class Renderer {
|
|
|
289
289
|
/**
|
|
290
290
|
* Creates a new Renderer instance.
|
|
291
291
|
*
|
|
292
|
-
* @param
|
|
293
|
-
* @param outputDir - Directory where documentation will be generated
|
|
294
|
-
* @param baseURL - Base URL for the documentation
|
|
295
|
-
* @param group - Optional grouping configuration for schema entities
|
|
296
|
-
* @param prettify - Whether to format the generated markdown
|
|
297
|
-
* @param docOptions - Additional documentation options
|
|
298
|
-
* @param mdxExtension - Optional MDX file extension to use
|
|
299
|
-
* @param outputAdapter - Destination for generated pages; defaults to the local filesystem
|
|
292
|
+
* @param options - Renderer construction options
|
|
300
293
|
* @example
|
|
301
294
|
*/
|
|
302
|
-
constructor(printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension, outputAdapter = undefined) {
|
|
295
|
+
constructor({ printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension, outputAdapter = undefined, }) {
|
|
303
296
|
this.printer = printer;
|
|
304
297
|
this.group = group;
|
|
305
298
|
this.outputDir = outputDir;
|
|
@@ -461,7 +454,7 @@ class Renderer {
|
|
|
461
454
|
}
|
|
462
455
|
}
|
|
463
456
|
}
|
|
464
|
-
return this.renderTypeEntities(dirPath, entityName, type[name], operationNamespaceParts);
|
|
457
|
+
return this.renderTypeEntities(dirPath, entityName, type[name], operationNamespaceParts, rootTypeName);
|
|
465
458
|
}));
|
|
466
459
|
}
|
|
467
460
|
/**
|
|
@@ -470,10 +463,12 @@ class Renderer {
|
|
|
470
463
|
* @param dirPath - The directory path where the file should be saved
|
|
471
464
|
* @param name - The name of the type entity
|
|
472
465
|
* @param type - The type entity to render
|
|
466
|
+
* @param operationNamespaceParts - The namespace parts for a namespaced operation
|
|
467
|
+
* @param entity - The schema entity kind being rendered, e.g. `queries`
|
|
473
468
|
* @returns The category information for the rendered entity or undefined
|
|
474
469
|
* @example
|
|
475
470
|
*/
|
|
476
|
-
async renderTypeEntities(dirPath, name, type, operationNamespaceParts) {
|
|
471
|
+
async renderTypeEntities(dirPath, name, type, operationNamespaceParts, entity) {
|
|
477
472
|
if (!(0, validation_1.isPath)(dirPath)) {
|
|
478
473
|
throw new Error("Output directory is empty or not specified");
|
|
479
474
|
}
|
|
@@ -483,7 +478,15 @@ class Renderer {
|
|
|
483
478
|
// NOSONAR - pattern is safe, hyphen in character class doesn't cause backtracking
|
|
484
479
|
const PageRegex = /(?<category>[a-z0-9-]+)[\\/]+(?<pageId>[a-z0-9-]+)\.mdx?$/i; // NOSONAR
|
|
485
480
|
const PageRegexFlat = /(?<pageId>[a-z0-9-]+)\.mdx?$/i; // NOSONAR
|
|
486
|
-
const
|
|
481
|
+
const isFlat = isHierarchy(this.options, config_1.TypeHierarchy.FLAT);
|
|
482
|
+
// Flat hierarchy has no folders to keep same-named entities of different
|
|
483
|
+
// kinds apart (a `type User` and a `Query.user` field both slugify to
|
|
484
|
+
// "user") — prefixing with `entity` (the `SchemaEntity` root type this
|
|
485
|
+
// came from, e.g. "objects" vs "queries") keeps every flat filename
|
|
486
|
+
// unique the same way the folder structure already does for "api"/
|
|
487
|
+
// "entity" hierarchy. `link.ts`'s `toLink` builds the matching prefix for
|
|
488
|
+
// cross-references under flat hierarchy — the two must stay in sync.
|
|
489
|
+
const fileName = isFlat && entity ? `${entity}-${(0, utils_1.slugify)(name)}` : (0, utils_1.slugify)(name);
|
|
487
490
|
const filePath = (0, node_path_1.join)((0, node_path_1.normalize)(dirPath), `${fileName}${this.mdxExtension}`);
|
|
488
491
|
let content;
|
|
489
492
|
try {
|
|
@@ -514,6 +517,7 @@ class Renderer {
|
|
|
514
517
|
...(operationNamespaceParts === undefined
|
|
515
518
|
? {}
|
|
516
519
|
: { operationNamespaceParts }),
|
|
520
|
+
...(entity === undefined ? {} : { entity }),
|
|
517
521
|
};
|
|
518
522
|
content = await this.printer.printType(fileName, type, printOptions);
|
|
519
523
|
if (typeof content !== "string" || content === "") {
|
|
@@ -527,7 +531,6 @@ class Renderer {
|
|
|
527
531
|
}
|
|
528
532
|
await this.writeOutput(filePath, content);
|
|
529
533
|
const pagePath = (0, node_path_1.relative)(this.outputDir, filePath);
|
|
530
|
-
const isFlat = isHierarchy(this.options, config_1.TypeHierarchy.FLAT);
|
|
531
534
|
const page = isFlat
|
|
532
535
|
? PageRegexFlat.exec(pagePath)
|
|
533
536
|
: PageRegex.exec(pagePath);
|
|
@@ -797,32 +800,36 @@ exports.Renderer = Renderer;
|
|
|
797
800
|
* Factory function to create and initialize a Renderer instance.
|
|
798
801
|
* Creates the output directory and returns a configured renderer.
|
|
799
802
|
*
|
|
800
|
-
* @param
|
|
801
|
-
* @param outputDir - The output directory for generated documentation
|
|
802
|
-
* @param baseURL - The base URL for the documentation
|
|
803
|
-
* @param group - Optional grouping configuration
|
|
804
|
-
* @param prettify - Whether to prettify the output markdown
|
|
805
|
-
* @param docOptions - Additional documentation options
|
|
806
|
-
* @param mdxExtension - Extension to use for MDX files
|
|
803
|
+
* @param options - Renderer construction options
|
|
807
804
|
* @returns A configured Renderer instance
|
|
808
805
|
*
|
|
809
806
|
* @example
|
|
810
807
|
* ```typescript
|
|
811
|
-
* const renderer = await getRenderer(
|
|
812
|
-
* myPrinter,
|
|
813
|
-
* './docs',
|
|
814
|
-
* '/api',
|
|
815
|
-
* groupConfig,
|
|
816
|
-
* true,
|
|
817
|
-
* { force: true, index: true }
|
|
818
|
-
*
|
|
808
|
+
* const renderer = await getRenderer({
|
|
809
|
+
* printer: myPrinter,
|
|
810
|
+
* outputDir: './docs',
|
|
811
|
+
* baseURL: '/api',
|
|
812
|
+
* group: groupConfig,
|
|
813
|
+
* prettify: true,
|
|
814
|
+
* docOptions: { force: true, index: true },
|
|
815
|
+
* mdxExtension: '.mdx',
|
|
816
|
+
* });
|
|
819
817
|
* ```
|
|
820
818
|
*/
|
|
821
|
-
const getRenderer = async (printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension, outputAdapter = undefined) => {
|
|
819
|
+
const getRenderer = async ({ printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension, outputAdapter = undefined, }) => {
|
|
822
820
|
const adapter = outputAdapter ?? utils_1.fsOutputAdapter;
|
|
823
821
|
// Optional on the interface: a destination with no directory concept (an
|
|
824
822
|
// object store, a CMS collection) has nothing to prepare.
|
|
825
823
|
await adapter.ensureDir?.(outputDir, { forceEmpty: docOptions?.force });
|
|
826
|
-
return new Renderer(
|
|
824
|
+
return new Renderer({
|
|
825
|
+
printer,
|
|
826
|
+
outputDir,
|
|
827
|
+
baseURL,
|
|
828
|
+
group,
|
|
829
|
+
prettify,
|
|
830
|
+
docOptions,
|
|
831
|
+
mdxExtension,
|
|
832
|
+
outputAdapter: adapter,
|
|
833
|
+
});
|
|
827
834
|
};
|
|
828
835
|
exports.getRenderer = getRenderer;
|