nestjs-docfy 0.3.6 → 1.0.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 (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -67
  3. package/dist/apply-docfy-metadata.d.ts +37 -0
  4. package/dist/apply-docfy-metadata.js +55 -0
  5. package/dist/apply-docfy-metadata.js.map +1 -0
  6. package/dist/cli/build-openapi-patch.d.ts +16 -12
  7. package/dist/cli/build-openapi-patch.js +98 -15
  8. package/dist/cli/build-openapi-patch.js.map +1 -1
  9. package/dist/cli/check.js.map +1 -1
  10. package/dist/cli/coverage.js +1 -3
  11. package/dist/cli/coverage.js.map +1 -1
  12. package/dist/cli/detect-project.js +1 -5
  13. package/dist/cli/detect-project.js.map +1 -1
  14. package/dist/cli/errors.js.map +1 -1
  15. package/dist/cli/eval-decorator-args.d.ts +5 -3
  16. package/dist/cli/eval-decorator-args.js +64 -11
  17. package/dist/cli/eval-decorator-args.js.map +1 -1
  18. package/dist/cli/extract-docs-config.d.ts +21 -1
  19. package/dist/cli/extract-docs-config.js +18 -6
  20. package/dist/cli/extract-docs-config.js.map +1 -1
  21. package/dist/cli/extract-methods.d.ts +11 -0
  22. package/dist/cli/extract-methods.js +113 -29
  23. package/dist/cli/extract-methods.js.map +1 -1
  24. package/dist/cli/generate-file.js +24 -24
  25. package/dist/cli/generate-file.js.map +1 -1
  26. package/dist/cli/index.js +5 -6
  27. package/dist/cli/index.js.map +1 -1
  28. package/dist/cli/lint.js +1 -3
  29. package/dist/cli/lint.js.map +1 -1
  30. package/dist/cli/logger.js +12 -6
  31. package/dist/cli/logger.js.map +1 -1
  32. package/dist/cli/merge-docs.js.map +1 -1
  33. package/dist/cli/merge-spec-patch.d.ts +15 -8
  34. package/dist/cli/merge-spec-patch.js +20 -4
  35. package/dist/cli/merge-spec-patch.js.map +1 -1
  36. package/dist/cli/parse-args.js +2 -6
  37. package/dist/cli/parse-args.js.map +1 -1
  38. package/dist/cli/patch-spec.d.ts +32 -8
  39. package/dist/cli/patch-spec.js +37 -15
  40. package/dist/cli/patch-spec.js.map +1 -1
  41. package/dist/cli/resolve-tsconfig.js +1 -5
  42. package/dist/cli/resolve-tsconfig.js.map +1 -1
  43. package/dist/cli/scan-controllers.d.ts +11 -0
  44. package/dist/cli/scan-controllers.js +10 -3
  45. package/dist/cli/scan-controllers.js.map +1 -1
  46. package/dist/cli/watch.js +3 -1
  47. package/dist/cli/watch.js.map +1 -1
  48. package/dist/cli/writer.js.map +1 -1
  49. package/dist/docfy-ui.module.d.ts +26 -10
  50. package/dist/docfy-ui.module.js +42 -6
  51. package/dist/docfy-ui.module.js.map +1 -1
  52. package/dist/docfy.module.js +1 -1
  53. package/dist/docfy.module.js.map +1 -1
  54. package/dist/docs.js.map +1 -1
  55. package/dist/index.d.ts +2 -1
  56. package/dist/index.js +3 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/plugin/generate-metadata.d.ts +35 -0
  59. package/dist/plugin/generate-metadata.js +46 -0
  60. package/dist/plugin/generate-metadata.js.map +1 -0
  61. package/dist/plugin/index.d.ts +30 -0
  62. package/dist/plugin/index.js +62 -0
  63. package/dist/plugin/index.js.map +1 -0
  64. package/dist/registry.d.ts +3 -3
  65. package/dist/registry.js.map +1 -1
  66. package/dist/resolve-docs-path.d.ts +1 -1
  67. package/dist/resolve-docs-path.js.map +1 -1
  68. package/dist/resolve-source-from-stack.js.map +1 -1
  69. package/dist/with-docs.decorator.js.map +1 -1
  70. package/package.json +32 -3
  71. package/dist/require-ts.d.ts +0 -32
  72. package/dist/require-ts.js +0 -122
  73. package/dist/require-ts.js.map +0 -1
@@ -1,122 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.requireTypeScriptFile = requireTypeScriptFile;
37
- const fs = __importStar(require("fs"));
38
- /**
39
- * Loads a .ts companion docs file at runtime without relying on a
40
- * pre-registered TypeScript loader (ts-node, tsx, etc.).
41
- *
42
- * Why this is needed: docs files are intentionally never imported by
43
- * application code (that's the whole point of the *.controller.docs.ts
44
- * convention — they attach metadata from outside the controller). Under
45
- * NestJS CLI's `webpack: true` build mode, that means they're never part
46
- * of the bundle's reachable module graph, so they never get compiled to
47
- * .js even when the rest of the app is — there's nothing for a plain
48
- * `require()` to load. resolveDocsPath can correctly locate the original
49
- * .ts file (see resolve-source-from-stack.ts), but loading it still needs
50
- * this.
51
- *
52
- * Registers `require.extensions['.ts']` — exactly the mechanism ts-node's
53
- * own `register()` uses — rather than manually constructing a `Module`
54
- * instance and calling `_compile()` directly. That distinction matters for
55
- * correctness, not just style: Node's module *resolution* (not just
56
- * compilation) only tries an extension if it's a registered key of
57
- * `require.extensions`. A docs file importing a sibling relative path
58
- * (`import { UsersController } from './users.controller'`) needs Node to
59
- * try `./users.controller.ts` while resolving — manually compiling just
60
- * the entry file doesn't make Node try `.ts` for anything *it* requires
61
- * in turn, so any relative import inside the docs file would still throw
62
- * "Cannot find module" one level down.
63
- *
64
- * Transpiles with esbuild — type-stripping only, since docs files call
65
- * decorator factories as plain functions (`docs(Controller, { classDecorators:
66
- * [ApiTags('x')] })`) rather than using TypeScript decorator syntax
67
- * themselves, so no decorator-metadata emulation is needed.
68
- */
69
- function requireTypeScriptFile(absPath) {
70
- console.error('[DEBUG requireTypeScriptFile]', JSON.stringify(absPath), 'exists=', fs.existsSync(absPath));
71
- if (!fs.existsSync(absPath)) {
72
- // Matches the shape of Node's own require() MODULE_NOT_FOUND error, so
73
- // callers that distinguish "file doesn't exist" from "file threw while
74
- // loading" (DocfyModule's isMissingDocsFile) work the same regardless
75
- // of which loader actually handled the path.
76
- throw Object.assign(new Error(`Cannot find module '${absPath}'`), {
77
- code: 'MODULE_NOT_FOUND',
78
- });
79
- }
80
- registerTsExtension();
81
- // eslint-disable-next-line @typescript-eslint/no-require-imports
82
- return require(absPath);
83
- }
84
- let registered = false;
85
- function registerTsExtension() {
86
- if (registered || require.extensions['.ts'])
87
- return;
88
- const esbuild = loadEsbuild();
89
- if (!esbuild) {
90
- throw new Error(`[nestjs-docfy] Cannot load a .ts docs file: no TypeScript loader is registered ` +
91
- `(e.g. ts-node) and the "esbuild" dependency isn't available. Install esbuild ` +
92
- `(it's a direct dependency of nestjs-docfy and should already be present — ` +
93
- `check your install), or disable webpack bundling ("webpack": false in ` +
94
- `nest-cli.json) so docs files get compiled to .js like everything else.`);
95
- }
96
- require.extensions['.ts'] = (mod, filename) => {
97
- const source = fs.readFileSync(filename, 'utf8');
98
- const { code } = esbuild.transformSync(source, {
99
- loader: 'ts',
100
- format: 'cjs',
101
- target: 'es2019',
102
- sourcefile: filename,
103
- // A docs file's own relative imports can pull in real application
104
- // source (e.g. the controller it documents), which legitimately uses
105
- // NestJS's decorator syntax — without this, esbuild rejects parameter
106
- // decorators like `@Body()` outright.
107
- tsconfigRaw: { compilerOptions: { experimentalDecorators: true, emitDecoratorMetadata: true } },
108
- });
109
- mod._compile(code, filename);
110
- };
111
- registered = true;
112
- }
113
- function loadEsbuild() {
114
- try {
115
- // eslint-disable-next-line @typescript-eslint/no-require-imports
116
- return require('esbuild');
117
- }
118
- catch {
119
- return null;
120
- }
121
- }
122
- //# sourceMappingURL=require-ts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"require-ts.js","sourceRoot":"","sources":["../src/require-ts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,sDAeC;AAtDD,uCAAyB;AAQzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,SAAgB,qBAAqB,CAAC,OAAe;IACnD,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3G,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,uEAAuE;QACvE,uEAAuE;QACvE,sEAAsE;QACtE,6CAA6C;QAC7C,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,OAAO,GAAG,CAAC,EAAE;YAChE,IAAI,EAAE,kBAAkB;SACzB,CAAC,CAAC;IACL,CAAC;IAED,mBAAmB,EAAE,CAAC;IACtB,iEAAiE;IACjE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,SAAS,mBAAmB;IAC1B,IAAI,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO;IACpD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC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