@dudousxd/nestjs-codegen 0.14.2 → 0.16.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 +49 -0
- package/dist/cli/main.cjs +207 -57
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +206 -56
- package/dist/cli/main.js.map +1 -1
- package/dist/extension/index.cjs.map +1 -1
- package/dist/extension/index.d.cts +1 -1
- package/dist/extension/index.d.ts +1 -1
- package/dist/extension/index.js.map +1 -1
- package/dist/{index-DT8SgPxp.d.cts → index-LQNP7Ms3.d.cts} +30 -0
- package/dist/{index-DT8SgPxp.d.ts → index-LQNP7Ms3.d.ts} +30 -0
- package/dist/index.cjs +207 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +206 -56
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +227 -59
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.d.cts +56 -3
- package/dist/nest/index.d.ts +56 -3
- package/dist/nest/index.js +222 -57
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/dist/nest/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as _nestjs_common from '@nestjs/common';
|
|
2
|
+
import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy, ExecutionContext } from '@nestjs/common';
|
|
3
|
+
import { U as UserConfig } from '../index-LQNP7Ms3.cjs';
|
|
3
4
|
import 'ts-morph';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -82,4 +83,56 @@ declare class NestjsCodegenModule {
|
|
|
82
83
|
static forRoot(options?: CodegenModuleOptions): DynamicModule;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Normalize a raw query value — `string | string[] | undefined | null` (and, for
|
|
88
|
+
* back-compat with the comma-joined wire format, a comma-separated string) — into
|
|
89
|
+
* a clean `string[]`.
|
|
90
|
+
*
|
|
91
|
+
* Why this exists: Express (and therefore Nest's default query parser) hands back a
|
|
92
|
+
* **bare `string`** when a querystring key carries exactly one value (`?ids=a`), and a
|
|
93
|
+
* `string[]` only when it carries two or more (`?ids=a&ids=b`). `ParseArrayPipe` rejects
|
|
94
|
+
* the single-value form, so the *common* case (one item selected) 400s while the
|
|
95
|
+
* multi-value case passes — an inverted footgun. This helper accepts every shape:
|
|
96
|
+
*
|
|
97
|
+
* - `undefined` / `null` → `[]`
|
|
98
|
+
* - `'a'` (single value) → `['a']`
|
|
99
|
+
* - `['a', 'b']` (repeated param) → `['a', 'b']`
|
|
100
|
+
* - `'a,b'` (comma-joined wire) → `['a', 'b']` (see `@dudousxd/nestjs-client`
|
|
101
|
+
* `arrayFormat: 'comma'`, the client default)
|
|
102
|
+
*
|
|
103
|
+
* Empty/whitespace-only entries are dropped. The comma-split is a compatibility fallback:
|
|
104
|
+
* once the client sends `arrayFormat: 'repeat'` (`?ids=a&ids=b`), it degrades to a no-op
|
|
105
|
+
* and only the single-value bare-string case still needs normalizing.
|
|
106
|
+
*
|
|
107
|
+
* Exported standalone so it can back a `class-transformer` `@Transform` on a DTO field
|
|
108
|
+
* (`@Transform(({ value }) => toStringList(value))`) as well as the {@link QueryList}
|
|
109
|
+
* param decorator.
|
|
110
|
+
*/
|
|
111
|
+
declare function toStringList(raw: unknown): string[];
|
|
112
|
+
/**
|
|
113
|
+
* Resolve a `string[]` from a request's query param `key` via {@link toStringList}.
|
|
114
|
+
* The seam the {@link QueryList} decorator is built on — exported so callers can reuse
|
|
115
|
+
* the exact resolution in a bespoke `createParamDecorator`. Returns `[]` when no `key`
|
|
116
|
+
* is given (a param decorator cannot infer the target property name).
|
|
117
|
+
*/
|
|
118
|
+
declare function resolveQueryList(key: string | undefined, ctx: ExecutionContext): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Param decorator that reads an array query param safely, always yielding a clean
|
|
121
|
+
* `string[]` regardless of whether the client sent one value, many, or a comma-joined
|
|
122
|
+
* string. Use it instead of `@Query(key, ParseArrayPipe)` for *optional* array query
|
|
123
|
+
* params:
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* @Get()
|
|
127
|
+
* list(@QueryList('baseIds') baseIds: string[]) {
|
|
128
|
+
* // baseIds is always a clean string[] — [] when the param is absent,
|
|
129
|
+
* // ['a'] for ?baseIds=a, ['a','b'] for ?baseIds=a&baseIds=b or ?baseIds=a,b
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* See {@link toStringList} for the exact normalization and the single-value footgun it
|
|
134
|
+
* closes.
|
|
135
|
+
*/
|
|
136
|
+
declare const QueryList: (...dataOrPipes: (string | _nestjs_common.PipeTransform<any, any> | _nestjs_common.Type<_nestjs_common.PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
|
|
137
|
+
|
|
138
|
+
export { CODEGEN_MODULE_OPTIONS, type CodegenModuleOptions, NestjsCodegenModule, NestjsCodegenService, QueryList, resolveQueryList, shouldRun, toStringList };
|
package/dist/nest/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as _nestjs_common from '@nestjs/common';
|
|
2
|
+
import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy, ExecutionContext } from '@nestjs/common';
|
|
3
|
+
import { U as UserConfig } from '../index-LQNP7Ms3.js';
|
|
3
4
|
import 'ts-morph';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -82,4 +83,56 @@ declare class NestjsCodegenModule {
|
|
|
82
83
|
static forRoot(options?: CodegenModuleOptions): DynamicModule;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Normalize a raw query value — `string | string[] | undefined | null` (and, for
|
|
88
|
+
* back-compat with the comma-joined wire format, a comma-separated string) — into
|
|
89
|
+
* a clean `string[]`.
|
|
90
|
+
*
|
|
91
|
+
* Why this exists: Express (and therefore Nest's default query parser) hands back a
|
|
92
|
+
* **bare `string`** when a querystring key carries exactly one value (`?ids=a`), and a
|
|
93
|
+
* `string[]` only when it carries two or more (`?ids=a&ids=b`). `ParseArrayPipe` rejects
|
|
94
|
+
* the single-value form, so the *common* case (one item selected) 400s while the
|
|
95
|
+
* multi-value case passes — an inverted footgun. This helper accepts every shape:
|
|
96
|
+
*
|
|
97
|
+
* - `undefined` / `null` → `[]`
|
|
98
|
+
* - `'a'` (single value) → `['a']`
|
|
99
|
+
* - `['a', 'b']` (repeated param) → `['a', 'b']`
|
|
100
|
+
* - `'a,b'` (comma-joined wire) → `['a', 'b']` (see `@dudousxd/nestjs-client`
|
|
101
|
+
* `arrayFormat: 'comma'`, the client default)
|
|
102
|
+
*
|
|
103
|
+
* Empty/whitespace-only entries are dropped. The comma-split is a compatibility fallback:
|
|
104
|
+
* once the client sends `arrayFormat: 'repeat'` (`?ids=a&ids=b`), it degrades to a no-op
|
|
105
|
+
* and only the single-value bare-string case still needs normalizing.
|
|
106
|
+
*
|
|
107
|
+
* Exported standalone so it can back a `class-transformer` `@Transform` on a DTO field
|
|
108
|
+
* (`@Transform(({ value }) => toStringList(value))`) as well as the {@link QueryList}
|
|
109
|
+
* param decorator.
|
|
110
|
+
*/
|
|
111
|
+
declare function toStringList(raw: unknown): string[];
|
|
112
|
+
/**
|
|
113
|
+
* Resolve a `string[]` from a request's query param `key` via {@link toStringList}.
|
|
114
|
+
* The seam the {@link QueryList} decorator is built on — exported so callers can reuse
|
|
115
|
+
* the exact resolution in a bespoke `createParamDecorator`. Returns `[]` when no `key`
|
|
116
|
+
* is given (a param decorator cannot infer the target property name).
|
|
117
|
+
*/
|
|
118
|
+
declare function resolveQueryList(key: string | undefined, ctx: ExecutionContext): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Param decorator that reads an array query param safely, always yielding a clean
|
|
121
|
+
* `string[]` regardless of whether the client sent one value, many, or a comma-joined
|
|
122
|
+
* string. Use it instead of `@Query(key, ParseArrayPipe)` for *optional* array query
|
|
123
|
+
* params:
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* @Get()
|
|
127
|
+
* list(@QueryList('baseIds') baseIds: string[]) {
|
|
128
|
+
* // baseIds is always a clean string[] — [] when the param is absent,
|
|
129
|
+
* // ['a'] for ?baseIds=a, ['a','b'] for ?baseIds=a&baseIds=b or ?baseIds=a,b
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* See {@link toStringList} for the exact normalization and the single-value footgun it
|
|
134
|
+
* closes.
|
|
135
|
+
*/
|
|
136
|
+
declare const QueryList: (...dataOrPipes: (string | _nestjs_common.PipeTransform<any, any> | _nestjs_common.Type<_nestjs_common.PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
|
|
137
|
+
|
|
138
|
+
export { CODEGEN_MODULE_OPTIONS, type CodegenModuleOptions, NestjsCodegenModule, NestjsCodegenService, QueryList, resolveQueryList, shouldRun, toStringList };
|