import { Observable } from 'rxjs/Observable' ; import { ProjectId , ScenarioFieldConfigObjectType } from 'teambition-types' ; import { SDK , CacheStrategy } from '../../SDK' ; import { SDKFetch } from '../../SDKFetch' ; import { ScenarioFieldConfigSchema , TaskScenarioFieldConfigSchema , EventScenarioFieldConfigSchema , TestcaseScenarioFieldConfigSchema , } from '../../schemas' ; import { ApiResult } from '../../Net' ; import { withCustomFields } from './with-custom-fields' ; export function getScenarioFieldConfigsFetch ( this , projectId , objectType , options ? ) ; export function getScenarioFieldConfigsFetch ( this , projectId , objectType , options ? ) ; export function getScenarioFieldConfigsFetch ( this , projectId , objectType , options ? ) ; export function getScenarioFieldConfigsFetch ( this , projectId , objectType , options ? ) ; export function getScenarioFieldConfigsFetch ( this , projectId , objectType , { appendCommonGroupChoices , withTaskflowstatus , withCustomfields = true } = { } ) { const url = `projects/${ projectId }/scenariofieldconfigs` ; const query = { objectType , withTaskflowstatus , withCustomfields , appendCommonGroupChoices , } ; return this . get < ScenarioFieldConfigSchema [ ] > ( url , query ) ; } declare module '../../SDKFetch' { interface SDKFetch { getScenarioFieldConfigs : typeof getScenarioFieldConfigsFetch ; } } SDKFetch . prototype . getScenarioFieldConfigs = getScenarioFieldConfigsFetch ; export function getScenarioFieldConfigs ( this , projectId , objectType , options ? ) ; export function getScenarioFieldConfigs ( this , projectId , objectType , options ? ) ; export function getScenarioFieldConfigs ( this , projectId , objectType , options ? ) ; export function getScenarioFieldConfigs ( this , projectId , objectType , options ? ) ; export function getScenarioFieldConfigs ( this , projectId , objectType , options = { } ) { const token = this . lift ( { cacheValidate : CacheStrategy . Request , tableName : 'ScenarioFieldConfig' , request : this . fetch . getScenarioFieldConfigs ( projectId , objectType , { ... options , withCustomfields : true } ) , query : { where : [ { _boundToObjectId : projectId } , { objectType } ] } , assocFields : { ... ( options . withTaskflowstatus ? { taskflowstatuses : [ '_id' , '_taskflowId' , 'name' , 'kind' , 'rejectStatusIds' , 'hasTaskflowEngineConfig' , 'pos' ] } : { } ) } } as ApiResult < ScenarioFieldConfigSchema , CacheStrategy . Request > ) ; return token . changes ( ) . pipe ( withCustomFields ( this , options ) ) ; } declare module '../../SDK' { interface SDK { getScenarioFieldConfigs : typeof getScenarioFieldConfigs ; } } SDK . prototype . getScenarioFieldConfigs = getScenarioFieldConfigs ; export interface GetScenarioFieldConfigsOptions { appendCommonGroupChoices ? : boolean ; withTaskflowstatus ? : boolean ; } export interface GetScenarioFieldConfigsFetchOptions { appendCommonGroupChoices ? : boolean ; withTaskflowstatus ? : boolean ; withCustomfields ? : boolean ; }