@graphql-markdown/core 1.19.0 → 1.20.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.
Files changed (58) hide show
  1. package/assets/generated.md +1 -8
  2. package/dist/config.d.ts +8 -6
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +33 -8
  5. package/dist/const/patterns.d.ts +9 -9
  6. package/dist/const/patterns.js +9 -9
  7. package/dist/diff.js +1 -34
  8. package/dist/directives/normalize.d.ts.map +1 -1
  9. package/dist/directives/normalize.js +3 -1
  10. package/dist/event-emitter.d.ts +7 -2
  11. package/dist/event-emitter.d.ts.map +1 -1
  12. package/dist/event-emitter.js +32 -23
  13. package/dist/event-map.d.ts +1 -0
  14. package/dist/event-map.d.ts.map +1 -1
  15. package/dist/event-map.js +1 -0
  16. package/dist/events/diff-check.d.ts +7 -8
  17. package/dist/events/diff-check.d.ts.map +1 -1
  18. package/dist/events/diff-check.js +3 -6
  19. package/dist/events/generate-index-metafile.d.ts +7 -8
  20. package/dist/events/generate-index-metafile.d.ts.map +1 -1
  21. package/dist/events/generate-index-metafile.js +3 -6
  22. package/dist/events/index.d.ts +1 -3
  23. package/dist/events/index.d.ts.map +1 -1
  24. package/dist/events/index.js +1 -8
  25. package/dist/events/print-type-events.d.ts +5 -2
  26. package/dist/events/print-type-events.d.ts.map +1 -1
  27. package/dist/events/print-type-events.js +5 -2
  28. package/dist/events/print-type.d.ts +4 -78
  29. package/dist/events/print-type.d.ts.map +1 -1
  30. package/dist/events/print-type.js +3 -66
  31. package/dist/events/render-homepage.d.ts +5 -6
  32. package/dist/events/render-homepage.d.ts.map +1 -1
  33. package/dist/events/render-homepage.js +3 -6
  34. package/dist/events/render-root-types.d.ts +5 -6
  35. package/dist/events/render-root-types.d.ts.map +1 -1
  36. package/dist/events/render-root-types.js +3 -6
  37. package/dist/events/render-type-entities.d.ts +6 -7
  38. package/dist/events/render-type-entities.d.ts.map +1 -1
  39. package/dist/events/render-type-entities.js +3 -6
  40. package/dist/events/schema-load.d.ts +7 -8
  41. package/dist/events/schema-load.d.ts.map +1 -1
  42. package/dist/events/schema-load.js +3 -6
  43. package/dist/generator.js +1 -1
  44. package/dist/graphql-config.js +1 -34
  45. package/dist/index.d.ts +2 -2
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +3 -1
  48. package/dist/options/builder.d.ts +13 -13
  49. package/dist/options/builder.d.ts.map +1 -1
  50. package/dist/options/builder.js +25 -25
  51. package/dist/printer.js +1 -34
  52. package/dist/renderer.d.ts +1 -1
  53. package/dist/renderer.d.ts.map +1 -1
  54. package/dist/renderer.js +20 -11
  55. package/package.json +24 -13
  56. package/dist/events/base.d.ts +0 -119
  57. package/dist/events/base.d.ts.map +0 -1
  58. package/dist/events/base.js +0 -149
@@ -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
@@ -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,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,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAqDnC;IAED;;;;;;;;OAQG;IACG,kBAAkB,CACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,uBAAuB,CAAC,EAAE,MAAM,EAAE,GACjC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAkH1B;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,CAkCnE;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;CA+BjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,WAAW,mRAmBvB,CAAC"}
package/dist/renderer.js CHANGED
@@ -414,21 +414,27 @@ class Renderer {
414
414
  return Promise.all(Object.keys(type).map(async (name) => {
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 (isOperationRootType && name.includes(".")) {
420
- const namespaceParts = name.split(".").filter(Boolean);
421
- if (namespaceParts.length > 1) {
422
- entityName = namespaceParts.at(-1) ?? entityName;
423
- for (const namespace of namespaceParts.slice(0, -1)) {
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 === "") {
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.19.0",
8
+ "version": "1.20.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -58,23 +58,34 @@
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.1.9",
67
- "@graphql-markdown/logger": "^1.0.5",
68
- "@graphql-markdown/utils": "^1.9.2"
69
- },
70
- "peerDependencies": {
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.1",
77
+ "@graphql-markdown/logger": "^1.0.6",
78
+ "@graphql-markdown/types": "^1.12.0",
79
+ "@graphql-markdown/utils": "^1.11.0"
75
80
  },
76
81
  "devDependencies": {
77
- "@graphql-markdown/types": "^1.10.1"
82
+ "@graphql-markdown/tooling-config": "^1.0.0"
83
+ },
84
+ "peerDependencies": {
85
+ "@graphql-markdown/diff": "^1.1.14",
86
+ "@graphql-markdown/helpers": "^1.0.13",
87
+ "@graphql-markdown/printer-legacy": "^1.15.0",
88
+ "graphql-config": "5.1.6"
78
89
  },
79
90
  "peerDependenciesMeta": {
80
91
  "@graphql-markdown/printer-legacy": {
@@ -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"}
@@ -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;