-
Notifications
You must be signed in to change notification settings - Fork 13
/
di.ns.ts
80 lines (71 loc) · 2.15 KB
/
di.ns.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2020-2020 The Mandarine.TS Framework authors. All rights reserved. MIT license.
import type { Cookies, Request } from "../../deps.ts";
import type { Mandarine } from "../Mandarine.ns.ts";
import { DependencyInjectionFactory } from "./diFactory.ts";
export namespace DI {
/**
* Interprets the arguments to return after injection
*
*/
export type ArgumentValue = any;
/**
* Infer the arguments of constructor for dependency injection.
*
*/
export type Constructor<T = any> = new (...args: any[]) => T;
/**
* Structure of data for requests in order to resolve dependencies.
*
*/
export interface ArgumentsResolverExtraData {
fullContext: any;
request: Request;
response: any;
params: any;
cookies: Cookies;
routingAction: Mandarine.MandarineMVC.Routing.RoutingAction;
}
/**
* Structure of injections in methods' arguments.
*
*/
export interface InjectionMetadataContext {
injectionType: InjectionTypes;
parameterName: string;
parameterIndex: number;
parameterMethodName: string;
parameterObjectToInject?: any;
parameterConfiguration?: any;
parameterOriginalMetadataType?: any;
propertyName: string;
className: string;
}
/**
* List of all the possible injection types.
* **NOTE** INJECTABLE_OBJECT refers to a injection that is not part of Mandarine Components but it has been defined as a component by the user.
*
*/
export enum InjectionTypes {
INJECTABLE_OBJECT,
QUERY_PARAM,
ROUTE_PARAM,
REQUEST_PARAM,
REQUEST_CONTEXT_PARAM,
SESSION_PARAM,
REQUEST_BODY_PARAM,
RESPONSE_PARAM,
COOKIE_PARAM,
TEMPLATE_MODEL_PARAM,
PARAMETERS_PARAM,
AUTH_PRINCIPAL_PARAM,
CUSTOM_DECORATOR_PARAM
}
/**
* Includes the instance of DependencyInjectionFactory
*/
export class FactoryClass extends DependencyInjectionFactory {}
/**
* Initializes the DI factory.
*/
export const Factory = new FactoryClass();
}