nest-graph-inspector 0.10.0 → 0.12.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 (36) hide show
  1. package/dist/adapters/http-output.adapter.d.ts +31 -0
  2. package/dist/adapters/http-output.adapter.d.ts.map +1 -1
  3. package/dist/adapters/http-output.adapter.js +185 -1
  4. package/dist/adapters/http-output.adapter.js.map +1 -1
  5. package/dist/adapters/viewer-output.adapter.d.ts.map +1 -1
  6. package/dist/adapters/viewer-output.adapter.js +1 -0
  7. package/dist/adapters/viewer-output.adapter.js.map +1 -1
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/nest-graph-inspector.setup.d.ts.map +1 -1
  13. package/dist/nest-graph-inspector.setup.js +11 -2
  14. package/dist/nest-graph-inspector.setup.js.map +1 -1
  15. package/dist/nest-graph-inspector.type.d.ts +22 -0
  16. package/dist/nest-graph-inspector.type.d.ts.map +1 -1
  17. package/dist/types/graph-layout.schema.d.ts +93 -0
  18. package/dist/types/graph-layout.schema.d.ts.map +1 -0
  19. package/dist/types/graph-layout.schema.js +182 -0
  20. package/dist/types/graph-layout.schema.js.map +1 -0
  21. package/dist/types/graph-layout.type.d.ts +31 -0
  22. package/dist/types/graph-layout.type.d.ts.map +1 -0
  23. package/dist/types/graph-layout.type.js +3 -0
  24. package/dist/types/graph-layout.type.js.map +1 -0
  25. package/package.json +1 -1
  26. package/src/adapters/http-output.adapter.spec.ts +332 -1
  27. package/src/adapters/http-output.adapter.ts +242 -0
  28. package/src/adapters/viewer-output.adapter.spec.ts +15 -0
  29. package/src/adapters/viewer-output.adapter.ts +1 -0
  30. package/src/index.ts +2 -0
  31. package/src/nest-graph-inspector.setup.spec.ts +87 -0
  32. package/src/nest-graph-inspector.setup.ts +17 -3
  33. package/src/nest-graph-inspector.type.ts +25 -0
  34. package/src/types/graph-layout.schema.spec.ts +256 -0
  35. package/src/types/graph-layout.schema.ts +251 -0
  36. package/src/types/graph-layout.type.ts +34 -0
