1 | import { Type } from '../type.interface';
|
2 | import { Paramtype } from './paramtype.interface';
|
3 | export type Transform<T = any> = (value: T, metadata: ArgumentMetadata) => any;
|
4 | /**
|
5 | * Interface describing a pipe implementation's `transform()` method metadata argument.
|
6 | *
|
7 | * @see [Pipes](https://docs.nestjs.com/pipes)
|
8 | *
|
9 | * @publicApi
|
10 | */
|
11 | export interface ArgumentMetadata {
|
12 | /**
|
13 | * Indicates whether argument is a body, query, param, or custom parameter
|
14 | */
|
15 | readonly type: Paramtype;
|
16 | /**
|
17 | * Underlying base type (e.g., `String`) of the parameter, based on the type
|
18 | * definition in the route handler.
|
19 | */
|
20 | readonly metatype?: Type<any> | undefined;
|
21 | /**
|
22 | * String passed as an argument to the decorator.
|
23 | * Example: `@Body('userId')` would yield `userId`
|
24 | */
|
25 | readonly data?: string | undefined;
|
26 | }
|
27 | /**
|
28 | * Interface describing implementation of a pipe.
|
29 | *
|
30 | * @see [Pipes](https://docs.nestjs.com/pipes)
|
31 | *
|
32 | * @publicApi
|
33 | */
|
34 | export interface PipeTransform<T = any, R = any> {
|
35 | /**
|
36 | * Method to implement a custom pipe. Called with two parameters
|
37 | *
|
38 | * @param value argument before it is received by route handler method
|
39 | * @param metadata contains metadata about the value
|
40 | */
|
41 | transform(value: T, metadata: ArgumentMetadata): R;
|
42 | }
|