@dudousxd/nestjs-codegen 0.2.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/CHANGELOG.md +77 -0
- package/LICENSE +21 -0
- package/bin/nestjs-codegen.js +8 -0
- package/dist/cli/main.cjs +5044 -0
- package/dist/cli/main.cjs.map +1 -0
- package/dist/cli/main.d.cts +10 -0
- package/dist/cli/main.d.ts +10 -0
- package/dist/cli/main.js +5024 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/extension/index.cjs +35 -0
- package/dist/extension/index.cjs.map +1 -0
- package/dist/extension/index.d.cts +2 -0
- package/dist/extension/index.d.ts +2 -0
- package/dist/extension/index.js +8 -0
- package/dist/extension/index.js.map +1 -0
- package/dist/index-BwIRjOQA.d.cts +509 -0
- package/dist/index-BwIRjOQA.d.ts +509 -0
- package/dist/index.cjs +3975 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +128 -0
- package/dist/index.d.ts +128 -0
- package/dist/index.js +3938 -0
- package/dist/index.js.map +1 -0
- package/dist/nest/index.cjs +3941 -0
- package/dist/nest/index.cjs.map +1 -0
- package/dist/nest/index.d.cts +67 -0
- package/dist/nest/index.d.ts +67 -0
- package/dist/nest/index.js +3919 -0
- package/dist/nest/index.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { U as UserConfig } from '../index-BwIRjOQA.cjs';
|
|
3
|
+
import 'ts-morph';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for {@link NestjsCodegenModule.forRoot}. These ARE the codegen config —
|
|
7
|
+
* no `nestjs-codegen.config.ts` file is required. Import the module in your root
|
|
8
|
+
* `AppModule` and the typed client regenerates as you edit your controllers:
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { NestjsCodegenModule } from '@dudousxd/nestjs-codegen/nest';
|
|
13
|
+
*
|
|
14
|
+
* @Module({
|
|
15
|
+
* imports: [
|
|
16
|
+
* NestjsCodegenModule.forRoot({
|
|
17
|
+
* contracts: { glob: 'src/**\/*.controller.ts' },
|
|
18
|
+
* codegen: { outDir: 'src/generated' },
|
|
19
|
+
* extensions: [tanstackQuery()],
|
|
20
|
+
* }),
|
|
21
|
+
* ],
|
|
22
|
+
* })
|
|
23
|
+
* export class AppModule {}
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
interface CodegenModuleOptions extends UserConfig {
|
|
27
|
+
/**
|
|
28
|
+
* Master switch for the boot-time watcher. When omitted, the watcher runs in every
|
|
29
|
+
* environment EXCEPT production (`process.env.NODE_ENV === 'production'`) — codegen is a
|
|
30
|
+
* dev/CI build step, not a production-runtime concern. Set `false` to disable entirely,
|
|
31
|
+
* or `true` to force it on even in production.
|
|
32
|
+
*/
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
/** Project root used to resolve globs / `outDir`. Defaults to `process.cwd()`. */
|
|
35
|
+
cwd?: string;
|
|
36
|
+
}
|
|
37
|
+
/** DI token holding the raw {@link CodegenModuleOptions} passed to `forRoot`. */
|
|
38
|
+
declare const CODEGEN_MODULE_OPTIONS: unique symbol;
|
|
39
|
+
/**
|
|
40
|
+
* Decide whether the boot-time watcher should start, given the module options and the
|
|
41
|
+
* current `NODE_ENV`. Explicit `enabled` always wins; otherwise default on unless prod.
|
|
42
|
+
*/
|
|
43
|
+
declare function shouldRun(options: CodegenModuleOptions, env: string | undefined): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Boots the codegen watcher on application start and tears it down on shutdown.
|
|
46
|
+
* The watcher does an initial full generate, then regenerates `routes.ts`/`api.ts`/
|
|
47
|
+
* `forms.ts` as controllers and DTOs change — mirroring `nestjs-codegen codegen --watch`,
|
|
48
|
+
* but driven by the Nest lifecycle so no separate process is needed in dev.
|
|
49
|
+
*/
|
|
50
|
+
declare class NestjsCodegenService implements OnApplicationBootstrap, OnModuleDestroy {
|
|
51
|
+
private readonly options;
|
|
52
|
+
private readonly logger;
|
|
53
|
+
private watcher;
|
|
54
|
+
constructor(options: CodegenModuleOptions);
|
|
55
|
+
onApplicationBootstrap(): Promise<void>;
|
|
56
|
+
onModuleDestroy(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* NestJS module that auto-starts the codegen watcher on app boot — the recommended way
|
|
60
|
+
* to wire `@dudousxd/nestjs-codegen` into a Nest app. For CI/pre-deploy, run the
|
|
61
|
+
* one-shot CLI (`nestjs-codegen codegen`) instead.
|
|
62
|
+
*/
|
|
63
|
+
declare class NestjsCodegenModule {
|
|
64
|
+
static forRoot(options?: CodegenModuleOptions): DynamicModule;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { CODEGEN_MODULE_OPTIONS, type CodegenModuleOptions, NestjsCodegenModule, NestjsCodegenService, shouldRun };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { U as UserConfig } from '../index-BwIRjOQA.js';
|
|
3
|
+
import 'ts-morph';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for {@link NestjsCodegenModule.forRoot}. These ARE the codegen config —
|
|
7
|
+
* no `nestjs-codegen.config.ts` file is required. Import the module in your root
|
|
8
|
+
* `AppModule` and the typed client regenerates as you edit your controllers:
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { NestjsCodegenModule } from '@dudousxd/nestjs-codegen/nest';
|
|
13
|
+
*
|
|
14
|
+
* @Module({
|
|
15
|
+
* imports: [
|
|
16
|
+
* NestjsCodegenModule.forRoot({
|
|
17
|
+
* contracts: { glob: 'src/**\/*.controller.ts' },
|
|
18
|
+
* codegen: { outDir: 'src/generated' },
|
|
19
|
+
* extensions: [tanstackQuery()],
|
|
20
|
+
* }),
|
|
21
|
+
* ],
|
|
22
|
+
* })
|
|
23
|
+
* export class AppModule {}
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
interface CodegenModuleOptions extends UserConfig {
|
|
27
|
+
/**
|
|
28
|
+
* Master switch for the boot-time watcher. When omitted, the watcher runs in every
|
|
29
|
+
* environment EXCEPT production (`process.env.NODE_ENV === 'production'`) — codegen is a
|
|
30
|
+
* dev/CI build step, not a production-runtime concern. Set `false` to disable entirely,
|
|
31
|
+
* or `true` to force it on even in production.
|
|
32
|
+
*/
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
/** Project root used to resolve globs / `outDir`. Defaults to `process.cwd()`. */
|
|
35
|
+
cwd?: string;
|
|
36
|
+
}
|
|
37
|
+
/** DI token holding the raw {@link CodegenModuleOptions} passed to `forRoot`. */
|
|
38
|
+
declare const CODEGEN_MODULE_OPTIONS: unique symbol;
|
|
39
|
+
/**
|
|
40
|
+
* Decide whether the boot-time watcher should start, given the module options and the
|
|
41
|
+
* current `NODE_ENV`. Explicit `enabled` always wins; otherwise default on unless prod.
|
|
42
|
+
*/
|
|
43
|
+
declare function shouldRun(options: CodegenModuleOptions, env: string | undefined): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Boots the codegen watcher on application start and tears it down on shutdown.
|
|
46
|
+
* The watcher does an initial full generate, then regenerates `routes.ts`/`api.ts`/
|
|
47
|
+
* `forms.ts` as controllers and DTOs change — mirroring `nestjs-codegen codegen --watch`,
|
|
48
|
+
* but driven by the Nest lifecycle so no separate process is needed in dev.
|
|
49
|
+
*/
|
|
50
|
+
declare class NestjsCodegenService implements OnApplicationBootstrap, OnModuleDestroy {
|
|
51
|
+
private readonly options;
|
|
52
|
+
private readonly logger;
|
|
53
|
+
private watcher;
|
|
54
|
+
constructor(options: CodegenModuleOptions);
|
|
55
|
+
onApplicationBootstrap(): Promise<void>;
|
|
56
|
+
onModuleDestroy(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* NestJS module that auto-starts the codegen watcher on app boot — the recommended way
|
|
60
|
+
* to wire `@dudousxd/nestjs-codegen` into a Nest app. For CI/pre-deploy, run the
|
|
61
|
+
* one-shot CLI (`nestjs-codegen codegen`) instead.
|
|
62
|
+
*/
|
|
63
|
+
declare class NestjsCodegenModule {
|
|
64
|
+
static forRoot(options?: CodegenModuleOptions): DynamicModule;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { CODEGEN_MODULE_OPTIONS, type CodegenModuleOptions, NestjsCodegenModule, NestjsCodegenService, shouldRun };
|