@manulz/nest-tools 1.1.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.
@@ -0,0 +1,141 @@
1
+ import * as _nestjs_common from '@nestjs/common';
2
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
3
+ import { Observable } from 'rxjs';
4
+
5
+ interface GenerateResourceOptions {
6
+ name: string;
7
+ spec?: boolean;
8
+ flat?: boolean;
9
+ dryRun?: boolean;
10
+ cwd?: string;
11
+ }
12
+ declare function generateResource(options: GenerateResourceOptions): Promise<void>;
13
+
14
+ interface GenerateCleanArchitectureOptions {
15
+ name: string;
16
+ dryRun?: boolean;
17
+ cwd?: string;
18
+ }
19
+ declare function generateCleanArchitecture(options: GenerateCleanArchitectureOptions): Promise<void>;
20
+
21
+ interface RunCommandOptions {
22
+ cwd?: string;
23
+ dryRun?: boolean;
24
+ silent?: boolean;
25
+ }
26
+ declare function runCommand(command: string, options?: RunCommandOptions): Promise<{
27
+ stdout: string;
28
+ stderr: string;
29
+ }>;
30
+
31
+ declare const logger: {
32
+ info: (msg: string) => void;
33
+ success: (msg: string) => void;
34
+ warn: (msg: string) => void;
35
+ error: (msg: string) => void;
36
+ step: (step: string, detail?: string) => void;
37
+ };
38
+
39
+ declare function toKebabCase(str: string): string;
40
+ declare function toPascalCase(str: string): string;
41
+ declare function toCamelCase(str: string): string;
42
+
43
+ interface NestToolsConfig {
44
+ spec?: boolean;
45
+ flat?: boolean;
46
+ architecture?: 'standard' | 'clean';
47
+ packageManager?: 'npm' | 'yarn' | 'pnpm';
48
+ }
49
+ declare const DEFAULT_CONFIG: NestToolsConfig;
50
+ declare function loadConfig(cwd?: string): Promise<NestToolsConfig>;
51
+ declare function createDefaultConfig(cwd?: string): Promise<string>;
52
+
53
+ interface DoctorReport {
54
+ isNestProject: boolean;
55
+ issues: string[];
56
+ recommendations: string[];
57
+ }
58
+ declare function runDoctor(cwd?: string): Promise<DoctorReport>;
59
+
60
+ declare const IS_PUBLIC_KEY = "isPublic";
61
+ /**
62
+ * Decorator to mark routes as public, skipping global authentication guards.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * @Public()
67
+ * @Get('health')
68
+ * checkHealth() {
69
+ * return { status: 'ok' };
70
+ * }
71
+ * ```
72
+ */
73
+ declare const Public: () => _nestjs_common.CustomDecorator<string>;
74
+
75
+ /**
76
+ * Parameter decorator to easily retrieve the authenticated user from the Request object.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * @Get('profile')
81
+ * getProfile(@CurrentUser() user: UserEntity) {
82
+ * return user;
83
+ * }
84
+ *
85
+ * @Get('id')
86
+ * getId(@CurrentUser('id') userId: string) {
87
+ * return userId;
88
+ * }
89
+ * ```
90
+ */
91
+ declare const CurrentUser: (...dataOrPipes: (string | _nestjs_common.PipeTransform<any, any> | _nestjs_common.Type<_nestjs_common.PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
92
+
93
+ interface StandardApiResponse<T> {
94
+ statusCode: number;
95
+ success: boolean;
96
+ data: T;
97
+ timestamp: string;
98
+ }
99
+ /**
100
+ * Global or controller interceptor that wraps successful responses in a standard JSON envelope.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * // In main.ts
105
+ * app.useGlobalInterceptors(new TransformResponseInterceptor());
106
+ * ```
107
+ */
108
+ declare class TransformResponseInterceptor<T> implements NestInterceptor<T, StandardApiResponse<T>> {
109
+ intercept(context: ExecutionContext, next: CallHandler): Observable<StandardApiResponse<T>>;
110
+ }
111
+
112
+ type SortOrder = 'ASC' | 'DESC' | 'asc' | 'desc';
113
+ declare class PaginationQueryDto {
114
+ page?: number;
115
+ limit?: number;
116
+ sortBy?: string;
117
+ order?: SortOrder;
118
+ search?: string;
119
+ get skip(): number;
120
+ get take(): number;
121
+ }
122
+
123
+ interface PaginationMeta {
124
+ itemCount: number;
125
+ totalItems: number;
126
+ itemsPerPage: number;
127
+ totalPages: number;
128
+ currentPage: number;
129
+ hasNextPage: boolean;
130
+ hasPreviousPage: boolean;
131
+ }
132
+ interface PaginatedResult<T> {
133
+ data: T[];
134
+ meta: PaginationMeta;
135
+ }
136
+ /**
137
+ * Creates a paginated response object with calculated metadata.
138
+ */
139
+ declare function createPaginatedResponse<T>(items: T[], totalItems: number, page?: number, limit?: number): PaginatedResult<T>;
140
+
141
+ export { CurrentUser, DEFAULT_CONFIG, type DoctorReport, type GenerateCleanArchitectureOptions, type GenerateResourceOptions, IS_PUBLIC_KEY, type NestToolsConfig, type PaginatedResult, type PaginationMeta, PaginationQueryDto, Public, type RunCommandOptions, type SortOrder, type StandardApiResponse, TransformResponseInterceptor, createDefaultConfig, createPaginatedResponse, generateCleanArchitecture, generateResource, loadConfig, logger, runCommand, runDoctor, toCamelCase, toKebabCase, toPascalCase };
@@ -0,0 +1,141 @@
1
+ import * as _nestjs_common from '@nestjs/common';
2
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
3
+ import { Observable } from 'rxjs';
4
+
5
+ interface GenerateResourceOptions {
6
+ name: string;
7
+ spec?: boolean;
8
+ flat?: boolean;
9
+ dryRun?: boolean;
10
+ cwd?: string;
11
+ }
12
+ declare function generateResource(options: GenerateResourceOptions): Promise<void>;
13
+
14
+ interface GenerateCleanArchitectureOptions {
15
+ name: string;
16
+ dryRun?: boolean;
17
+ cwd?: string;
18
+ }
19
+ declare function generateCleanArchitecture(options: GenerateCleanArchitectureOptions): Promise<void>;
20
+
21
+ interface RunCommandOptions {
22
+ cwd?: string;
23
+ dryRun?: boolean;
24
+ silent?: boolean;
25
+ }
26
+ declare function runCommand(command: string, options?: RunCommandOptions): Promise<{
27
+ stdout: string;
28
+ stderr: string;
29
+ }>;
30
+
31
+ declare const logger: {
32
+ info: (msg: string) => void;
33
+ success: (msg: string) => void;
34
+ warn: (msg: string) => void;
35
+ error: (msg: string) => void;
36
+ step: (step: string, detail?: string) => void;
37
+ };
38
+
39
+ declare function toKebabCase(str: string): string;
40
+ declare function toPascalCase(str: string): string;
41
+ declare function toCamelCase(str: string): string;
42
+
43
+ interface NestToolsConfig {
44
+ spec?: boolean;
45
+ flat?: boolean;
46
+ architecture?: 'standard' | 'clean';
47
+ packageManager?: 'npm' | 'yarn' | 'pnpm';
48
+ }
49
+ declare const DEFAULT_CONFIG: NestToolsConfig;
50
+ declare function loadConfig(cwd?: string): Promise<NestToolsConfig>;
51
+ declare function createDefaultConfig(cwd?: string): Promise<string>;
52
+
53
+ interface DoctorReport {
54
+ isNestProject: boolean;
55
+ issues: string[];
56
+ recommendations: string[];
57
+ }
58
+ declare function runDoctor(cwd?: string): Promise<DoctorReport>;
59
+
60
+ declare const IS_PUBLIC_KEY = "isPublic";
61
+ /**
62
+ * Decorator to mark routes as public, skipping global authentication guards.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * @Public()
67
+ * @Get('health')
68
+ * checkHealth() {
69
+ * return { status: 'ok' };
70
+ * }
71
+ * ```
72
+ */
73
+ declare const Public: () => _nestjs_common.CustomDecorator<string>;
74
+
75
+ /**
76
+ * Parameter decorator to easily retrieve the authenticated user from the Request object.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * @Get('profile')
81
+ * getProfile(@CurrentUser() user: UserEntity) {
82
+ * return user;
83
+ * }
84
+ *
85
+ * @Get('id')
86
+ * getId(@CurrentUser('id') userId: string) {
87
+ * return userId;
88
+ * }
89
+ * ```
90
+ */
91
+ declare const CurrentUser: (...dataOrPipes: (string | _nestjs_common.PipeTransform<any, any> | _nestjs_common.Type<_nestjs_common.PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
92
+
93
+ interface StandardApiResponse<T> {
94
+ statusCode: number;
95
+ success: boolean;
96
+ data: T;
97
+ timestamp: string;
98
+ }
99
+ /**
100
+ * Global or controller interceptor that wraps successful responses in a standard JSON envelope.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * // In main.ts
105
+ * app.useGlobalInterceptors(new TransformResponseInterceptor());
106
+ * ```
107
+ */
108
+ declare class TransformResponseInterceptor<T> implements NestInterceptor<T, StandardApiResponse<T>> {
109
+ intercept(context: ExecutionContext, next: CallHandler): Observable<StandardApiResponse<T>>;
110
+ }
111
+
112
+ type SortOrder = 'ASC' | 'DESC' | 'asc' | 'desc';
113
+ declare class PaginationQueryDto {
114
+ page?: number;
115
+ limit?: number;
116
+ sortBy?: string;
117
+ order?: SortOrder;
118
+ search?: string;
119
+ get skip(): number;
120
+ get take(): number;
121
+ }
122
+
123
+ interface PaginationMeta {
124
+ itemCount: number;
125
+ totalItems: number;
126
+ itemsPerPage: number;
127
+ totalPages: number;
128
+ currentPage: number;
129
+ hasNextPage: boolean;
130
+ hasPreviousPage: boolean;
131
+ }
132
+ interface PaginatedResult<T> {
133
+ data: T[];
134
+ meta: PaginationMeta;
135
+ }
136
+ /**
137
+ * Creates a paginated response object with calculated metadata.
138
+ */
139
+ declare function createPaginatedResponse<T>(items: T[], totalItems: number, page?: number, limit?: number): PaginatedResult<T>;
140
+
141
+ export { CurrentUser, DEFAULT_CONFIG, type DoctorReport, type GenerateCleanArchitectureOptions, type GenerateResourceOptions, IS_PUBLIC_KEY, type NestToolsConfig, type PaginatedResult, type PaginationMeta, PaginationQueryDto, Public, type RunCommandOptions, type SortOrder, type StandardApiResponse, TransformResponseInterceptor, createDefaultConfig, createPaginatedResponse, generateCleanArchitecture, generateResource, loadConfig, logger, runCommand, runDoctor, toCamelCase, toKebabCase, toPascalCase };