import { isPrimitive } from "../safe"; import { Descriptor } from "./interfaces"; import { ServicesDeclaration, ServiceRecordBuilder, ServiceModule, RegistrationBuilder, ExtractDependency } from "./fluent/interfaces"; import { AnnotaionBuilder } from "./Annotations"; import { FactoryBuilder } from "./fluent/FactoryBuilder"; import { ConstructorBuilder } from "./fluent/ConstructorBuiler"; export function isDescriptor(x: any): x is Descriptor { return (!isPrimitive(x)) && (x.activate instanceof Function); } export function declare(): ServicesDeclaration { return { annotate() { return new AnnotaionBuilder(); }, build(): ServiceRecordBuilder { return { factory

) => T>( target: F, ...params: P ): FactoryBuilder { return new FactoryBuilder(target, params); }, type

) => T>( target: C, ...params: P ): ConstructorBuilder { return new ConstructorBuilder(target, params); }, wired(module: ServiceModule, m?: M): RegistrationBuilder { const service = m ? module[m] : (module as ServiceModule).service; if (!service) throw new Error("The specified module doen's provides a service annotation"); return service.getRegistrationBuilder(); } }; }, configure() { throw new Error(); }, dependency() { throw new Error(); } }; }