1 | import { ArrayLiteralExpression, ClassDeclaration, Decorator, JSDoc, JSDocableNode, MethodDeclaration, NumericLiteral, ObjectLiteralExpression, ParameterDeclaration, PropertyAssignment, PropertyDeclaration, PropertySignature, SourceFile, StringLiteral, TypeLiteralNode } from "ts-morph";
|
2 | import { HttpMethod, QueryParamArrayStrategy } from "../definitions";
|
3 | /**
|
4 | * Retrieve all local dependencies of a file recursively including itself.
|
5 | *
|
6 | * @param file the source file
|
7 | * @param visitedFiles visisted files
|
8 | */
|
9 | export declare function getSelfAndLocalDependencies(file: SourceFile, visitedFiles?: SourceFile[]): SourceFile[];
|
10 | /**
|
11 | * Retrieve a class from a file with a particular decorator or throw.
|
12 | *
|
13 | * @param file the source file
|
14 | * @param decoratorName name of decorator to search for
|
15 | */
|
16 | export declare function getClassWithDecoratorOrThrow(file: SourceFile, decoratorName: string): ClassDeclaration;
|
17 | /**
|
18 | * Retrieve a property from a class declaration with a particular decorator.
|
19 | *
|
20 | * @param klass class declaration
|
21 | * @param decoratorName name of decorator to search for
|
22 | */
|
23 | export declare function getPropertyWithDecorator(klass: ClassDeclaration, decoratorName: string): PropertyDeclaration | undefined;
|
24 | /**
|
25 | * Retrieve a method from a class declaration with a particular decorator.
|
26 | *
|
27 | * @param klass class declaration
|
28 | * @param decoratorName name of the decorator to search for
|
29 | */
|
30 | export declare function getMethodWithDecorator(klass: ClassDeclaration, decoratorName: string): MethodDeclaration | undefined;
|
31 | /**
|
32 | * Retrieve a parameter from a method declaration with a particular decorator.
|
33 | *
|
34 | * @param method method declaration
|
35 | * @param decoratorName name of decorator to search for
|
36 | */
|
37 | export declare function getParamWithDecorator(method: MethodDeclaration, decoratorName: string): ParameterDeclaration | undefined;
|
38 | /**
|
39 | * Retrieve a parameter's type as a type literal or throw.
|
40 | *
|
41 | * @param parameter a parameter declaration
|
42 | */
|
43 | export declare function getParameterTypeAsTypeLiteralOrThrow(parameter: ParameterDeclaration): TypeLiteralNode;
|
44 | /**
|
45 | * Retrieve a decorator factory's configuration. The configuration is
|
46 | * the first parameter of the decorator and is expected to be an object
|
47 | * literal.
|
48 | *
|
49 | * @param decorator the source decorator
|
50 | */
|
51 | export declare function getDecoratorConfigOrThrow(decorator: Decorator): ObjectLiteralExpression;
|
52 | /**
|
53 | * Retrieves a property from an object literal expression. If provided,
|
54 | * the generic parameter will narrow down the available property names
|
55 | * allowed.
|
56 | *
|
57 | * @param objectLiteral a ts-morph object literal expression
|
58 | * @param propertyName name of the property
|
59 | */
|
60 | export declare function getObjLiteralProp<T>(objectLiteral: ObjectLiteralExpression, propertyName: Extract<keyof T, string>): PropertyAssignment | undefined;
|
61 | /**
|
62 | * Retrieves a property from an object literal expression or error. If
|
63 | * provided, the generic parameter will narrow down the available
|
64 | * property names allowed.
|
65 | *
|
66 | * @param objectLiteral a ts-morph object literal expression
|
67 | * @param propertyName name of the property
|
68 | */
|
69 | export declare function getObjLiteralPropOrThrow<T>(objectLiteral: ObjectLiteralExpression, propertyName: Extract<keyof T, string>): PropertyAssignment;
|
70 | /**
|
71 | * Retrieve a property's value as a string or error.
|
72 | *
|
73 | * @param property the source property
|
74 | */
|
75 | export declare function getPropValueAsStringOrThrow(property: PropertyAssignment): StringLiteral;
|
76 | /**
|
77 | * Retrieve a property's value as a number or error.
|
78 | *
|
79 | * @param property the source property
|
80 | */
|
81 | export declare function getPropValueAsNumberOrThrow(property: PropertyAssignment): NumericLiteral;
|
82 | /**
|
83 | * Retrieve a property's value as an array or error.
|
84 | *
|
85 | * @param property the source property
|
86 | */
|
87 | export declare function getPropValueAsArrayOrThrow(property: PropertyAssignment): ArrayLiteralExpression;
|
88 | /**
|
89 | * Retrieve a property's value as an object or error.
|
90 | *
|
91 | * @param property the source property
|
92 | */
|
93 | export declare function getPropValueAsObjectOrThrow(property: PropertyAssignment): ObjectLiteralExpression;
|
94 | /**
|
95 | * Retrieve a property's name. This will remove any quotes surrounding the name.
|
96 | *
|
97 | * @param property property signature
|
98 | */
|
99 | export declare function getPropertyName(property: PropertyDeclaration | PropertySignature): string;
|
100 | /**
|
101 | * Retrieve a JSDoc for a ts-morph node. The node is expected
|
102 | * to have no more than one JSDoc.
|
103 | *
|
104 | * @param node a JSDocable ts-morph node
|
105 | */
|
106 | export declare function getJsDoc(node: JSDocableNode): JSDoc | undefined;
|
107 | /**
|
108 | * Determine if a HTTP method is a supported HttpMethod.
|
109 | *
|
110 | * @param method the method to check
|
111 | */
|
112 | export declare function isHttpMethod(method: string): method is HttpMethod;
|
113 | /**
|
114 | * Determine if a query param array strategy is a supported QueryParamArrayStrategy.
|
115 | *
|
116 | * @param strategy the strategy to check
|
117 | */
|
118 | export declare function isQueryParamArrayStrategy(strategy: string): strategy is QueryParamArrayStrategy;
|