@@ -126,6 +126,11 @@ export type NestGraphInspectorOutput = {
126
126
  port?: number;
127
127
  path?: string;
128
128
  directRun?: NestGraphInspectorViewerDirectRunOptions;
129
+ /**
130
+ * Where this output reads and saves the graph layout. Overrides the
131
+ * module-wide `layoutFilePath`.
132
+ */
133
+ layoutFilePath?: string;
129
134
  } | {
130
135
  type: 'markdown';
131
136
  path: string;
@@ -138,7 +143,15 @@ export type NestGraphInspectorOutput = {
138
143
  host?: string;
139
144
  port?: number;
140
145
  path?: string;
146
+ /**
147
+ * Where this output reads and saves the graph layout. Overrides the
148
+ * module-wide `layoutFilePath`.
149
+ */
150
+ layoutFilePath?: string;
141
151
  };
152
+ export type NestGraphInspectorViewerOptions = Extract<NestGraphInspectorOutput, {
153
+ type: 'viewer';
154
+ }>;
142
155
  export interface NestGraphInspectorModuleOptions {
143
156
  /**
144
157
  * Which "Root" of module that need to be inspect
@@ -204,5 +217,14 @@ export interface NestGraphInspectorModuleOptions {
204
217
  * wins where it sets a value.
205
218
  */
206
219
  directRun?: NestGraphInspectorViewerDirectRunOptions;
220
+ /**
221
+ * The file the viewer's graph layout is read from (`GET {path}/layout.json`)
222
+ * and saved to (`POST {path}/layout`), for every `viewer` and `http` output
223
+ * that does not set its own `layoutFilePath`.
224
+ *
225
+ * Defaults to `'./nest-graph-layout.json'`. A relative path resolves against
226
+ * `process.cwd()`; missing parent directories are created on save.
227
+ */
228
+ layoutFilePath?: string;
207
229
  }
208
230
  //# sourceMappingURL=nest-graph-inspector.type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nest-graph-inspector.type.d.ts","sourceRoot":"","sources":["../src/nest-graph-inspector.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,MAAM,wCAAwC,GAAG;IACrD;;;;;;;OAOG;IACH,OAAO,CAA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CAAE,CACnB,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;IAElB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,EAAE,wBAAwB,EAAE,CAAC;IAErC;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,oCAAoC,CAAC;IAEnD;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,wCAAwC,CAAC;IAErD;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,93 @@
1
+ import type { GraphLayout } from './graph-layout.type';
2
+ export declare const GRAPH_LAYOUT_SCHEMA_VERSION = "1";
3
+ export declare const GRAPH_LAYOUT_SCHEMA_ID = "https://albasyir.github.io/nest-graph-inspector/schemas/graph-layout-v1.schema.json";
4
+ export declare const GRAPH_LAYOUT_JSON_SCHEMA: {
5
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
6
+ readonly $id: "https://albasyir.github.io/nest-graph-inspector/schemas/graph-layout-v1.schema.json";
7
+ readonly title: "Nest Graph Inspector Graph Layout";
8
+ readonly type: "object";
9
+ readonly additionalProperties: false;
10
+ readonly required: readonly ["version", "modules"];
11
+ readonly properties: {
12
+ readonly $schema: {
13
+ readonly type: "string";
14
+ };
15
+ readonly version: {
16
+ readonly const: "1";
17
+ };
18
+ readonly modules: {
19
+ readonly type: "object";
20
+ readonly propertyNames: {
21
+ readonly $ref: "#/$defs/key";
22
+ };
23
+ readonly additionalProperties: {
24
+ readonly $ref: "#/$defs/module";
25
+ };
26
+ };
27
+ };
28
+ readonly $defs: {
29
+ readonly key: {
30
+ readonly description: "A layout file is committed and shared, so a key a naive deep merge would follow into Object.prototype is refused.";
31
+ readonly not: {
32
+ readonly const: "__proto__";
33
+ };
34
+ };
35
+ readonly position: {
36
+ readonly type: "object";
37
+ readonly additionalProperties: false;
38
+ readonly required: readonly ["x", "y"];
39
+ readonly properties: {
40
+ readonly x: {
41
+ readonly type: "number";
42
+ };
43
+ readonly y: {
44
+ readonly type: "number";
45
+ };
46
+ };
47
+ };
48
+ readonly module: {
49
+ readonly type: "object";
50
+ readonly additionalProperties: false;
51
+ readonly required: readonly ["position"];
52
+ readonly properties: {
53
+ readonly position: {
54
+ readonly $ref: "#/$defs/position";
55
+ };
56
+ readonly isCollapsed: {
57
+ readonly type: "boolean";
58
+ };
59
+ readonly items: {
60
+ readonly type: "object";
61
+ readonly propertyNames: {
62
+ readonly $ref: "#/$defs/key";
63
+ };
64
+ readonly additionalProperties: {
65
+ readonly $ref: "#/$defs/position";
66
+ };
67
+ };
68
+ };
69
+ };
70
+ };
71
+ };
72
+ export type GraphLayoutValidationResult = {
73
+ ok: true;
74
+ layout: GraphLayout;
75
+ } | {
76
+ ok: false;
77
+ errors: string[];
78
+ };
79
+ /**
80
+ * Checks a value against `GRAPH_LAYOUT_JSON_SCHEMA` without a schema engine,
81
+ * since the package ships no runtime dependency beyond ts-morph. Required and
82
+ * allowed property names are read from the schema itself, so the two cannot
83
+ * drift apart on shape.
84
+ *
85
+ * Coordinates must also be finite: `JSON.parse('1e999')` is `Infinity`, which
86
+ * `JSON.stringify` would write back as `null`.
87
+ *
88
+ * Each error names a JSON Pointer rooted at `layout`, such as
89
+ * `layout/modules/UserModule/position/x must be a finite number`. At most 20
90
+ * errors are reported.
91
+ */
92
+ export declare function validateGraphLayout(value: unknown): GraphLayoutValidationResult;
93
+ //# sourceMappingURL=graph-layout.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-layout.schema.d.ts","sourceRoot":"","sources":["../../src/types/graph-layout.schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,eAAO,MAAM,sBAAsB,wFACoD,CAAC;AAExF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoE3B,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACnC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GACjC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAYpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,2BAA2B,CAa7B"}
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GRAPH_LAYOUT_JSON_SCHEMA = exports.GRAPH_LAYOUT_SCHEMA_ID = exports.GRAPH_LAYOUT_SCHEMA_VERSION = void 0;
4
+ exports.validateGraphLayout = validateGraphLayout;
5
+ exports.GRAPH_LAYOUT_SCHEMA_VERSION = '1';
6
+ exports.GRAPH_LAYOUT_SCHEMA_ID = 'https://albasyir.github.io/nest-graph-inspector/schemas/graph-layout-v1.schema.json';
7
+ exports.GRAPH_LAYOUT_JSON_SCHEMA = {
8
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
9
+ $id: exports.GRAPH_LAYOUT_SCHEMA_ID,
10
+ title: 'Nest Graph Inspector Graph Layout',
11
+ type: 'object',
12
+ additionalProperties: false,
13
+ required: ['version', 'modules'],
14
+ properties: {
15
+ $schema: {
16
+ type: 'string',
17
+ },
18
+ version: {
19
+ const: exports.GRAPH_LAYOUT_SCHEMA_VERSION,
20
+ },
21
+ modules: {
22
+ type: 'object',
23
+ propertyNames: {
24
+ $ref: '#/$defs/key',
25
+ },
26
+ additionalProperties: {
27
+ $ref: '#/$defs/module',
28
+ },
29
+ },
30
+ },
31
+ $defs: {
32
+ key: {
33
+ description: 'A layout file is committed and shared, so a key a naive deep merge would follow into Object.prototype is refused.',
34
+ not: {
35
+ const: '__proto__',
36
+ },
37
+ },
38
+ position: {
39
+ type: 'object',
40
+ additionalProperties: false,
41
+ required: ['x', 'y'],
42
+ properties: {
43
+ x: {
44
+ type: 'number',
45
+ },
46
+ y: {
47
+ type: 'number',
48
+ },
49
+ },
50
+ },
51
+ module: {
52
+ type: 'object',
53
+ additionalProperties: false,
54
+ required: ['position'],
55
+ properties: {
56
+ position: {
57
+ $ref: '#/$defs/position',
58
+ },
59
+ isCollapsed: {
60
+ type: 'boolean',
61
+ },
62
+ items: {
63
+ type: 'object',
64
+ propertyNames: {
65
+ $ref: '#/$defs/key',
66
+ },
67
+ additionalProperties: {
68
+ $ref: '#/$defs/position',
69
+ },
70
+ },
71
+ },
72
+ },
73
+ },
74
+ };
75
+ /** One error is enough to reject a layout; a handful is enough to fix one. */
76
+ const MAX_REPORTED_ERRORS = 20;
77
+ /**
78
+ * Checks a value against `GRAPH_LAYOUT_JSON_SCHEMA` without a schema engine,
79
+ * since the package ships no runtime dependency beyond ts-morph. Required and
80
+ * allowed property names are read from the schema itself, so the two cannot
81
+ * drift apart on shape.
82
+ *
83
+ * Coordinates must also be finite: `JSON.parse('1e999')` is `Infinity`, which
84
+ * `JSON.stringify` would write back as `null`.
85
+ *
86
+ * Each error names a JSON Pointer rooted at `layout`, such as
87
+ * `layout/modules/UserModule/position/x must be a finite number`. At most 20
88
+ * errors are reported.
89
+ */
90
+ function validateGraphLayout(value) {
91
+ const errors = [];
92
+ const report = (pointer, problem) => {
93
+ if (errors.length < MAX_REPORTED_ERRORS) {
94
+ errors.push(`${pointer} ${problem}`);
95
+ }
96
+ };
97
+ validateRoot(value, report);
98
+ return errors.length
99
+ ? { ok: false, errors }
100
+ : { ok: true, layout: value };
101
+ }
102
+ function validateRoot(value, report) {
103
+ const pointer = 'layout';
104
+ if (!isObject(value)) {
105
+ report(pointer, 'must be a JSON object');
106
+ return;
107
+ }
108
+ checkShape(value, pointer, exports.GRAPH_LAYOUT_JSON_SCHEMA, report);
109
+ if (Object.hasOwn(value, '$schema') && typeof value.$schema !== 'string') {
110
+ report(childPointer(pointer, '$schema'), 'must be a string');
111
+ }
112
+ if (Object.hasOwn(value, 'version') &&
113
+ value.version !== exports.GRAPH_LAYOUT_SCHEMA_VERSION) {
114
+ report(childPointer(pointer, 'version'), `must be "${exports.GRAPH_LAYOUT_SCHEMA_VERSION}"`);
115
+ }
116
+ if (Object.hasOwn(value, 'modules')) {
117
+ validateRecord(value.modules, childPointer(pointer, 'modules'), validateModule, report);
118
+ }
119
+ }
120
+ function validateModule(value, pointer, report) {
121
+ if (!isObject(value)) {
122
+ report(pointer, 'must be an object');
123
+ return;
124
+ }
125
+ checkShape(value, pointer, exports.GRAPH_LAYOUT_JSON_SCHEMA.$defs.module, report);
126
+ if (Object.hasOwn(value, 'position')) {
127
+ validatePosition(value.position, childPointer(pointer, 'position'), report);
128
+ }
129
+ if (Object.hasOwn(value, 'isCollapsed') &&
130
+ typeof value.isCollapsed !== 'boolean') {
131
+ report(childPointer(pointer, 'isCollapsed'), 'must be a boolean');
132
+ }
133
+ if (Object.hasOwn(value, 'items')) {
134
+ validateRecord(value.items, childPointer(pointer, 'items'), validatePosition, report);
135
+ }
136
+ }
137
+ function validatePosition(value, pointer, report) {
138
+ if (!isObject(value)) {
139
+ report(pointer, 'must be an object');
140
+ return;
141
+ }
142
+ checkShape(value, pointer, exports.GRAPH_LAYOUT_JSON_SCHEMA.$defs.position, report);
143
+ for (const axis of exports.GRAPH_LAYOUT_JSON_SCHEMA.$defs.position.required) {
144
+ if (Object.hasOwn(value, axis) && !Number.isFinite(value[axis])) {
145
+ report(childPointer(pointer, axis), 'must be a finite number');
146
+ }
147
+ }
148
+ }
149
+ function validateRecord(value, pointer, validateEntry, report) {
150
+ if (!isObject(value)) {
151
+ report(pointer, 'must be an object');
152
+ return;
153
+ }
154
+ const forbiddenKey = exports.GRAPH_LAYOUT_JSON_SCHEMA.$defs.key.not.const;
155
+ for (const [key, entry] of Object.entries(value)) {
156
+ if (key === forbiddenKey) {
157
+ report(pointer, `must not contain the key "${forbiddenKey}"`);
158
+ continue;
159
+ }
160
+ validateEntry(entry, childPointer(pointer, key), report);
161
+ }
162
+ }
163
+ function checkShape(value, pointer, shape, report) {
164
+ for (const name of shape.required) {
165
+ if (!Object.hasOwn(value, name)) {
166
+ report(pointer, `is missing required property "${name}"`);
167
+ }
168
+ }
169
+ for (const name of Object.keys(value)) {
170
+ if (!Object.hasOwn(shape.properties, name)) {
171
+ report(childPointer(pointer, name), 'is not a known property');
172
+ }
173
+ }
174
+ }
175
+ function isObject(value) {
176
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
177
+ }
178
+ /** RFC 6901 escaping, so a key containing `/` cannot be misread as a path. */
179
+ function childPointer(pointer, key) {
180
+ return `${pointer}/${key.replace(/~/g, '~0').replace(/\//g, '~1')}`;
181
+ }
182
+ //# sourceMappingURL=graph-layout.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-layout.schema.js","sourceRoot":"","sources":["../../src/types/graph-layout.schema.ts"],"names":[],"mappings":";;;AAwGA,kDAeC;AArHY,QAAA,2BAA2B,GAAG,GAAG,CAAC;AAElC,QAAA,sBAAsB,GACjC,qFAAqF,CAAC;AAE3E,QAAA,wBAAwB,GAAG;IACtC,OAAO,EAAE,8CAA8C;IACvD,GAAG,EAAE,8BAAsB;IAC3B,KAAK,EAAE,mCAAmC;IAC1C,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAChC,UAAU,EAAE;QACV,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;SACf;QACD,OAAO,EAAE;YACP,KAAK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AC,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;YAC3C,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,yBAAyB,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,8EAA8E;AAC9E,SAAS,YAAY,CAAC,OAAe,EAAE,GAAW;IAChD,OAAO,GAAG,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;AACtE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A node's position on the viewer canvas, in canvas units.
3
+ */
4
+ export type GraphLayoutPosition = {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ /**
9
+ * Where one module sits on the canvas, and where its items sit inside it.
10
+ */
11
+ export type GraphLayoutModule = {
12
+ position: GraphLayoutPosition;
13
+ /** Whether the module is drawn collapsed. Absent means expanded. */
14
+ isCollapsed?: boolean;
15
+ /**
16
+ * Item positions keyed by the viewer's item id. The library treats the keys
17
+ * as opaque; the viewer draws items relative to their module.
18
+ */
19
+ items?: Record<string, GraphLayoutPosition>;
20
+ };
21
+ /**
22
+ * The arrangement of a graph in the viewer, persisted to `layoutFilePath` and
23
+ * served at `{path}/layout.json`.
24
+ */
25
+ export type GraphLayout = {
26
+ $schema?: string;
27
+ version: '1';
28
+ /** Keyed by module class name, as in `GraphOutput.modules`. */
29
+ modules: Record<string, GraphLayoutModule>;
30
+ };
31
+ //# sourceMappingURL=graph-layout.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-layout.type.d.ts","sourceRoot":"","sources":["../../src/types/graph-layout.type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,mBAAmB,CAAC;IAE9B,oEAAoE;IACpE,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=graph-layout.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-layout.type.js","sourceRoot":"","sources":["../../src/types/graph-layout.type.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nest-graph-inspector",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "NestJS module graph inspector for discovery and dependency analysis",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,