import * as callsite from 'callsite' ; import * as minimist from 'minimist' ; import * as path from 'path' ; import { ComponentRequestTable , ConceptServer , InitDbCallbackFn , InitResolversFn } from './conceptServer' ; import { Config , getConfig } from './config' ; /**
 * The type of the function to be called to get the dynamic type definitions
 * for the schema from the config
 */ export type GetDynamicTypeDefsFn < C = Config > = ( config : C ) => string [ ] ; /**
 * A builder for  ConceptServer export class ConceptServerBuilder < C extends Config = Config > { private readonly _name : string ; private _schemaPath : string = path . join ( path . dirname ( callsite ( ) [ 1 ] . getFileName ( ) ) , 'schema.graphql' ) ; private _componentRequestTable : ComponentRequestTable = { } ; private _config : C ; private _initDbCallback ? : InitDbCallbackFn < C > ; private _initResolvers ? : InitResolversFn < C > ; private _getDynamicTypeDefsFn : GetDynamicTypeDefsFn = ( _ ) => [ ] ; param defaultName constructor ( defaultName ) { const argv = minimist ( process . argv ) ; this . _name = argv . as ? argv . as : defaultName ; this . _config = getConfig < C > ( this . _name , argv ) ; } param componentRequestTable return componentRequestTable ( componentRequestTable ) { this . _componentRequestTable = componentRequestTable ; return this ; } param config return config ( config ) { this . _config = Object . assign ( { } , this . _config , config ) ; return this ; } param callback return initDb ( callback ) { this . _initDbCallback = callback ; return this ; } param initResolvers return resolvers ( initResolvers ) { this . _initResolvers = initResolvers ; return this ; } param schemaPath return schemaPath ( schemaPath ) { this . _schemaPath = schemaPath ; return this ; } param getDynamicTypeDefsFn return dynamicTypeDefs ( getDynamicTypeDefsFn ) { this . _getDynamicTypeDefsFn = getDynamicTypeDefsFn ; return this ; } return build ( ) { return new ConceptServer < C > ( this . _name , this . _componentRequestTable , this . _config , this . _schemaPath , this . _initDbCallback , this . _initResolvers , this . _getDynamicTypeDefsFn ( this . _config ) ) ; } }