@graphql-markdown/core 1.19.0 → 1.21.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/assets/generated.md +1 -8
- package/dist/config.d.ts +9 -55
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +24 -39
- package/dist/const/patterns.d.ts +9 -9
- package/dist/const/patterns.d.ts.map +1 -1
- package/dist/const/patterns.js +9 -9
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +1 -34
- package/dist/directives/normalize.d.ts +2 -2
- package/dist/directives/normalize.d.ts.map +1 -1
- package/dist/directives/normalize.js +3 -1
- package/dist/directives/validation.d.ts.map +1 -1
- package/dist/event-emitter.d.ts +7 -2
- package/dist/event-emitter.d.ts.map +1 -1
- package/dist/event-emitter.js +32 -23
- package/dist/event-handlers.d.ts.map +1 -1
- package/dist/event-map.d.ts +2 -0
- package/dist/event-map.d.ts.map +1 -1
- package/dist/event-map.js +3 -0
- package/dist/events/diff-check.d.ts +7 -8
- package/dist/events/diff-check.d.ts.map +1 -1
- package/dist/events/diff-check.js +3 -6
- package/dist/events/diff-events.d.ts.map +1 -1
- package/dist/events/generate-index-metafile-events.d.ts.map +1 -1
- package/dist/events/generate-index-metafile.d.ts +7 -8
- package/dist/events/generate-index-metafile.d.ts.map +1 -1
- package/dist/events/generate-index-metafile.js +3 -6
- package/dist/events/index.d.ts +2 -3
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +21 -21
- package/dist/events/print-type-events.d.ts +5 -2
- package/dist/events/print-type-events.d.ts.map +1 -1
- package/dist/events/print-type-events.js +5 -2
- package/dist/events/print-type.d.ts +4 -78
- package/dist/events/print-type.d.ts.map +1 -1
- package/dist/events/print-type.js +3 -66
- package/dist/events/render-files-events.d.ts +13 -0
- package/dist/events/render-files-events.d.ts.map +1 -0
- package/dist/events/render-files-events.js +15 -0
- package/dist/events/render-files.d.ts +26 -0
- package/dist/events/render-files.d.ts.map +1 -0
- package/dist/events/render-files.js +20 -0
- package/dist/events/render-homepage-events.d.ts.map +1 -1
- package/dist/events/render-homepage.d.ts +5 -6
- package/dist/events/render-homepage.d.ts.map +1 -1
- package/dist/events/render-homepage.js +3 -6
- package/dist/events/render-root-types-events.d.ts.map +1 -1
- package/dist/events/render-root-types.d.ts +5 -6
- package/dist/events/render-root-types.d.ts.map +1 -1
- package/dist/events/render-root-types.js +3 -6
- package/dist/events/render-type-entities-events.d.ts.map +1 -1
- package/dist/events/render-type-entities.d.ts +10 -7
- package/dist/events/render-type-entities.d.ts.map +1 -1
- package/dist/events/render-type-entities.js +3 -6
- package/dist/events/schema-events.d.ts.map +1 -1
- package/dist/events/schema-load.d.ts +7 -8
- package/dist/events/schema-load.d.ts.map +1 -1
- package/dist/events/schema-load.js +3 -6
- package/dist/generator.d.ts +3 -14
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +16 -11
- package/dist/graphql-config.d.ts +0 -5
- package/dist/graphql-config.d.ts.map +1 -1
- package/dist/graphql-config.js +8 -38
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -13
- package/dist/options/builder.d.ts +13 -13
- package/dist/options/builder.d.ts.map +1 -1
- package/dist/options/builder.js +25 -25
- package/dist/printer.d.ts +9 -10
- package/dist/printer.d.ts.map +1 -1
- package/dist/printer.js +11 -53
- package/dist/renderer.d.ts +5 -5
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +24 -15
- package/package.json +24 -16
- package/dist/events/base.d.ts +0 -119
- package/dist/events/base.d.ts.map +0 -1
- package/dist/events/base.js +0 -149
package/dist/printer.d.ts
CHANGED
|
@@ -7,26 +7,23 @@
|
|
|
7
7
|
* @module printer
|
|
8
8
|
*
|
|
9
9
|
* This module provides the functionality to load and initialize a printer for GraphQL schema documentation.
|
|
10
|
-
* It
|
|
10
|
+
* It resolves a supported printer module and configures it with the provided schema and options.
|
|
11
11
|
*/
|
|
12
|
-
import type { Formatter, IPrinter, Maybe,
|
|
12
|
+
import type { Formatter, IPrinter, Maybe, PrinterConfig, PrinterEventEmitter, PrinterOptions } from "@graphql-markdown/types";
|
|
13
13
|
/**
|
|
14
14
|
* Loads and initializes a printer module for GraphQL schema documentation.
|
|
15
15
|
*
|
|
16
|
-
* This function
|
|
16
|
+
* This function resolves the specified printer module and initializes it
|
|
17
17
|
* with the provided configuration and options. The printer is responsible for rendering
|
|
18
18
|
* GraphQL schema documentation in the desired format.
|
|
19
19
|
*
|
|
20
|
-
* @param printerModule - The name/path of the printer module to load
|
|
21
20
|
* @param config - Configuration for the printer including schema, baseURL, and linkRoot
|
|
22
21
|
* @param options - Additional options for customizing the printer's behavior
|
|
23
22
|
* @param formatter - Optional formatter functions for customizing output format (e.g., MDX)
|
|
24
23
|
*
|
|
25
24
|
* @returns A promise that resolves to the initialized Printer instance
|
|
26
25
|
*
|
|
27
|
-
* @throws Will throw an error if printerModule is not a string
|
|
28
26
|
* @throws Will throw an error if config is not provided
|
|
29
|
-
* @throws Will throw an error if the module specified by printerModule cannot be found
|
|
30
27
|
*
|
|
31
28
|
* @example
|
|
32
29
|
* ```typescript
|
|
@@ -40,19 +37,21 @@ import type { Formatter, IPrinter, Maybe, PackageName, PrinterConfig, PrinterEve
|
|
|
40
37
|
* `);
|
|
41
38
|
*
|
|
42
39
|
* const printer = await getPrinter(
|
|
43
|
-
* '@graphql-markdown/printer-legacy',
|
|
44
40
|
* {
|
|
45
41
|
* schema,
|
|
46
42
|
* baseURL: '/docs',
|
|
47
43
|
* linkRoot: 'graphql'
|
|
48
44
|
* },
|
|
49
45
|
* {
|
|
50
|
-
* printTypeOptions: {
|
|
46
|
+
* printTypeOptions: { deprecated: 'group' }
|
|
51
47
|
* }
|
|
52
48
|
* );
|
|
53
49
|
*
|
|
54
|
-
* const
|
|
50
|
+
* const queryType = schema.getQueryType();
|
|
51
|
+
* if (queryType) {
|
|
52
|
+
* const output = await printer.printType('Query', queryType);
|
|
53
|
+
* }
|
|
55
54
|
* ```
|
|
56
55
|
*/
|
|
57
|
-
export declare const getPrinter: (
|
|
56
|
+
export declare const getPrinter: (config?: Maybe<PrinterConfig>, options?: Maybe<PrinterOptions>, formatter?: Partial<Formatter>, mdxDeclaration?: Maybe<string>, eventEmitter?: Maybe<PrinterEventEmitter>) => Promise<typeof IPrinter>;
|
|
58
57
|
//# sourceMappingURL=printer.d.ts.map
|
package/dist/printer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,aAAa,EACb,mBAAmB,EACnB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,UAAU,YACZ,KAAK,CAAC,aAAa,CAAC,YACnB,KAAK,CAAC,cAAc,CAAC,cACnB,OAAO,CAAC,SAAS,CAAC,mBACb,KAAK,CAAC,MAAM,CAAC,iBACf,KAAK,CAAC,mBAAmB,CAAC,KACxC,OAAO,CAAC,OAAO,QAAQ,CAiBzB,CAAC"}
|
package/dist/printer.js
CHANGED
|
@@ -1,56 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.getPrinter = void 0;
|
|
4
|
+
const printer_legacy_1 = require("@graphql-markdown/printer-legacy");
|
|
37
5
|
/**
|
|
38
6
|
* Loads and initializes a printer module for GraphQL schema documentation.
|
|
39
7
|
*
|
|
40
|
-
* This function
|
|
8
|
+
* This function resolves the specified printer module and initializes it
|
|
41
9
|
* with the provided configuration and options. The printer is responsible for rendering
|
|
42
10
|
* GraphQL schema documentation in the desired format.
|
|
43
11
|
*
|
|
44
|
-
* @param printerModule - The name/path of the printer module to load
|
|
45
12
|
* @param config - Configuration for the printer including schema, baseURL, and linkRoot
|
|
46
13
|
* @param options - Additional options for customizing the printer's behavior
|
|
47
14
|
* @param formatter - Optional formatter functions for customizing output format (e.g., MDX)
|
|
48
15
|
*
|
|
49
16
|
* @returns A promise that resolves to the initialized Printer instance
|
|
50
17
|
*
|
|
51
|
-
* @throws Will throw an error if printerModule is not a string
|
|
52
18
|
* @throws Will throw an error if config is not provided
|
|
53
|
-
* @throws Will throw an error if the module specified by printerModule cannot be found
|
|
54
19
|
*
|
|
55
20
|
* @example
|
|
56
21
|
* ```typescript
|
|
@@ -64,35 +29,28 @@ exports.getPrinter = void 0;
|
|
|
64
29
|
* `);
|
|
65
30
|
*
|
|
66
31
|
* const printer = await getPrinter(
|
|
67
|
-
* '@graphql-markdown/printer-legacy',
|
|
68
32
|
* {
|
|
69
33
|
* schema,
|
|
70
34
|
* baseURL: '/docs',
|
|
71
35
|
* linkRoot: 'graphql'
|
|
72
36
|
* },
|
|
73
37
|
* {
|
|
74
|
-
* printTypeOptions: {
|
|
38
|
+
* printTypeOptions: { deprecated: 'group' }
|
|
75
39
|
* }
|
|
76
40
|
* );
|
|
77
41
|
*
|
|
78
|
-
* const
|
|
42
|
+
* const queryType = schema.getQueryType();
|
|
43
|
+
* if (queryType) {
|
|
44
|
+
* const output = await printer.printType('Query', queryType);
|
|
45
|
+
* }
|
|
79
46
|
* ```
|
|
80
47
|
*/
|
|
81
|
-
const getPrinter = async (
|
|
82
|
-
if (typeof printerModule !== "string") {
|
|
83
|
-
throw new TypeError("Invalid printer module name.");
|
|
84
|
-
}
|
|
48
|
+
const getPrinter = async (config, options, formatter, mdxDeclaration, eventEmitter) => {
|
|
85
49
|
if (!config) {
|
|
86
50
|
throw new Error("Invalid printer config.");
|
|
87
51
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
await Printer.init(schema, baseURL, linkRoot, { ...options }, formatter, mdxDeclaration, eventEmitter);
|
|
92
|
-
return Printer;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
throw new Error(`Cannot find module '${printerModule}'.`);
|
|
96
|
-
}
|
|
52
|
+
const { schema, baseURL, linkRoot } = config;
|
|
53
|
+
await printer_legacy_1.Printer.init(schema, baseURL, linkRoot, options ?? undefined, formatter, mdxDeclaration, eventEmitter);
|
|
54
|
+
return printer_legacy_1.Printer;
|
|
97
55
|
};
|
|
98
56
|
exports.getPrinter = getPrinter;
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiGroupOverrideType, Category, Maybe,
|
|
1
|
+
import type { ApiGroupOverrideType, Category, Maybe, IPrinter, RendererDocOptions, SchemaEntitiesGroupMap, SchemaEntity } from "@graphql-markdown/types";
|
|
2
2
|
/**
|
|
3
3
|
* Default group names for API types and non-API types.
|
|
4
4
|
* This constant provides the base folder structure for organizing GraphQL schema entities.
|
|
@@ -36,7 +36,7 @@ export declare const API_GROUPS: Required<ApiGroupOverrideType>;
|
|
|
36
36
|
* const folder = getApiGroupFolder(objectType, { operations: "queries" }); // Returns appropriate folder
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export declare const getApiGroupFolder: (type: unknown, groups?: Maybe<
|
|
39
|
+
export declare const getApiGroupFolder: (type: unknown, groups?: Maybe<ApiGroupOverrideType | boolean>) => string;
|
|
40
40
|
/**
|
|
41
41
|
* Configuration options for category metafiles in the documentation.
|
|
42
42
|
* These options control the appearance and behavior of category sections in the sidebar.
|
|
@@ -96,7 +96,7 @@ export declare class Renderer {
|
|
|
96
96
|
* @param mdxExtension - Optional MDX file extension to use
|
|
97
97
|
* @example
|
|
98
98
|
*/
|
|
99
|
-
constructor(printer:
|
|
99
|
+
constructor(printer: typeof IPrinter, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<RendererDocOptions>, mdxExtension: string);
|
|
100
100
|
/**
|
|
101
101
|
* Generates an index metafile for a category directory if MDX support is available.
|
|
102
102
|
*
|
|
@@ -143,7 +143,7 @@ export declare class Renderer {
|
|
|
143
143
|
* @returns The category information for the rendered entity or undefined
|
|
144
144
|
* @example
|
|
145
145
|
*/
|
|
146
|
-
renderTypeEntities(dirPath: string, name: string, type: unknown): Promise<Maybe<Category>>;
|
|
146
|
+
renderTypeEntities(dirPath: string, name: string, type: unknown, operationNamespaceParts?: string[]): Promise<Maybe<Category>>;
|
|
147
147
|
/**
|
|
148
148
|
* Pre-collects all category names that will be generated during rendering.
|
|
149
149
|
* This allows the position manager to assign consistent positions before
|
|
@@ -243,5 +243,5 @@ export declare class Renderer {
|
|
|
243
243
|
* );
|
|
244
244
|
* ```
|
|
245
245
|
*/
|
|
246
|
-
export declare const getRenderer: (printer: typeof
|
|
246
|
+
export declare const getRenderer: (printer: typeof IPrinter, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<RendererDocOptions>, mdxExtension: string) => Promise<InstanceType<typeof Renderer>>;
|
|
247
247
|
//# sourceMappingURL=renderer.d.ts.map
|
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,
|
|
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,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,SACtB,OAAO,WACJ,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=> {
|
|
415
415
|
let dirPath = this.outputDir;
|
|
416
416
|
let entityName = name;
|
|
417
|
+
let operationNamespaceParts;
|
|
418
|
+
if (isOperationRootType && name.includes(".")) {
|
|
419
|
+
const namespaceParts = name.split(".").filter(Boolean);
|
|
420
|
+
if (namespaceParts.length > 1) {
|
|
421
|
+
operationNamespaceParts = namespaceParts.slice(0, -1);
|
|
422
|
+
if (!isFlat) {
|
|
423
|
+
entityName = namespaceParts.at(-1) ?? entityName;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
417
427
|
if (!isFlat) {
|
|
418
428
|
dirPath = await this.generateCategoryMetafileType(type[name], name, rootTypeName);
|
|
419
|
-
if (
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const formattedNamespace = (0, utils_1.slugify)(namespace);
|
|
425
|
-
dirPath = (0, node_path_1.join)(dirPath, formattedNamespace);
|
|
426
|
-
await this.generateIndexMetafile(dirPath, namespace);
|
|
427
|
-
}
|
|
429
|
+
if (operationNamespaceParts && operationNamespaceParts.length > 0) {
|
|
430
|
+
for (const namespace of operationNamespaceParts) {
|
|
431
|
+
const formattedNamespace = (0, utils_1.slugify)(namespace);
|
|
432
|
+
dirPath = (0, node_path_1.join)(dirPath, formattedNamespace);
|
|
433
|
+
await this.generateIndexMetafile(dirPath, namespace);
|
|
428
434
|
}
|
|
429
435
|
}
|
|
430
436
|
}
|
|
431
|
-
return this.renderTypeEntities(dirPath, entityName, type[name]);
|
|
437
|
+
return this.renderTypeEntities(dirPath, entityName, type[name], operationNamespaceParts);
|
|
432
438
|
}));
|
|
433
439
|
}
|
|
434
440
|
/**
|
|
@@ -440,7 +446,7 @@ class Renderer {
|
|
|
440
446
|
* @returns The category information for the rendered entity or undefined
|
|
441
447
|
* @example
|
|
442
448
|
*/
|
|
443
|
-
async renderTypeEntities(dirPath, name, type) {
|
|
449
|
+
async renderTypeEntities(dirPath, name, type, operationNamespaceParts) {
|
|
444
450
|
if (!(0, validation_1.isPath)(dirPath)) {
|
|
445
451
|
throw new Error("Output directory is empty or not specified");
|
|
446
452
|
}
|
|
@@ -478,6 +484,9 @@ class Renderer {
|
|
|
478
484
|
// Unknown categories should not receive synthetic numeric prefixes.
|
|
479
485
|
return (0, utils_1.slugify)(categoryName);
|
|
480
486
|
},
|
|
487
|
+
...(operationNamespaceParts === undefined
|
|
488
|
+
? {}
|
|
489
|
+
: { operationNamespaceParts }),
|
|
481
490
|
};
|
|
482
491
|
content = await this.printer.printType(fileName, type, printOptions);
|
|
483
492
|
if (typeof content !== "string" || content === "") {
|
|
@@ -503,19 +512,19 @@ class Renderer {
|
|
|
503
512
|
const extractedCategory = isFlat
|
|
504
513
|
? page.groups.pageId
|
|
505
514
|
: stripNumericPrefix(page.groups.category);
|
|
506
|
-
const slug = isFlat
|
|
507
|
-
? page.groups.pageId
|
|
508
|
-
: utils_1.pathUrl.join(extractedCategory, page.groups.pageId);
|
|
509
515
|
const category = isFlat ? "schema" : (0, utils_1.startCase)(extractedCategory);
|
|
510
516
|
const events = (0, event_emitter_1.getEvents)();
|
|
511
517
|
const event = new events_1.RenderTypeEntitiesEvent({
|
|
518
|
+
baseURL: this.baseURL,
|
|
512
519
|
name,
|
|
513
520
|
filePath,
|
|
521
|
+
outputDir: this.outputDir,
|
|
514
522
|
});
|
|
515
523
|
await events.emitAsync(events_1.RenderTypeEntitiesEvents.AFTER_RENDER, event);
|
|
516
524
|
return {
|
|
517
525
|
category,
|
|
518
|
-
|
|
526
|
+
filePath,
|
|
527
|
+
name,
|
|
519
528
|
};
|
|
520
529
|
}
|
|
521
530
|
/**
|
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.
|
|
8
|
+
"version": "1.21.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -58,28 +58,36 @@
|
|
|
58
58
|
"scripts": {
|
|
59
59
|
"stryker": "stryker run",
|
|
60
60
|
"clean": "tsgo --build --clean && rm -rf ./dist",
|
|
61
|
-
"docs": "typedoc",
|
|
62
|
-
"build": "tsgo --build"
|
|
61
|
+
"docs": "typedoc --options typedoc.config.mjs",
|
|
62
|
+
"build": "tsgo --build",
|
|
63
|
+
"lint": "eslint --config ../../packages/tooling-config/eslint/config.ts \"{src,tests}/**/*.{ts,js,json,gql}\"",
|
|
64
|
+
"lint:fix": "eslint --config ../../packages/tooling-config/eslint/config.ts \"{src,tests}/**/*.{ts,js,json,gql}\" --fix",
|
|
65
|
+
"prettier": "prettier \"{src,tests,assets}/**/*.{ts,js,json,md,gql}\" --check",
|
|
66
|
+
"prettier:fix": "prettier \"{src,tests,assets}/**/*.{ts,js,json,md,gql}\" --write",
|
|
67
|
+
"ts:check": "tsgo --noEmit",
|
|
68
|
+
"test": "jest",
|
|
69
|
+
"test:unit": "jest --passWithNoTests --testPathPatterns=tests/unit",
|
|
70
|
+
"test:integration": "jest --passWithNoTests --testPathPatterns=tests/integration",
|
|
71
|
+
"test:ci": "jest --passWithNoTests --ci --silent --randomize --runInBand",
|
|
72
|
+
"test:watch": "jest --watch"
|
|
63
73
|
},
|
|
64
74
|
"dependencies": {
|
|
65
75
|
"@fastify/deepmerge": "^3.2.1",
|
|
66
|
-
"@graphql-markdown/graphql": "^1.
|
|
67
|
-
"@graphql-markdown/logger": "^1.0.
|
|
68
|
-
"@graphql-markdown/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"@graphql-markdown/diff": "^1.1.13",
|
|
72
|
-
"@graphql-markdown/helpers": "^1.0.12",
|
|
73
|
-
"@graphql-markdown/printer-legacy": "^1.13.1",
|
|
74
|
-
"graphql-config": "5.1.5"
|
|
76
|
+
"@graphql-markdown/graphql": "^1.2.2",
|
|
77
|
+
"@graphql-markdown/logger": "^1.0.7",
|
|
78
|
+
"@graphql-markdown/printer-legacy": "^1.16.0",
|
|
79
|
+
"@graphql-markdown/types": "^1.13.0",
|
|
80
|
+
"@graphql-markdown/utils": "^1.12.0"
|
|
75
81
|
},
|
|
76
82
|
"devDependencies": {
|
|
77
|
-
"@graphql-markdown/
|
|
83
|
+
"@graphql-markdown/tooling-config": "^1.0.0"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"@graphql-markdown/diff": "^1.1.15",
|
|
87
|
+
"@graphql-markdown/helpers": "^1.1.0",
|
|
88
|
+
"graphql-config": "5.1.6"
|
|
78
89
|
},
|
|
79
90
|
"peerDependenciesMeta": {
|
|
80
|
-
"@graphql-markdown/printer-legacy": {
|
|
81
|
-
"optional": true
|
|
82
|
-
},
|
|
83
91
|
"@graphql-markdown/diff": {
|
|
84
92
|
"optional": true
|
|
85
93
|
},
|
package/dist/events/base.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base event class and utilities for GraphQL-Markdown events.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
import type { DefaultAction, ICancellableEvent } from "@graphql-markdown/types";
|
|
7
|
-
/**
|
|
8
|
-
* Deep freezes an object to make it immutable at runtime.
|
|
9
|
-
* Recursively freezes all nested objects and arrays.
|
|
10
|
-
*
|
|
11
|
-
* @param obj - The object to freeze
|
|
12
|
-
* @returns The frozen object (same reference)
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const data = { user: { name: 'John' } };
|
|
17
|
-
* deepFreeze(data);
|
|
18
|
-
* data.user.name = 'Jane'; // Throws error in strict mode
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare const deepFreeze: <T extends Record<PropertyKey, any>>(obj: T) => T;
|
|
22
|
-
export interface CancellableEventOptions {
|
|
23
|
-
defaultAction?: DefaultAction;
|
|
24
|
-
cancellable?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Base class for all cancellable events in GraphQL-Markdown.
|
|
28
|
-
*
|
|
29
|
-
* Provides common functionality:
|
|
30
|
-
* - preventDefault() to cancel default actions
|
|
31
|
-
* - stopPropagation() to halt handler chain
|
|
32
|
-
* - Configurable cancellability
|
|
33
|
-
* - Optional default action function
|
|
34
|
-
*
|
|
35
|
-
* @category Events
|
|
36
|
-
*/
|
|
37
|
-
export declare abstract class CancellableEvent implements ICancellableEvent {
|
|
38
|
-
/**
|
|
39
|
-
* Whether the default action has been prevented.
|
|
40
|
-
* Set to true when preventDefault() is called.
|
|
41
|
-
*/
|
|
42
|
-
private _defaultPrevented;
|
|
43
|
-
/**
|
|
44
|
-
* Whether propagation to remaining handlers has been stopped.
|
|
45
|
-
* Set to true when stopPropagation() is called.
|
|
46
|
-
*/
|
|
47
|
-
private _propagationStopped;
|
|
48
|
-
/**
|
|
49
|
-
* Whether this event can be cancelled.
|
|
50
|
-
* If false, preventDefault() has no effect.
|
|
51
|
-
*/
|
|
52
|
-
private readonly _cancellable;
|
|
53
|
-
/**
|
|
54
|
-
* Optional function to execute as the default action.
|
|
55
|
-
* Only runs if preventDefault() was not called.
|
|
56
|
-
*/
|
|
57
|
-
private readonly _defaultAction?;
|
|
58
|
-
/**
|
|
59
|
-
* Creates a new CancellableEvent.
|
|
60
|
-
*
|
|
61
|
-
* @param options - Configuration options for the event
|
|
62
|
-
* @param options.cancellable - Whether this event can be cancelled (default: true)
|
|
63
|
-
* @param options.defaultAction - Optional function to execute as default action
|
|
64
|
-
*/
|
|
65
|
-
constructor(options?: CancellableEventOptions);
|
|
66
|
-
/**
|
|
67
|
-
* Gets whether the default action has been prevented.
|
|
68
|
-
*/
|
|
69
|
-
get defaultPrevented(): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Gets whether propagation has been stopped.
|
|
72
|
-
*/
|
|
73
|
-
get propagationStopped(): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Gets the default action function if one was provided.
|
|
76
|
-
*/
|
|
77
|
-
get defaultAction(): DefaultAction | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* Prevents the default action from executing.
|
|
80
|
-
* Only works if the event is cancellable.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* events.on('beforeLoadSchema', (event) => {
|
|
85
|
-
* if (shouldUseCustomLoader) {
|
|
86
|
-
* event.preventDefault(); // Stops default schema loading
|
|
87
|
-
* // Custom logic here
|
|
88
|
-
* }
|
|
89
|
-
* });
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
preventDefault(): void;
|
|
93
|
-
/**
|
|
94
|
-
* Stops propagation to remaining event handlers.
|
|
95
|
-
* Handlers registered after the current one will not execute.
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```typescript
|
|
99
|
-
* events.on('beforeLoadSchema', (event) => {
|
|
100
|
-
* if (criticalError) {
|
|
101
|
-
* event.stopPropagation(); // No more handlers run
|
|
102
|
-
* }
|
|
103
|
-
* });
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
stopPropagation(): void;
|
|
107
|
-
/**
|
|
108
|
-
* Executes the default action for an event if it hasn't been prevented.
|
|
109
|
-
*
|
|
110
|
-
* @returns A promise that resolves when the default action completes, or void if the action was prevented or no default action is defined
|
|
111
|
-
*
|
|
112
|
-
* @remarks
|
|
113
|
-
* This method will only execute the `_defaultAction` if:
|
|
114
|
-
* - The event's default has not been prevented (`_defaultPrevented` is false)
|
|
115
|
-
* - A default action function has been defined (`_defaultAction` is a function)
|
|
116
|
-
*/
|
|
117
|
-
runDefaultAction(): Promise<void>;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/events/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEhF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,+CAc3B,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,8BAAsB,gBAAiB,YAAW,iBAAiB;IACjE;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAS;IAElC;;;OAGG;IACH,OAAO,CAAC,mBAAmB,CAAS;IAEpC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IAEvC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAgB;IAEhD;;;;;;OAMG;IACH,YAAY,OAAO,CAAC,EAAE,uBAAuB,EAG5C;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,OAAO,CAE9B;IAED;;OAEG;IACH,IAAI,kBAAkB,IAAI,OAAO,CAEhC;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,aAAa,GAAG,SAAS,CAE7C;IAED;;;;;;;;;;;;;OAaG;IACH,cAAc,IAAI,IAAI,CAIrB;IAED;;;;;;;;;;;;OAYG;IACH,eAAe,IAAI,IAAI,CAEtB;IAED;;;;;;;;;OASG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKtC;CACF"}
|
package/dist/events/base.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Base event class and utilities for GraphQL-Markdown events.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.CancellableEvent = exports.deepFreeze = void 0;
|
|
9
|
-
/**
|
|
10
|
-
* Deep freezes an object to make it immutable at runtime.
|
|
11
|
-
* Recursively freezes all nested objects and arrays.
|
|
12
|
-
*
|
|
13
|
-
* @param obj - The object to freeze
|
|
14
|
-
* @returns The frozen object (same reference)
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const data = { user: { name: 'John' } };
|
|
19
|
-
* deepFreeze(data);
|
|
20
|
-
* data.user.name = 'Jane'; // Throws error in strict mode
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
const deepFreeze = (obj) => {
|
|
24
|
-
// Get all property names including symbols
|
|
25
|
-
const propNames = Reflect.ownKeys(obj);
|
|
26
|
-
// Freeze properties before freezing self
|
|
27
|
-
for (const name of propNames) {
|
|
28
|
-
const value = obj[name];
|
|
29
|
-
if ((value && typeof value === "object") || typeof value === "function") {
|
|
30
|
-
(0, exports.deepFreeze)(value);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return Object.freeze(obj);
|
|
34
|
-
};
|
|
35
|
-
exports.deepFreeze = deepFreeze;
|
|
36
|
-
/**
|
|
37
|
-
* Base class for all cancellable events in GraphQL-Markdown.
|
|
38
|
-
*
|
|
39
|
-
* Provides common functionality:
|
|
40
|
-
* - preventDefault() to cancel default actions
|
|
41
|
-
* - stopPropagation() to halt handler chain
|
|
42
|
-
* - Configurable cancellability
|
|
43
|
-
* - Optional default action function
|
|
44
|
-
*
|
|
45
|
-
* @category Events
|
|
46
|
-
*/
|
|
47
|
-
class CancellableEvent {
|
|
48
|
-
/**
|
|
49
|
-
* Whether the default action has been prevented.
|
|
50
|
-
* Set to true when preventDefault() is called.
|
|
51
|
-
*/
|
|
52
|
-
_defaultPrevented = false;
|
|
53
|
-
/**
|
|
54
|
-
* Whether propagation to remaining handlers has been stopped.
|
|
55
|
-
* Set to true when stopPropagation() is called.
|
|
56
|
-
*/
|
|
57
|
-
_propagationStopped = false;
|
|
58
|
-
/**
|
|
59
|
-
* Whether this event can be cancelled.
|
|
60
|
-
* If false, preventDefault() has no effect.
|
|
61
|
-
*/
|
|
62
|
-
_cancellable;
|
|
63
|
-
/**
|
|
64
|
-
* Optional function to execute as the default action.
|
|
65
|
-
* Only runs if preventDefault() was not called.
|
|
66
|
-
*/
|
|
67
|
-
_defaultAction;
|
|
68
|
-
/**
|
|
69
|
-
* Creates a new CancellableEvent.
|
|
70
|
-
*
|
|
71
|
-
* @param options - Configuration options for the event
|
|
72
|
-
* @param options.cancellable - Whether this event can be cancelled (default: true)
|
|
73
|
-
* @param options.defaultAction - Optional function to execute as default action
|
|
74
|
-
*/
|
|
75
|
-
constructor(options) {
|
|
76
|
-
this._cancellable = options?.cancellable ?? true;
|
|
77
|
-
this._defaultAction = options?.defaultAction;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Gets whether the default action has been prevented.
|
|
81
|
-
*/
|
|
82
|
-
get defaultPrevented() {
|
|
83
|
-
return this._defaultPrevented;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Gets whether propagation has been stopped.
|
|
87
|
-
*/
|
|
88
|
-
get propagationStopped() {
|
|
89
|
-
return this._propagationStopped;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Gets the default action function if one was provided.
|
|
93
|
-
*/
|
|
94
|
-
get defaultAction() {
|
|
95
|
-
return this._defaultAction;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Prevents the default action from executing.
|
|
99
|
-
* Only works if the event is cancellable.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```typescript
|
|
103
|
-
* events.on('beforeLoadSchema', (event) => {
|
|
104
|
-
* if (shouldUseCustomLoader) {
|
|
105
|
-
* event.preventDefault(); // Stops default schema loading
|
|
106
|
-
* // Custom logic here
|
|
107
|
-
* }
|
|
108
|
-
* });
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
preventDefault() {
|
|
112
|
-
if (this._cancellable) {
|
|
113
|
-
this._defaultPrevented = true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Stops propagation to remaining event handlers.
|
|
118
|
-
* Handlers registered after the current one will not execute.
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```typescript
|
|
122
|
-
* events.on('beforeLoadSchema', (event) => {
|
|
123
|
-
* if (criticalError) {
|
|
124
|
-
* event.stopPropagation(); // No more handlers run
|
|
125
|
-
* }
|
|
126
|
-
* });
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
stopPropagation() {
|
|
130
|
-
this._propagationStopped = true;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Executes the default action for an event if it hasn't been prevented.
|
|
134
|
-
*
|
|
135
|
-
* @returns A promise that resolves when the default action completes, or void if the action was prevented or no default action is defined
|
|
136
|
-
*
|
|
137
|
-
* @remarks
|
|
138
|
-
* This method will only execute the `_defaultAction` if:
|
|
139
|
-
* - The event's default has not been prevented (`_defaultPrevented` is false)
|
|
140
|
-
* - A default action function has been defined (`_defaultAction` is a function)
|
|
141
|
-
*/
|
|
142
|
-
async runDefaultAction() {
|
|
143
|
-
if (!this._defaultPrevented && typeof this._defaultAction === "function") {
|
|
144
|
-
return this._defaultAction();
|
|
145
|
-
}
|
|
146
|
-
return void 0;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.CancellableEvent = CancellableEvent;
|