1 | import { HashMap } from "@azera/util/is";
|
2 | export { HashMap };
|
3 | export declare type Service = IDefinition | Function | any[];
|
4 | export declare type Factory<T = {}> = Constructor<IFactory<T>> | FunctionOf<T>;
|
5 | export declare type ContainerValue = any;
|
6 | export declare type Constructor<T = {}> = new (...args: any[]) => T;
|
7 | export interface IInjectable extends Function {
|
8 | $inject?: string[];
|
9 | }
|
10 | export declare type MockMethod<O extends object, K extends keyof O> = (...params: any[]) => ReturnType<O[K] extends ((...params: any[]) => any) ? O[K] : any>;
|
11 | export declare type MockMethodAsync<O extends object, K extends keyof O> = (...params: any[]) => Promise<ReturnType<O[K] extends ((...params: any[]) => any) ? O[K] : any>>;
|
12 | export declare type InjectableFunction<T = any> = {
|
13 | (...params: any[]): T;
|
14 | $inject?: string[];
|
15 | };
|
16 | export declare type FunctionOf<T> = (...params: any[]) => T;
|
17 | export declare type Injectable<T = any> = InjectableFunction<T> | Function | Array<string | Function | FunctionOf<T>>;
|
18 | export declare type InvokableFunctions<T> = Injectable<T> | Constructor<T> | Factory<T>;
|
19 | export declare type Invokable<T> = InvokableFunctions<T> | string | T;
|
20 | export declare type IServices = HashMap<IDefinition | Function | any[]>;
|
21 | export interface IAutoTagger {
|
22 | (service: IDefinition): string[];
|
23 | }
|
24 | export declare type ServiceDefinitionCollection = HashMap<Service>;
|
25 | export interface IContainer {
|
26 | set(values: {
|
27 | [name: string]: IDefinition | ContainerValue;
|
28 | }[]): this;
|
29 | set(name: string, value: IDefinition | ContainerValue): this;
|
30 | get<T>(name: string): T | undefined;
|
31 | invoke<T>(value: Invokable<T>): T | undefined;
|
32 | }
|
33 | export interface IDefinition<T = Function> {
|
34 | name: string;
|
35 | service?: T;
|
36 | parameters: (string | Function)[];
|
37 | properties: HashMap<string | Function | IPropertyInjection>;
|
38 | methods: {
|
39 | [name: string]: (string | Function)[];
|
40 | };
|
41 | calls: {
|
42 | [name: string]: (string | Function)[];
|
43 | };
|
44 | private: boolean;
|
45 | isFactory: boolean;
|
46 | factory?: Function | IFactory;
|
47 | tags: string[];
|
48 | invoke: boolean;
|
49 | imports: (string | Function)[];
|
50 | autoTags: ({
|
51 | class: Function;
|
52 | tags: string[];
|
53 | } | IAutoTagger)[];
|
54 | }
|
55 | export interface IInternalDefinition extends IDefinition {
|
56 | compiled?: boolean;
|
57 | inherited?: boolean;
|
58 | $target?: Function;
|
59 | }
|
60 | export interface IPropertyInjection {
|
61 | lateBinding?: boolean;
|
62 | name?: string | Function;
|
63 | }
|
64 | export interface IFactory<T = any> {
|
65 | create(...params: any[]): T;
|
66 | }
|
67 | export interface IMethod {
|
68 | context: any;
|
69 | method: string;
|
70 | }
|