##// END OF EJS Templates
working on fluent configuration
working on fluent configuration

File last commit:

r132:0866c6259285 ioc ts support
r132:0866c6259285 ioc ts support
Show More
interfaces.ts
71 lines | 2.7 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / di / fluent / interfaces.ts
cin
working on fluent container configuration
r125 import { primitive } from "../../safe";
import { ActivationType } from "../interfaces";
cin
fluent configuration interfaces
r127 import { AnnotaionBuilder } from "../Annotations";
import { LazyDependencyRegistration, DependencyRegistration } from "../Configuration";
cin
working on fluent configuration
r128 import { Container } from "../Container";
cin
working on fluent container configuration
r125
cin
fluent configuration interfaces
r127 export interface DependencyOptions<T> {
optional?: boolean;
default?: T;
}
cin
working on fluent container configuration
r125
cin
fluent configuration interfaces
r127 export interface LazyDependencyOptions<T> extends DependencyOptions<T> {
lazy: true;
}
export type ExtractService<K, S> = K extends keyof S ? S[K] : K;
export type ExtractDependency<D, S> = D extends { $dependency: infer K } ?
cin
working on fluent container configuration
r125 D extends { lazy: true } ? () => ExtractService<K, S> : ExtractService<K, S> :
D extends { $type: new (...args: any[]) => infer I } ? I :
D extends { $factory: (...args: any[]) => infer R } ? R :
WalkDependencies<D, S>;
cin
fluent configuration interfaces
r127 export type WalkDependencies<D, S> = D extends primitive ? D :
cin
working on fluent container configuration
r125 { [K in keyof D]: ExtractDependency<D[K], S> };
cin
fluent configuration interfaces
r127 export type ServiceModule<T, S extends object, M extends keyof any = "service"> = {
[m in M]: AnnotaionBuilder<T, S>;
cin
sync
r126 };
cin
working on fluent configuration
r128 export interface ServiceRecordBuilder<T, S extends object> {
cin
working on fluent container configuration
r125 type<P extends any[], C extends new (...args: ExtractDependency<P, S>) => T>(
target: C, ...params: P): ConstructorBuilder<C, S>;
factory<P extends any[], F extends (...args: ExtractDependency<P, S>) => T>(
target: F, ...params: P): FactoryBuilder<F, S>;
cin
working on fluent configuration
r128 wired<M extends keyof any>(module: ServiceModule<T, S, M>, m: M): RegistrationBuilder<T, S>;
wired(module: ServiceModule<T, S>): RegistrationBuilder<T, S>;
}
cin
working on fluent configuration
r132 export interface RegistrationVisitor {
cin
working on fluent configuration
r128 visitDependency(): void;
visitObject(): void;
visitTypeRegistration(): void;
visitFactoryRegistration(): void;
cin
working on fluent container configuration
r125 }
cin
working on fluent configuration
r132 export interface ServiceRegistration {
visit(visitor: RegistrationVisitor): void;
cin
working on fluent container configuration
r125 }
export interface ConfigBuilder<S extends object, Y extends keyof S = keyof S> {
cin
working on fluent configuration
r128 register<K extends Y>(name: K, builder: (t: ServiceRecordBuilder<S[K], S>) => void | Promise<void>): ConfigBuilder<S, Exclude<Y, K>>;
register<K extends Y, V>(name: S[K] extends ExtractDependency<V, S> ? K : never, value: V): ConfigBuilder<S, Exclude<Y, K>>;
register<K extends Y>(name: K, value: S[K], raw: true): ConfigBuilder<S, Exclude<Y, K>>;
apply(container: Container<S>): Promise<void>;
cin
working on fluent container configuration
r125 }
cin
fluent configuration interfaces
r127
cin
working on fluent configuration
r132 export interface ServicesDeclaration<S extends object> {
cin
working on fluent configuration
r128 build<T>(this: void): ServiceRecordBuilder<T, S>;
cin
fluent configuration interfaces
r127 annotate<T>(this: void): AnnotaionBuilder<T, S>;
dependency<K extends keyof S>(this: void, name: K, opts: LazyDependencyOptions<S[K]>): LazyDependencyRegistration<S, K>;
dependency<K extends keyof S>(this: void, name: K, opts?: DependencyOptions<S[K]>): DependencyRegistration<S, K>;
configure(): ConfigBuilder<S>;
}