import { Observable } from 'rxjs/Observable' ; import { OrganizationId , ScenarioFieldConfigObjectType } from 'teambition-types' ; import { SDK , CacheStrategy } from '../../SDK' ; import { SDKFetch } from '../../SDKFetch' ; import { ScenarioFieldConfigSchema , TaskScenarioFieldConfigSchema , EventScenarioFieldConfigSchema } from '../../schemas' ; import { ApiResult } from '../../Net' ; import { OriginalResponse } from '../../Net/Pagination' ; import { withCustomFields } from './with-custom-fields' ; import { Omit } from '../../utils' ; export function getOrgScenarioFieldConfigsFetch ( this , organizationId , objectType , query ? ) ; export function getOrgScenarioFieldConfigsFetch ( this , organizationId , objectType , query ? ) ; export function getOrgScenarioFieldConfigsFetch ( this , organizationId , objectType , query ? ) ; export function getOrgScenarioFieldConfigsFetch ( this , organizationId , objectType , options = { } ) { const url = `organizations/${ organizationId }/scenariofieldconfigs` ; const { withCustomfields = true } = options ; const query = { ... options , withCustomfields , objectType } ; return this . get < OriginalResponse < ScenarioFieldConfigSchema > > ( url , query ) . map ( ( resp ) => { return resp . result ; } ) ; } declare module '../../SDKFetch' { interface SDKFetch { getOrgScenarioFieldConfigs : typeof getOrgScenarioFieldConfigsFetch ; } } SDKFetch . prototype . getOrgScenarioFieldConfigs = getOrgScenarioFieldConfigsFetch ; export function getOrgScenarioFieldConfigs ( this , organizationId , objectType , query ? ) ; export function getOrgScenarioFieldConfigs ( this , organizationId , objectType , query ? ) ; export function getOrgScenarioFieldConfigs ( this , organizationId , objectType , query ? ) ; export function getOrgScenarioFieldConfigs ( this , organizationId , objectType , query = { } ) { const token = this . lift ( { cacheValidate : CacheStrategy . Request , tableName : 'ScenarioFieldConfig' , request : this . fetch . getOrgScenarioFieldConfigs ( organizationId , objectType , { ... query , withCustomfields : true } ) , query : { where : [ { _boundToObjectId : organizationId } , { objectType } ] } , excludeFields : [ 'taskflowstatuses' ] } as ApiResult < ScenarioFieldConfigSchema , CacheStrategy . Request > ) ; return token . changes ( ) . pipe ( withCustomFields ( this ) ) ; } declare module '../../SDK' { interface SDK { getOrgScenarioFieldConfigs : typeof getOrgScenarioFieldConfigs ; } } SDK . prototype . getOrgScenarioFieldConfigs = getOrgScenarioFieldConfigs ; export type GetOrgScenarioFieldConfigsOptions = Omit < GetOrgScenarioFieldConfigsFetchOptions , 'withCustomfields' > ; export interface GetOrgScenarioFieldConfigsFetchOptions { sort ? : string ; withCustomfields ? : boolean ; pageSize ? : number ; }