1 | import { Class } from '../common-types';
|
2 | import { DataSource } from '../datasource';
|
3 | import { Entity, Model } from '../model';
|
4 | import { Repository } from '../repositories';
|
5 | import { juggler } from '../repositories/legacy-juggler-bridge';
|
6 |
|
7 |
|
8 |
|
9 | export type RepositoryDecorator = (target: Object, key?: string, descriptorOrIndex?: TypedPropertyDescriptor<any> | number) => void;
|
10 |
|
11 |
|
12 |
|
13 | export declare class RepositoryMetadata {
|
14 | |
15 |
|
16 |
|
17 | name?: string;
|
18 | |
19 |
|
20 |
|
21 | modelName?: string;
|
22 | |
23 |
|
24 |
|
25 | modelClass?: typeof Entity;
|
26 | |
27 |
|
28 |
|
29 | dataSourceName?: string;
|
30 | |
31 |
|
32 |
|
33 | dataSource?: juggler.DataSource | DataSource;
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | constructor(modelOrRepo: string | typeof Entity, dataSource?: string | juggler.DataSource | DataSource);
|
51 | }
|
52 | /**
|
53 | * Decorator for repository injections on properties or method arguments
|
54 | *
|
55 | * @example
|
56 | * ```ts
|
57 | * class CustomerController {
|
58 | * @repository(CustomerRepository) public custRepo: CustomerRepository;
|
59 | *
|
60 | * constructor(
|
61 | * @repository(ProductRepository) public prodRepo: ProductRepository,
|
62 | * ) {}
|
63 | *
|
64 | * }
|
65 | * ```
|
66 | *
|
67 | * @param repositoryName - Name of the repo
|
68 | */
|
69 | export declare function repository(repositoryName: string | Class<Repository<Model>>): RepositoryDecorator;
|
70 | /**
|
71 | * Decorator for DefaultCrudRepository generation and injection on properties
|
72 | * or method arguments based on the given model and dataSource (or their names)
|
73 | *
|
74 | * @example
|
75 | * ```ts
|
76 | * class CustomerController {
|
77 | * @repository('Customer', 'mySqlDataSource')
|
78 | * public custRepo: DefaultCrudRepository<
|
79 | * Customer,
|
80 | * typeof Customer.prototype.id
|
81 | * >;
|
82 | *
|
83 | * constructor(
|
84 | * @repository(Product, mySqlDataSource)
|
85 | * public prodRepo: DefaultCrudRepository<
|
86 | * Product,
|
87 | * typeof Product.prototype.id
|
88 | * >,
|
89 | * ) {}
|
90 | *
|
91 | * }
|
92 | * ```
|
93 | *
|
94 | * @param model - Name/class of the model
|
95 | * @param dataSource - Name/instance of the dataSource
|
96 | */
|
97 | export declare function repository(model: string | typeof Entity, dataSource: string | juggler.DataSource): RepositoryDecorator;
|
98 | export declare namespace repository {
|
99 | /**
|
100 | * Decorator used to inject a Getter for a repository
|
101 | * Mainly intended for usage with repository injections on relation repository
|
102 | * factory
|
103 | * @param nameOrClass - The repository class (ProductRepository) or a string name ('ProductRepository').
|
104 | */
|
105 | function getter(nameOrClass: string | Class<Repository<Model>>): (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
|
106 | }
|
107 |
|
\ | No newline at end of file |