@graphql-markdown/core 1.17.0 → 1.17.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.
- package/dist/event-emitter.d.ts.map +1 -1
- package/dist/event-emitter.js +1 -3
- package/dist/event-handlers.d.ts +6 -3
- package/dist/event-handlers.d.ts.map +1 -1
- package/dist/event-handlers.js +10 -7
- package/dist/event-map.d.ts +7 -0
- package/dist/event-map.d.ts.map +1 -1
- package/dist/event-map.js +8 -0
- package/dist/events/base.d.ts +8 -3
- package/dist/events/base.d.ts.map +1 -1
- package/dist/events/base.js +6 -5
- package/dist/events/diff-check.d.ts +11 -11
- package/dist/events/diff-check.d.ts.map +1 -1
- package/dist/events/diff-check.js +5 -8
- package/dist/events/generate-index-metafile.d.ts +8 -11
- package/dist/events/generate-index-metafile.d.ts.map +1 -1
- package/dist/events/generate-index-metafile.js +5 -11
- package/dist/events/index.d.ts +4 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +7 -2
- package/dist/events/print-type-events.d.ts +33 -0
- package/dist/events/print-type-events.d.ts.map +1 -0
- package/dist/events/print-type-events.js +35 -0
- package/dist/events/print-type.d.ts +84 -0
- package/dist/events/print-type.d.ts.map +1 -0
- package/dist/events/print-type.js +73 -0
- package/dist/events/render-homepage.d.ts +6 -7
- package/dist/events/render-homepage.d.ts.map +1 -1
- package/dist/events/render-homepage.js +5 -5
- package/dist/events/render-root-types.d.ts +6 -7
- package/dist/events/render-root-types.d.ts.map +1 -1
- package/dist/events/render-root-types.js +5 -5
- package/dist/events/render-type-entities.d.ts +7 -9
- package/dist/events/render-type-entities.d.ts.map +1 -1
- package/dist/events/render-type-entities.js +5 -8
- package/dist/events/schema-events.d.ts +4 -0
- package/dist/events/schema-events.d.ts.map +1 -1
- package/dist/events/schema-events.js +4 -0
- package/dist/events/schema-load.d.ts +13 -9
- package/dist/events/schema-load.d.ts.map +1 -1
- package/dist/events/schema-load.js +8 -8
- package/dist/generator.d.ts +79 -1
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +222 -49
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/printer.d.ts +3 -3
- package/dist/printer.d.ts.map +1 -1
- package/dist/printer.js +3 -3
- package/dist/renderer.d.ts +10 -10
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +12 -22
- package/package.json +9 -9
- package/dist/event-types.d.ts +0 -313
- package/dist/event-types.d.ts.map +0 -1
- package/dist/event-types.js +0 -309
- package/dist/hooks.d.ts +0 -10
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js +0 -33
package/dist/generator.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.generateDocFromSchema = void 0;
|
|
36
|
+
exports.generateDocFromSchema = exports.resolveSkipAndOnlyDirectives = exports.checkSchemaDifferences = exports.loadGraphqlSchema = exports.getFormatterFromMDXModule = exports.loadMDXModule = exports.FILE_EXTENSION = 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");
|
|
@@ -44,6 +44,17 @@ const renderer_1 = require("./renderer");
|
|
|
44
44
|
const event_emitter_1 = require("./event-emitter");
|
|
45
45
|
const events_1 = require("./events");
|
|
46
46
|
const event_handlers_1 = require("./event-handlers");
|
|
47
|
+
/**
|
|
48
|
+
* Supported file extensions for generated documentation files.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* - MDX: MDX file extension (.mdx) for React component-enabled markdown
|
|
52
|
+
* - MD: Standard markdown file extension (.md)
|
|
53
|
+
*/
|
|
54
|
+
exports.FILE_EXTENSION = {
|
|
55
|
+
MDX: ".mdx",
|
|
56
|
+
MD: ".md",
|
|
57
|
+
};
|
|
47
58
|
/**
|
|
48
59
|
* Constant representing nanoseconds per second.
|
|
49
60
|
*
|
|
@@ -58,56 +69,159 @@ const NS_PER_SEC = 1e9;
|
|
|
58
69
|
*/
|
|
59
70
|
const SEC_DECIMALS = 3;
|
|
60
71
|
/**
|
|
61
|
-
*
|
|
72
|
+
* Asynchronously loads an MDX module dynamically.
|
|
62
73
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* - Initializes printers and renderers
|
|
68
|
-
* - Generates markdown files
|
|
74
|
+
* @param mdxParser - The MDX parser package name or path to import. Can be null or undefined.
|
|
75
|
+
* @returns A promise that resolves to the imported module, or undefined if:
|
|
76
|
+
* - The mdxParser parameter is null or undefined
|
|
77
|
+
* - An error occurs during import (logs a warning and returns undefined)
|
|
69
78
|
*
|
|
70
|
-
* @
|
|
71
|
-
* @returns Promise that resolves when documentation is fully generated
|
|
79
|
+
* @internal
|
|
72
80
|
*/
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
const loadMDXModule = async (mdxParser) => {
|
|
82
|
+
return mdxParser !== undefined && mdxParser !== null
|
|
83
|
+
? Promise.resolve(`${mdxParser}`).then(s => __importStar(require(s))).catch((err) => {
|
|
84
|
+
const errorMessage = err instanceof Error ? err.message : String(err ?? "Unknown error");
|
|
85
|
+
(0, logger_1.log)(`An error occurred while loading MDX formatter "${mdxParser}"\n${errorMessage}`, logger_1.LogLevel.warn);
|
|
86
|
+
return undefined;
|
|
87
|
+
})
|
|
88
|
+
: undefined;
|
|
89
|
+
};
|
|
90
|
+
exports.loadMDXModule = loadMDXModule;
|
|
91
|
+
/**
|
|
92
|
+
* List of formatter function names that can be exported individually from an MDX module.
|
|
93
|
+
*/
|
|
94
|
+
const FORMATTER_FUNCTION_NAMES = [
|
|
95
|
+
"formatMDXBadge",
|
|
96
|
+
"formatMDXAdmonition",
|
|
97
|
+
"formatMDXBullet",
|
|
98
|
+
"formatMDXDetails",
|
|
99
|
+
"formatMDXFrontmatter",
|
|
100
|
+
"formatMDXLink",
|
|
101
|
+
"formatMDXNameEntity",
|
|
102
|
+
"formatMDXSpecifiedByLink",
|
|
103
|
+
];
|
|
104
|
+
/**
|
|
105
|
+
* Extracts a formatter from an MDX module.
|
|
106
|
+
*
|
|
107
|
+
* Checks for formatter functions in the following order:
|
|
108
|
+
* 1. A `createMDXFormatter` factory function (for internal/advanced usage)
|
|
109
|
+
* 2. Individual exported formatter functions (e.g., `formatMDXBadge`, `formatMDXAdmonition`)
|
|
110
|
+
*
|
|
111
|
+
* @param mdxModule - The loaded MDX module that may contain formatter exports
|
|
112
|
+
* @param meta - Optional metadata to pass to the formatter factory
|
|
113
|
+
* @returns A partial Formatter with the found functions, or undefined if none found
|
|
114
|
+
*
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
const getFormatterFromMDXModule = (mdxModule, meta) => {
|
|
118
|
+
if (!mdxModule || typeof mdxModule !== "object") {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
const module = mdxModule;
|
|
122
|
+
// Check for createMDXFormatter on the module directly (internal/advanced usage)
|
|
123
|
+
if ("createMDXFormatter" in module &&
|
|
124
|
+
typeof module.createMDXFormatter === "function") {
|
|
125
|
+
return module.createMDXFormatter(meta);
|
|
126
|
+
}
|
|
127
|
+
// Check for createMDXFormatter on module.default (ESM default export)
|
|
128
|
+
const defaultExport = module.default;
|
|
129
|
+
if (defaultExport &&
|
|
130
|
+
"createMDXFormatter" in defaultExport &&
|
|
131
|
+
typeof defaultExport.createMDXFormatter === "function") {
|
|
132
|
+
return defaultExport.createMDXFormatter(meta);
|
|
133
|
+
}
|
|
134
|
+
// Check for individual formatter functions
|
|
135
|
+
const formatter = {};
|
|
136
|
+
let hasFormatter = false;
|
|
137
|
+
for (const funcName of FORMATTER_FUNCTION_NAMES) {
|
|
138
|
+
if (funcName in module && typeof module[funcName] === "function") {
|
|
139
|
+
formatter[funcName] = module[funcName];
|
|
140
|
+
hasFormatter = true;
|
|
141
|
+
}
|
|
142
|
+
else if (defaultExport &&
|
|
143
|
+
funcName in defaultExport &&
|
|
144
|
+
typeof defaultExport[funcName] === "function") {
|
|
145
|
+
formatter[funcName] =
|
|
146
|
+
defaultExport[funcName];
|
|
147
|
+
hasFormatter = true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return hasFormatter ? formatter : undefined;
|
|
151
|
+
};
|
|
152
|
+
exports.getFormatterFromMDXModule = getFormatterFromMDXModule;
|
|
153
|
+
/**
|
|
154
|
+
* Loads a GraphQL schema from the specified location using configured document loaders.
|
|
155
|
+
*
|
|
156
|
+
* @param schemaLocation - The location/path of the GraphQL schema to load (e.g., file path, URL, or glob pattern).
|
|
157
|
+
* @param loadersList - Optional loader configuration for customizing how the schema is loaded.
|
|
158
|
+
*
|
|
159
|
+
* @returns A promise that resolves to the loaded GraphQL schema, or undefined if:
|
|
160
|
+
* - The loaders cannot be initialized
|
|
161
|
+
* - An error occurs during schema loading
|
|
162
|
+
*
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
const loadGraphqlSchema = async (schemaLocation, loadersList) => {
|
|
76
166
|
const loaders = await (0, graphql_1.getDocumentLoaders)(loadersList);
|
|
77
167
|
if (!loaders) {
|
|
78
168
|
(0, logger_1.log)(`An error occurred while loading GraphQL loader.\nCheck your dependencies and configuration.`, "error");
|
|
79
|
-
return;
|
|
169
|
+
return undefined;
|
|
80
170
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
171
|
+
return (0, graphql_1.loadSchema)(schemaLocation, loaders);
|
|
172
|
+
};
|
|
173
|
+
exports.loadGraphqlSchema = loadGraphqlSchema;
|
|
174
|
+
/**
|
|
175
|
+
* Checks if there are differences in the GraphQL schema compared to a previous version.
|
|
176
|
+
*
|
|
177
|
+
* @param schema - The GraphQL schema to check for differences.
|
|
178
|
+
* @param schemaLocation - The location/path of the schema file for logging purposes.
|
|
179
|
+
* @param diffMethod - The method to use for detecting differences. If set to `NONE`, changes detection is skipped.
|
|
180
|
+
* @param tmpDir - The temporary directory path used for storing and comparing schema versions.
|
|
181
|
+
*
|
|
182
|
+
* @returns A promise that resolves to `true` if changes are detected or if diff method is `NONE`,
|
|
183
|
+
* or `false` if no changes are detected.
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* When no changes are detected, a log message is generated indicating that the schema is unchanged.
|
|
187
|
+
*/
|
|
188
|
+
const checkSchemaDifferences = async (schema, schemaLocation, diffMethod, tmpDir) => {
|
|
189
|
+
let changed = true;
|
|
91
190
|
if (diffMethod !== config_1.DiffMethod.NONE) {
|
|
92
|
-
|
|
93
|
-
schema,
|
|
94
|
-
outputDir: tmpDir,
|
|
95
|
-
});
|
|
96
|
-
await events.emitAsync(events_1.DiffEvents.BEFORE_CHECK, beforeDiffEvent);
|
|
97
|
-
const changed = await (0, diff_1.hasChanges)(schema, tmpDir, diffMethod);
|
|
191
|
+
changed = await (0, diff_1.hasChanges)(schema, tmpDir, diffMethod);
|
|
98
192
|
if (!changed) {
|
|
99
193
|
(0, logger_1.log)(`No changes detected in schema "${(0, utils_1.toString)(schemaLocation)}".`);
|
|
100
194
|
}
|
|
101
|
-
const afterDiffEvent = new events_1.DiffCheckEvent({
|
|
102
|
-
schema,
|
|
103
|
-
outputDir: tmpDir,
|
|
104
|
-
});
|
|
105
|
-
await events.emitAsync(events_1.DiffEvents.AFTER_CHECK, afterDiffEvent);
|
|
106
195
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
196
|
+
return changed;
|
|
197
|
+
};
|
|
198
|
+
exports.checkSchemaDifferences = checkSchemaDifferences;
|
|
199
|
+
/**
|
|
200
|
+
* Resolves and retrieves GraphQL directive objects from the schema based on their names.
|
|
201
|
+
*
|
|
202
|
+
* Takes two lists of directive names (for "only" and "skip" documentation directives),
|
|
203
|
+
* looks them up in the provided GraphQL schema, and returns the resolved directive objects.
|
|
204
|
+
*
|
|
205
|
+
* @param onlyDocDirective - A directive name or array of directive names for "only" documentation filtering
|
|
206
|
+
* @param skipDocDirective - A directive name or array of directive names for "skip" documentation filtering
|
|
207
|
+
* @param schema - The GraphQL schema to resolve directives from
|
|
208
|
+
*
|
|
209
|
+
* @returns A tuple containing two arrays: the first with resolved "only" directives,
|
|
210
|
+
* the second with resolved "skip" directives. Only defined directives are included.
|
|
211
|
+
*/
|
|
212
|
+
const resolveSkipAndOnlyDirectives = (onlyDocDirective, skipDocDirective, schema) => {
|
|
213
|
+
return [onlyDocDirective, skipDocDirective].map((directive) => {
|
|
214
|
+
// Normalize to array and filter out null/undefined
|
|
215
|
+
let directiveList;
|
|
216
|
+
if (Array.isArray(directive)) {
|
|
217
|
+
directiveList = directive;
|
|
218
|
+
}
|
|
219
|
+
else if (directive) {
|
|
220
|
+
directiveList = [directive];
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
directiveList = [];
|
|
224
|
+
}
|
|
111
225
|
return directiveList
|
|
112
226
|
.map((name) => {
|
|
113
227
|
return schema.getDirective(name);
|
|
@@ -116,17 +230,60 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
|
|
|
116
230
|
return directive !== undefined;
|
|
117
231
|
});
|
|
118
232
|
});
|
|
233
|
+
};
|
|
234
|
+
exports.resolveSkipAndOnlyDirectives = resolveSkipAndOnlyDirectives;
|
|
235
|
+
/**
|
|
236
|
+
* Main entry point for generating Markdown documentation from a GraphQL schema.
|
|
237
|
+
*
|
|
238
|
+
* This function coordinates the entire documentation generation process:
|
|
239
|
+
* - Loads and validates the schema
|
|
240
|
+
* - Checks for schema changes if diffing is enabled
|
|
241
|
+
* - Processes directives and groups
|
|
242
|
+
* - Initializes printers and renderers
|
|
243
|
+
* - Generates markdown files
|
|
244
|
+
*
|
|
245
|
+
* @param options - Complete configuration for the documentation generation
|
|
246
|
+
* @returns Promise that resolves when documentation is fully generated
|
|
247
|
+
*/
|
|
248
|
+
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, }) => {
|
|
249
|
+
const start = process.hrtime.bigint();
|
|
250
|
+
await (0, logger_1.default)(loggerModule);
|
|
251
|
+
const mdxModule = await (0, exports.loadMDXModule)(mdxParser);
|
|
252
|
+
// Register MDX lifecycle event handlers if mdxModule loaded successfully
|
|
253
|
+
// This must be called BEFORE getEvents() because it resets the singleton
|
|
254
|
+
(0, event_handlers_1.registerMDXEventHandlers)(mdxModule);
|
|
255
|
+
// Get events AFTER registration (registerMDXEventHandlers resets and recreates the singleton)
|
|
256
|
+
const events = (0, event_emitter_1.getEvents)();
|
|
257
|
+
await events.emitAsync(events_1.SchemaEvents.BEFORE_LOAD, new events_1.SchemaEvent({
|
|
258
|
+
schemaLocation: schemaLocation,
|
|
259
|
+
}));
|
|
260
|
+
const schema = await (0, exports.loadGraphqlSchema)(schemaLocation, loadersList);
|
|
261
|
+
await events.emitAsync(events_1.SchemaEvents.AFTER_LOAD, new events_1.SchemaEvent({
|
|
262
|
+
schemaLocation: schemaLocation,
|
|
263
|
+
schema,
|
|
264
|
+
}));
|
|
265
|
+
if (!schema) {
|
|
266
|
+
(0, logger_1.log)(`Failed to load GraphQL schema from location "${(0, utils_1.toString)(schemaLocation)}".`, "error");
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
await events.emitAsync(events_1.DiffEvents.BEFORE_CHECK, new events_1.DiffCheckEvent({
|
|
270
|
+
schema,
|
|
271
|
+
outputDir: tmpDir,
|
|
272
|
+
}));
|
|
273
|
+
const schemaHasChanges = await (0, exports.checkSchemaDifferences)(schema, schemaLocation, diffMethod, tmpDir);
|
|
274
|
+
await events.emitAsync(events_1.DiffEvents.AFTER_CHECK, new events_1.DiffCheckEvent({ schemaHasChanges }));
|
|
275
|
+
const [onlyDocDirectives, skipDocDirectives] = (0, exports.resolveSkipAndOnlyDirectives)(onlyDocDirective, skipDocDirective, schema);
|
|
276
|
+
events.emit(events_1.SchemaEvents.BEFORE_MAP, new events_1.SchemaEvent({ schema }));
|
|
119
277
|
const rootTypes = (0, graphql_1.getSchemaMap)(schema);
|
|
278
|
+
events.emit(events_1.SchemaEvents.AFTER_MAP, new events_1.SchemaEvent({ schema, rootTypes }));
|
|
120
279
|
const customDirectives = (0, graphql_1.getCustomDirectives)(rootTypes, customDirective);
|
|
121
280
|
const groups = (0, graphql_1.getGroups)(rootTypes, groupByDirective);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
: undefined
|
|
128
|
-
// Register MDX event handlers if mdxModule loaded successfully
|
|
129
|
-
(0, event_handlers_1.registerMDXEventHandlers)(mdxModule);
|
|
281
|
+
// Extract formatter from the MDX module (for direct function calls)
|
|
282
|
+
const formatter = (0, exports.getFormatterFromMDXModule)(mdxModule, docOptions);
|
|
283
|
+
// Extract mdxDeclaration from the MDX module (if available)
|
|
284
|
+
const mdxDeclaration = mdxModule && typeof mdxModule === "object" && "mdxDeclaration" in mdxModule
|
|
285
|
+
? mdxModule.mdxDeclaration
|
|
286
|
+
: undefined;
|
|
130
287
|
const printer = await (0, printer_1.getPrinter)(
|
|
131
288
|
// module mandatory
|
|
132
289
|
printerModule,
|
|
@@ -148,13 +305,29 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
|
|
|
148
305
|
onlyDocDirectives,
|
|
149
306
|
printTypeOptions,
|
|
150
307
|
skipDocDirectives,
|
|
151
|
-
},
|
|
308
|
+
}, formatter, mdxDeclaration,
|
|
309
|
+
// Pass event emitter to enable print events
|
|
310
|
+
events);
|
|
311
|
+
// allow mdxModule to specify custom extension
|
|
312
|
+
let mdxExtension;
|
|
313
|
+
if (mdxModule &&
|
|
314
|
+
typeof mdxModule === "object" &&
|
|
315
|
+
"mdxExtension" in mdxModule) {
|
|
316
|
+
mdxExtension = mdxModule
|
|
317
|
+
.mdxExtension;
|
|
318
|
+
}
|
|
319
|
+
else if (mdxModule) {
|
|
320
|
+
mdxExtension = exports.FILE_EXTENSION.MDX;
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
mdxExtension = exports.FILE_EXTENSION.MD;
|
|
324
|
+
}
|
|
152
325
|
const renderer = await (0, renderer_1.getRenderer)(printer, outputDir, baseURL, groups, prettify, {
|
|
153
326
|
...docOptions,
|
|
154
327
|
deprecated: printTypeOptions?.deprecated,
|
|
155
328
|
force,
|
|
156
329
|
hierarchy: printTypeOptions?.hierarchy,
|
|
157
|
-
},
|
|
330
|
+
}, mdxExtension);
|
|
158
331
|
// Pre-collect all categories before rendering to ensure consistent positions
|
|
159
332
|
renderer.preCollectCategories(Object.keys(rootTypes));
|
|
160
333
|
const beforeRenderRootTypesEvent = new events_1.RenderRootTypesEvent({
|
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,19 @@ export { buildConfig } from "./config";
|
|
|
6
6
|
export { getEvents, resetEvents, type EmitResult } from "./event-emitter";
|
|
7
7
|
export { registerMDXEventHandlers } from "./event-handlers";
|
|
8
8
|
export { EVENT_CALLBACK_MAP } from "./event-map";
|
|
9
|
+
export { SchemaEvents } from "./events/schema-events";
|
|
10
|
+
export { DiffEvents } from "./events/diff-events";
|
|
11
|
+
export { RenderRootTypesEvents } from "./events/render-root-types-events";
|
|
12
|
+
export { RenderHomepageEvents } from "./events/render-homepage-events";
|
|
13
|
+
export { RenderTypeEntitiesEvents } from "./events/render-type-entities-events";
|
|
14
|
+
export { GenerateIndexMetafileEvents } from "./events/generate-index-metafile-events";
|
|
15
|
+
export { PrintTypeEvents } from "./events/print-type-events";
|
|
9
16
|
export type { CancellableEvent } from "./events/base";
|
|
10
|
-
export type { SchemaLoadEvent } from "./events/schema-load";
|
|
17
|
+
export type { SchemaEvent as SchemaLoadEvent } from "./events/schema-load";
|
|
11
18
|
export type { DiffCheckEvent } from "./events/diff-check";
|
|
12
19
|
export type { RenderRootTypesEvent } from "./events/render-root-types";
|
|
13
20
|
export type { RenderHomepageEvent } from "./events/render-homepage";
|
|
14
21
|
export type { RenderTypeEntitiesEvent } from "./events/render-type-entities";
|
|
15
22
|
export type { GenerateIndexMetafileEvent } from "./events/generate-index-metafile";
|
|
23
|
+
export type { PrintCodeEvent, PrintCodeEventData, PrintTypeEvent, PrintTypeEventData, } from "./events/print-type";
|
|
16
24
|
//# sourceMappingURL=index.d.ts.map
|
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;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,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
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;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,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,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,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,kBAAkB,GACnB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/* istanbul ignore file */
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.EVENT_CALLBACK_MAP = exports.registerMDXEventHandlers = exports.resetEvents = exports.getEvents = exports.buildConfig = exports.generateDocFromSchema = void 0;
|
|
7
|
+
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
8
|
const generator_1 = require("./generator");
|
|
9
9
|
Object.defineProperty(exports, "generateDocFromSchema", { enumerable: true, get: function () { return generator_1.generateDocFromSchema; } });
|
|
10
10
|
const config_1 = require("./config");
|
|
@@ -17,3 +17,18 @@ const event_handlers_1 = require("./event-handlers");
|
|
|
17
17
|
Object.defineProperty(exports, "registerMDXEventHandlers", { enumerable: true, get: function () { return event_handlers_1.registerMDXEventHandlers; } });
|
|
18
18
|
const 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
|
+
// Event constant exports
|
|
21
|
+
const schema_events_1 = require("./events/schema-events");
|
|
22
|
+
Object.defineProperty(exports, "SchemaEvents", { enumerable: true, get: function () { return schema_events_1.SchemaEvents; } });
|
|
23
|
+
const diff_events_1 = require("./events/diff-events");
|
|
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");
|
|
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");
|
|
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");
|
|
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");
|
|
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");
|
|
34
|
+
Object.defineProperty(exports, "PrintTypeEvents", { enumerable: true, get: function () { return print_type_events_1.PrintTypeEvents; } });
|
package/dist/printer.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This module provides the functionality to load and initialize a printer for GraphQL schema documentation.
|
|
5
5
|
* It dynamically imports a printer module and configures it with the provided schema and options.
|
|
6
6
|
*/
|
|
7
|
-
import type { IPrinter, Maybe, PackageName, PrinterConfig, PrinterOptions } from "@graphql-markdown/types";
|
|
7
|
+
import type { Formatter, IPrinter, Maybe, PackageName, PrinterConfig, PrinterEventEmitter, PrinterOptions } from "@graphql-markdown/types";
|
|
8
8
|
/**
|
|
9
9
|
* Loads and initializes a printer module for GraphQL schema documentation.
|
|
10
10
|
*
|
|
@@ -15,7 +15,7 @@ import type { IPrinter, Maybe, PackageName, PrinterConfig, PrinterOptions } from
|
|
|
15
15
|
* @param printerModule - The name/path of the printer module to load
|
|
16
16
|
* @param config - Configuration for the printer including schema, baseURL, and linkRoot
|
|
17
17
|
* @param options - Additional options for customizing the printer's behavior
|
|
18
|
-
* @param
|
|
18
|
+
* @param formatter - Optional formatter functions for customizing output format (e.g., MDX)
|
|
19
19
|
*
|
|
20
20
|
* @returns A promise that resolves to the initialized Printer instance
|
|
21
21
|
*
|
|
@@ -49,5 +49,5 @@ import type { IPrinter, Maybe, PackageName, PrinterConfig, PrinterOptions } from
|
|
|
49
49
|
* const output = printer.printSchema();
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
export declare const getPrinter: (printerModule?: Maybe<PackageName>, config?: Maybe<PrinterConfig>, options?: Maybe<PrinterOptions>,
|
|
52
|
+
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>;
|
|
53
53
|
//# sourceMappingURL=printer.d.ts.map
|
package/dist/printer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,QAAQ,EACR,KAAK,EACL,WAAW,EAEX,aAAa,EACb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;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"}
|
package/dist/printer.js
CHANGED
|
@@ -44,7 +44,7 @@ exports.getPrinter = void 0;
|
|
|
44
44
|
* @param printerModule - The name/path of the printer module to load
|
|
45
45
|
* @param config - Configuration for the printer including schema, baseURL, and linkRoot
|
|
46
46
|
* @param options - Additional options for customizing the printer's behavior
|
|
47
|
-
* @param
|
|
47
|
+
* @param formatter - Optional formatter functions for customizing output format (e.g., MDX)
|
|
48
48
|
*
|
|
49
49
|
* @returns A promise that resolves to the initialized Printer instance
|
|
50
50
|
*
|
|
@@ -78,7 +78,7 @@ exports.getPrinter = void 0;
|
|
|
78
78
|
* const output = printer.printSchema();
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
|
-
const getPrinter = async (printerModule, config, options,
|
|
81
|
+
const getPrinter = async (printerModule, config, options, formatter, mdxDeclaration, eventEmitter) => {
|
|
82
82
|
if (typeof printerModule !== "string") {
|
|
83
83
|
throw new TypeError("Invalid printer module name.");
|
|
84
84
|
}
|
|
@@ -88,7 +88,7 @@ const getPrinter = async (printerModule, config, options, mdxModule) => {
|
|
|
88
88
|
try {
|
|
89
89
|
const { Printer } = await Promise.resolve(`${printerModule}`).then(s => __importStar(require(s)));
|
|
90
90
|
const { schema, baseURL, linkRoot } = config;
|
|
91
|
-
await Printer.init(schema, baseURL, linkRoot, { ...options },
|
|
91
|
+
await Printer.init(schema, baseURL, linkRoot, { ...options }, formatter, mdxDeclaration, eventEmitter);
|
|
92
92
|
return Printer;
|
|
93
93
|
}
|
|
94
94
|
catch {
|
package/dist/renderer.d.ts
CHANGED
|
@@ -75,12 +75,12 @@ export interface CategoryMetafileOptions {
|
|
|
75
75
|
* @example
|
|
76
76
|
*/
|
|
77
77
|
export declare class Renderer {
|
|
78
|
-
group: Maybe<SchemaEntitiesGroupMap>;
|
|
79
|
-
outputDir: string;
|
|
80
|
-
baseURL: string;
|
|
81
|
-
prettify: boolean;
|
|
82
|
-
options: Maybe<RendererDocOptions>;
|
|
83
|
-
|
|
78
|
+
readonly group: Maybe<SchemaEntitiesGroupMap>;
|
|
79
|
+
readonly outputDir: string;
|
|
80
|
+
readonly baseURL: string;
|
|
81
|
+
readonly prettify: boolean;
|
|
82
|
+
readonly options: Maybe<RendererDocOptions>;
|
|
83
|
+
readonly mdxExtension: string;
|
|
84
84
|
private readonly printer;
|
|
85
85
|
private readonly rootLevelPositionManager;
|
|
86
86
|
private readonly categoryPositionManager;
|
|
@@ -93,10 +93,10 @@ export declare class Renderer {
|
|
|
93
93
|
* @param group - Optional grouping configuration for schema entities
|
|
94
94
|
* @param prettify - Whether to format the generated markdown
|
|
95
95
|
* @param docOptions - Additional documentation options
|
|
96
|
-
* @param
|
|
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>,
|
|
99
|
+
constructor(printer: Printer, 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
|
*
|
|
@@ -228,7 +228,7 @@ export declare class Renderer {
|
|
|
228
228
|
* @param group - Optional grouping configuration
|
|
229
229
|
* @param prettify - Whether to prettify the output markdown
|
|
230
230
|
* @param docOptions - Additional documentation options
|
|
231
|
-
* @param
|
|
231
|
+
* @param mdxExtension - Extension to use for MDX files
|
|
232
232
|
* @returns A configured Renderer instance
|
|
233
233
|
*
|
|
234
234
|
* @example
|
|
@@ -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>,
|
|
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>;
|
|
247
247
|
//# 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,OAAO,EACP,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EAGb,MAAM,yBAAyB,CAAC;AA2FjC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,oBAAoB,CAG5C,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,2EAS7B,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;;;;;;;;;;GAUG;AACH,qBAAa,QAAQ;IACnB,KAAK,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"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"}
|
package/dist/renderer.js
CHANGED
|
@@ -260,7 +260,7 @@ class Renderer {
|
|
|
260
260
|
baseURL;
|
|
261
261
|
prettify;
|
|
262
262
|
options;
|
|
263
|
-
|
|
263
|
+
mdxExtension;
|
|
264
264
|
// mdxModuleIndexFileSupport: boolean;
|
|
265
265
|
printer;
|
|
266
266
|
rootLevelPositionManager;
|
|
@@ -274,17 +274,17 @@ class Renderer {
|
|
|
274
274
|
* @param group - Optional grouping configuration for schema entities
|
|
275
275
|
* @param prettify - Whether to format the generated markdown
|
|
276
276
|
* @param docOptions - Additional documentation options
|
|
277
|
-
* @param
|
|
277
|
+
* @param mdxExtension - Optional MDX file extension to use
|
|
278
278
|
* @example
|
|
279
279
|
*/
|
|
280
|
-
constructor(printer, outputDir, baseURL, group, prettify, docOptions,
|
|
280
|
+
constructor(printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension) {
|
|
281
281
|
this.printer = printer;
|
|
282
282
|
this.group = group;
|
|
283
283
|
this.outputDir = outputDir;
|
|
284
284
|
this.baseURL = baseURL;
|
|
285
285
|
this.prettify = prettify;
|
|
286
286
|
this.options = docOptions;
|
|
287
|
-
this.
|
|
287
|
+
this.mdxExtension = mdxExtension;
|
|
288
288
|
// Initialize position managers for different hierarchy levels
|
|
289
289
|
// rootLevelPositionManager: for root-level categories (Query, Mutation, Deprecated, etc.)
|
|
290
290
|
this.rootLevelPositionManager = new CategoryPositionManager(docOptions?.categorySort, 1);
|
|
@@ -435,19 +435,8 @@ class Renderer {
|
|
|
435
435
|
// NOSONAR - pattern is safe, hyphen in character class doesn't cause backtracking
|
|
436
436
|
const PageRegex = /(?<category>[a-z0-9-]+)[\\/]+(?<pageId>[a-z0-9-]+)\.mdx?$/i; // NOSONAR
|
|
437
437
|
const PageRegexFlat = /(?<pageId>[a-z0-9-]+)\.mdx?$/i; // NOSONAR
|
|
438
|
-
// allow mdxModule to specify custom extension
|
|
439
|
-
let extension = "md";
|
|
440
|
-
if (this.mdxModule &&
|
|
441
|
-
typeof this.mdxModule === "object" &&
|
|
442
|
-
"extension" in this.mdxModule &&
|
|
443
|
-
typeof this.mdxModule.extension === "string") {
|
|
444
|
-
extension = this.mdxModule.extension;
|
|
445
|
-
}
|
|
446
|
-
else if (this.mdxModule) {
|
|
447
|
-
extension = "mdx";
|
|
448
|
-
}
|
|
449
438
|
const fileName = (0, utils_1.slugify)(name);
|
|
450
|
-
const filePath = (0, node_path_1.join)((0, node_path_1.normalize)(dirPath), `${fileName}
|
|
439
|
+
const filePath = (0, node_path_1.join)((0, node_path_1.normalize)(dirPath), `${fileName}${this.mdxExtension}`);
|
|
451
440
|
let content;
|
|
452
441
|
try {
|
|
453
442
|
const printOptions = {
|
|
@@ -465,13 +454,14 @@ class Renderer {
|
|
|
465
454
|
return this.formatCategoryFolderName(categoryName, false);
|
|
466
455
|
},
|
|
467
456
|
};
|
|
468
|
-
content = this.printer.printType(fileName, type, printOptions);
|
|
457
|
+
content = await this.printer.printType(fileName, type, printOptions);
|
|
469
458
|
if (typeof content !== "string" || content === "") {
|
|
459
|
+
(0, logger_1.log)(`No content generated for "${name}" - printType returned empty`, logger_1.LogLevel.warn);
|
|
470
460
|
return undefined;
|
|
471
461
|
}
|
|
472
462
|
}
|
|
473
|
-
catch {
|
|
474
|
-
(0, logger_1.log)(`An error occurred while processing "${
|
|
463
|
+
catch (error) {
|
|
464
|
+
(0, logger_1.log)(`An error occurred while processing "${name}": ${error instanceof Error ? error.message : String(error)}`, logger_1.LogLevel.warn);
|
|
475
465
|
return undefined;
|
|
476
466
|
}
|
|
477
467
|
await (0, utils_1.saveFile)(filePath, content, this.prettify ? utils_1.prettifyMarkdown : undefined);
|
|
@@ -726,7 +716,7 @@ exports.Renderer = Renderer;
|
|
|
726
716
|
* @param group - Optional grouping configuration
|
|
727
717
|
* @param prettify - Whether to prettify the output markdown
|
|
728
718
|
* @param docOptions - Additional documentation options
|
|
729
|
-
* @param
|
|
719
|
+
* @param mdxExtension - Extension to use for MDX files
|
|
730
720
|
* @returns A configured Renderer instance
|
|
731
721
|
*
|
|
732
722
|
* @example
|
|
@@ -741,8 +731,8 @@ exports.Renderer = Renderer;
|
|
|
741
731
|
* );
|
|
742
732
|
* ```
|
|
743
733
|
*/
|
|
744
|
-
const getRenderer = async (printer, outputDir, baseURL, group, prettify, docOptions,
|
|
734
|
+
const getRenderer = async (printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension) => {
|
|
745
735
|
await (0, utils_1.ensureDir)(outputDir, { forceEmpty: docOptions?.force });
|
|
746
|
-
return new Renderer(printer, outputDir, baseURL, group, prettify, docOptions,
|
|
736
|
+
return new Renderer(printer, outputDir, baseURL, group, prettify, docOptions, mdxExtension);
|
|
747
737
|
};
|
|
748
738
|
exports.getRenderer = getRenderer;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.17.
|
|
8
|
+
"version": "1.17.1",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -63,18 +63,18 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@fastify/deepmerge": "^3.2.0",
|
|
66
|
-
"@graphql-markdown/graphql": "
|
|
67
|
-
"@graphql-markdown/logger": "
|
|
68
|
-
"@graphql-markdown/utils": "
|
|
66
|
+
"@graphql-markdown/graphql": "^1.1.9",
|
|
67
|
+
"@graphql-markdown/logger": "^1.0.5",
|
|
68
|
+
"@graphql-markdown/utils": "^1.9.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@graphql-markdown/diff": "
|
|
72
|
-
"@graphql-markdown/helpers": "
|
|
73
|
-
"@graphql-markdown/printer-legacy": "
|
|
74
|
-
"graphql-config": "
|
|
71
|
+
"@graphql-markdown/diff": "^1.1.13",
|
|
72
|
+
"@graphql-markdown/helpers": "^1.0.12",
|
|
73
|
+
"@graphql-markdown/printer-legacy": "^1.12.4",
|
|
74
|
+
"graphql-config": "5.1.5"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@graphql-markdown/types": "
|
|
77
|
+
"@graphql-markdown/types": "^1.9.0"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
|
80
80
|
"@graphql-markdown/printer-legacy": {
|