import { ODataClient } from "./ODataClient" ; import { Project , Team , WorkItemTypeField , AnalyticsDate } from "./AnalyticsTypes" ; import { ICacheableQuery } from "./ICacheableQuery" ; /**
 * Implements a query of available Projects
 */ export class ProjectsQuery implements ICacheableQuery < Project [ ] > { public getKey ( ) { return "Projects()" ; } public runQuery ( ) { return ODataClient . getInstance ( ) . then ( ( client ) => { let fullQueryUrl = client . generateAccountLink ( "Projects" ) ; return client . runGetQuery ( fullQueryUrl ) . then ( ( results ) => { return results [ ODataClient . valueKey ] ; } ) ; } ) ; } } /**
 * Implements a query of available Teams, scoped to Team
 */ export class TeamsQuery implements ICacheableQuery < Team [ ] > { private projectId : string ; constructor ( projectId ) { this . projectId = projectId ; } public getKey ( ) { return `Teams(${ this . projectId })` ; } public runQuery ( ) { return ODataClient . getInstance ( ) . then ( ( client ) => { let fullQueryUrl = client . generateProjectLink ( this . projectId , "Teams" ) ; return client . runGetQuery ( fullQueryUrl ) . then ( ( results ) => { return results [ ODataClient . valueKey ] ; } ) ; } ) ; } } /**
 * Implements a query of available Dates
 */ export class WitFieldsQuery implements ICacheableQuery < WorkItemTypeField [ ] > { private projectId : string ; constructor ( projectId ) { this . projectId = projectId ; } public getKey ( ) { return `WorkItemTypeFields(${ this . projectId })` ; } public runQuery ( ) { return ODataClient . getInstance ( ) . then ( ( client ) => { let fullQueryUrl = client . generateAccountLink ( "WorkItemTypeFields" ) ; return client . runGetQuery ( fullQueryUrl ) . then ( ( results ) => { return results [ ODataClient . valueKey ] ; } ) ; } ) ; } } /**
 * Implements a query of available Dates
 */ export class DatesQuery implements ICacheableQuery < AnalyticsDate [ ] > { public getKey ( ) { return `Dates()` ; } public runQuery ( ) { return ODataClient . getInstance ( ) . then ( ( client ) => { let fullQueryUrl = client . generateAccountLink ( "Dates" ) ; return client . runGetQuery ( fullQueryUrl ) . then ( ( results ) => { return results [ ODataClient . valueKey ] ; } ) ; } ) ; } }