ClientApi base classes + webapi factory

ClientApi base classes + webapi factory
This commit is contained in:
Teddy Ward 2015-07-23 17:18:52 -04:00
Родитель ad6df2935f
Коммит 2cf1cc35e8
16 изменённых файлов: 591 добавлений и 642 удалений

Просмотреть файл

@ -20,17 +20,12 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import BuildInterfaces = require("./interfaces/BuildInterfaces");
import VSSInterfaces = require("./interfaces/common/VSSInterfaces");
export interface IBuildApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface IBuildApi extends basem.ClientApiBase {
createArtifact(artifact: BuildInterfaces.BuildArtifact, buildId: number, project: string, onResult: (err: any, statusCode: number, artifact: BuildInterfaces.BuildArtifact) => void): void;
getArtifact(buildId: number, artifactName: string, project: string, onResult: (err: any, statusCode: number, artifact: BuildInterfaces.BuildArtifact) => void): void;
getArtifactContentZip(buildId: number, artifactName: string, project: string, onResult: (err: any, statusCode: number, res: NodeJS.ReadableStream) => void): void;
@ -75,8 +70,7 @@ export interface IBuildApi {
getBuildWorkItemsRefsFromCommits(commitIds: string[], project: string, buildId: number, top: number, onResult: (err: any, statusCode: number, workitems: VSSInterfaces.ResourceRef[]) => void): void;
}
export interface IQBuildApi {
connect(): Q.Promise<void>;
export interface IQBuildApi extends basem.QClientApiBase {
createArtifact(artifact: BuildInterfaces.BuildArtifact, buildId: number, project?: string): Q.Promise<BuildInterfaces.BuildArtifact>;
getArtifact(buildId: number, artifactName: string, project?: string): Q.Promise<BuildInterfaces.BuildArtifact>;
@ -115,27 +109,10 @@ export interface IQBuildApi {
getBuildWorkItemsRefsFromCommits(commitIds: string[], project: string, buildId: number, top?: number): Q.Promise<VSSInterfaces.ResourceRef[]>;
}
export class BuildApi implements IBuildApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class BuildApi extends basem.ClientApiBase implements IBuildApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-Build-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-Build-api');
}
/**
@ -1401,27 +1378,12 @@ export class BuildApi implements IBuildApi {
}
export class QBuildApi implements IQBuildApi {
BuildApi: IBuildApi;
export class QBuildApi extends basem.QClientApiBase implements IQBuildApi {
api: BuildApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.BuildApi = new BuildApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.BuildApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, BuildApi);
}
@ -1440,7 +1402,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildArtifact>();
this.BuildApi.createArtifact(artifact, buildId, project, (err: any, statusCode: number, artifact: BuildInterfaces.BuildArtifact) => {
this.api.createArtifact(artifact, buildId, project, (err: any, statusCode: number, artifact: BuildInterfaces.BuildArtifact) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1468,7 +1430,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildArtifact>();
this.BuildApi.getArtifact(buildId, artifactName, project, (err: any, statusCode: number, artifact: BuildInterfaces.BuildArtifact) => {
this.api.getArtifact(buildId, artifactName, project, (err: any, statusCode: number, artifact: BuildInterfaces.BuildArtifact) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1494,7 +1456,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildArtifact[]>();
this.BuildApi.getArtifacts(buildId, project, (err: any, statusCode: number, artifacts: BuildInterfaces.BuildArtifact[]) => {
this.api.getArtifacts(buildId, project, (err: any, statusCode: number, artifacts: BuildInterfaces.BuildArtifact[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1520,7 +1482,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<string>();
this.BuildApi.getBadge(project, definitionId, branchName, (err: any, statusCode: number, badge: string) => {
this.api.getBadge(project, definitionId, branchName, (err: any, statusCode: number, badge: string) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1548,7 +1510,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.Build>();
this.BuildApi.getBuild(buildId, project, propertyFilters, (err: any, statusCode: number, build: BuildInterfaces.Build) => {
this.api.getBuild(buildId, project, propertyFilters, (err: any, statusCode: number, build: BuildInterfaces.Build) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1606,7 +1568,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.Build[]>();
this.BuildApi.getBuilds(project, definitions, queues, buildNumber, minFinishTime, maxFinishTime, requestedFor, reasonFilter, statusFilter, resultFilter, tagFilters, properties, type, top, continuationToken, maxBuildsPerDefinition, deletedFilter, queryOrder, (err: any, statusCode: number, builds: BuildInterfaces.Build[]) => {
this.api.getBuilds(project, definitions, queues, buildNumber, minFinishTime, maxFinishTime, requestedFor, reasonFilter, statusFilter, resultFilter, tagFilters, properties, type, top, continuationToken, maxBuildsPerDefinition, deletedFilter, queryOrder, (err: any, statusCode: number, builds: BuildInterfaces.Build[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1634,7 +1596,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.Build>();
this.BuildApi.queueBuild(build, project, ignoreWarnings, (err: any, statusCode: number, build: BuildInterfaces.Build) => {
this.api.queueBuild(build, project, ignoreWarnings, (err: any, statusCode: number, build: BuildInterfaces.Build) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1662,7 +1624,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.Build>();
this.BuildApi.updateBuild(build, buildId, project, (err: any, statusCode: number, build: BuildInterfaces.Build) => {
this.api.updateBuild(build, buildId, project, (err: any, statusCode: number, build: BuildInterfaces.Build) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1690,7 +1652,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.Change[]>();
this.BuildApi.getBuildCommits(project, buildId, top, (err: any, statusCode: number, changes: BuildInterfaces.Change[]) => {
this.api.getBuildCommits(project, buildId, top, (err: any, statusCode: number, changes: BuildInterfaces.Change[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1714,7 +1676,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildController>();
this.BuildApi.getBuildController(controllerId, (err: any, statusCode: number, Controller: BuildInterfaces.BuildController) => {
this.api.getBuildController(controllerId, (err: any, statusCode: number, Controller: BuildInterfaces.BuildController) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1738,7 +1700,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildController[]>();
this.BuildApi.getBuildControllers(name, (err: any, statusCode: number, Controllers: BuildInterfaces.BuildController[]) => {
this.api.getBuildControllers(name, (err: any, statusCode: number, Controllers: BuildInterfaces.BuildController[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1768,7 +1730,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildDefinition>();
this.BuildApi.createDefinition(definition, project, definitionToCloneId, definitionToCloneRevision, (err: any, statusCode: number, definition: BuildInterfaces.BuildDefinition) => {
this.api.createDefinition(definition, project, definitionToCloneId, definitionToCloneRevision, (err: any, statusCode: number, definition: BuildInterfaces.BuildDefinition) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1798,7 +1760,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.DefinitionReference>();
this.BuildApi.getDefinition(definitionId, project, revision, propertyFilters, (err: any, statusCode: number, definition: BuildInterfaces.DefinitionReference) => {
this.api.getDefinition(definitionId, project, revision, propertyFilters, (err: any, statusCode: number, definition: BuildInterfaces.DefinitionReference) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1826,7 +1788,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.DefinitionReference[]>();
this.BuildApi.getDefinitions(project, name, type, (err: any, statusCode: number, definitions: BuildInterfaces.DefinitionReference[]) => {
this.api.getDefinitions(project, name, type, (err: any, statusCode: number, definitions: BuildInterfaces.DefinitionReference[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1858,7 +1820,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildDefinition>();
this.BuildApi.updateDefinition(definition, definitionId, project, secretsSourceDefinitionId, secretsSourceDefinitionRevision, (err: any, statusCode: number, definition: BuildInterfaces.BuildDefinition) => {
this.api.updateDefinition(definition, definitionId, project, secretsSourceDefinitionId, secretsSourceDefinitionRevision, (err: any, statusCode: number, definition: BuildInterfaces.BuildDefinition) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1884,7 +1846,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.Deployment[]>();
this.BuildApi.getBuildDeployments(project, buildId, (err: any, statusCode: number, deployments: BuildInterfaces.Deployment[]) => {
this.api.getBuildDeployments(project, buildId, (err: any, statusCode: number, deployments: BuildInterfaces.Deployment[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1910,7 +1872,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildLog[]>();
this.BuildApi.getBuildLogs(project, buildId, (err: any, statusCode: number, logs: BuildInterfaces.BuildLog[]) => {
this.api.getBuildLogs(project, buildId, (err: any, statusCode: number, logs: BuildInterfaces.BuildLog[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1930,7 +1892,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildOptionDefinition[]>();
this.BuildApi.getBuildOptionDefinitions((err: any, statusCode: number, options: BuildInterfaces.BuildOptionDefinition[]) => {
this.api.getBuildOptionDefinitions((err: any, statusCode: number, options: BuildInterfaces.BuildOptionDefinition[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1954,7 +1916,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.AgentPoolQueue>();
this.BuildApi.createQueue(queue, (err: any, statusCode: number, queue: BuildInterfaces.AgentPoolQueue) => {
this.api.createQueue(queue, (err: any, statusCode: number, queue: BuildInterfaces.AgentPoolQueue) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1978,7 +1940,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.AgentPoolQueue>();
this.BuildApi.getAgentPoolQueue(controllerId, (err: any, statusCode: number, queue: BuildInterfaces.AgentPoolQueue) => {
this.api.getAgentPoolQueue(controllerId, (err: any, statusCode: number, queue: BuildInterfaces.AgentPoolQueue) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2002,7 +1964,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.AgentPoolQueue[]>();
this.BuildApi.getQueues(name, (err: any, statusCode: number, queues: BuildInterfaces.AgentPoolQueue[]) => {
this.api.getQueues(name, (err: any, statusCode: number, queues: BuildInterfaces.AgentPoolQueue[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2028,7 +1990,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildDefinitionRevision[]>();
this.BuildApi.getDefinitionRevisions(project, definitionId, (err: any, statusCode: number, revisions: BuildInterfaces.BuildDefinitionRevision[]) => {
this.api.getDefinitionRevisions(project, definitionId, (err: any, statusCode: number, revisions: BuildInterfaces.BuildDefinitionRevision[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2048,7 +2010,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildSettings>();
this.BuildApi.getBuildSettings((err: any, statusCode: number, setting: BuildInterfaces.BuildSettings) => {
this.api.getBuildSettings((err: any, statusCode: number, setting: BuildInterfaces.BuildSettings) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2072,7 +2034,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildSettings>();
this.BuildApi.updateBuildSettings(settings, (err: any, statusCode: number, setting: BuildInterfaces.BuildSettings) => {
this.api.updateBuildSettings(settings, (err: any, statusCode: number, setting: BuildInterfaces.BuildSettings) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2100,7 +2062,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<string[]>();
this.BuildApi.addBuildTag(project, buildId, tag, (err: any, statusCode: number, tags: string[]) => {
this.api.addBuildTag(project, buildId, tag, (err: any, statusCode: number, tags: string[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2128,7 +2090,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<string[]>();
this.BuildApi.addBuildTags(tags, project, buildId, (err: any, statusCode: number, tags: string[]) => {
this.api.addBuildTags(tags, project, buildId, (err: any, statusCode: number, tags: string[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2156,7 +2118,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<string[]>();
this.BuildApi.deleteBuildTag(project, buildId, tag, (err: any, statusCode: number, tags: string[]) => {
this.api.deleteBuildTag(project, buildId, tag, (err: any, statusCode: number, tags: string[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2182,7 +2144,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<string[]>();
this.BuildApi.getBuildTags(project, buildId, (err: any, statusCode: number, tags: string[]) => {
this.api.getBuildTags(project, buildId, (err: any, statusCode: number, tags: string[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2204,7 +2166,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<string[]>();
this.BuildApi.getTags(project, (err: any, statusCode: number, tags: string[]) => {
this.api.getTags(project, (err: any, statusCode: number, tags: string[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2230,7 +2192,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildDefinitionTemplate>();
this.BuildApi.getTemplate(project, templateId, (err: any, statusCode: number, template: BuildInterfaces.BuildDefinitionTemplate) => {
this.api.getTemplate(project, templateId, (err: any, statusCode: number, template: BuildInterfaces.BuildDefinitionTemplate) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2252,7 +2214,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildDefinitionTemplate[]>();
this.BuildApi.getTemplates(project, (err: any, statusCode: number, templates: BuildInterfaces.BuildDefinitionTemplate[]) => {
this.api.getTemplates(project, (err: any, statusCode: number, templates: BuildInterfaces.BuildDefinitionTemplate[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2280,7 +2242,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.BuildDefinitionTemplate>();
this.BuildApi.saveTemplate(template, project, templateId, (err: any, statusCode: number, template: BuildInterfaces.BuildDefinitionTemplate) => {
this.api.saveTemplate(template, project, templateId, (err: any, statusCode: number, template: BuildInterfaces.BuildDefinitionTemplate) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2310,7 +2272,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<BuildInterfaces.Timeline>();
this.BuildApi.getBuildTimeline(project, buildId, timelineId, changeId, (err: any, statusCode: number, Timeline: BuildInterfaces.Timeline) => {
this.api.getBuildTimeline(project, buildId, timelineId, changeId, (err: any, statusCode: number, Timeline: BuildInterfaces.Timeline) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2338,7 +2300,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<VSSInterfaces.ResourceRef[]>();
this.BuildApi.getBuildWorkItemsRefs(project, buildId, top, (err: any, statusCode: number, workitems: VSSInterfaces.ResourceRef[]) => {
this.api.getBuildWorkItemsRefs(project, buildId, top, (err: any, statusCode: number, workitems: VSSInterfaces.ResourceRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2368,7 +2330,7 @@ export class QBuildApi implements IQBuildApi {
var deferred = Q.defer<VSSInterfaces.ResourceRef[]>();
this.BuildApi.getBuildWorkItemsRefsFromCommits(commitIds, project, buildId, top, (err: any, statusCode: number, workitems: VSSInterfaces.ResourceRef[]) => {
this.api.getBuildWorkItemsRefsFromCommits(commitIds, project, buildId, top, (err: any, statusCode: number, workitems: VSSInterfaces.ResourceRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

57
src/api/ClientApiBases.ts Normal file
Просмотреть файл

@ -0,0 +1,57 @@
import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
export class ClientApiBase {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], userAgent?: string);
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], userAgent: string) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient(userAgent, handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
this.userAgent = userAgent;
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
}
}
export class QClientApiBase {
api: ClientApiBase;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], api: typeof ClientApiBase) {
this.api = new api(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.api.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
}
}

Просмотреть файл

@ -20,19 +20,14 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import CoreInterfaces = require("./interfaces/CoreInterfaces");
import OperationsInterfaces = require("./interfaces/common/OperationsInterfaces");
import TfsInterfaces = require("./interfaces/common/TfsInterfaces");
import VSSInterfaces = require("./interfaces/common/VSSInterfaces");
export interface ICoreApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface ICoreApi extends basem.ClientApiBase {
createConnectedService(connectedServiceCreationData: CoreInterfaces.WebApiConnectedServiceDetails, projectId: string, onResult: (err: any, statusCode: number, connectedService: CoreInterfaces.WebApiConnectedService) => void): void;
getConnectedServiceDetails(projectId: string, name: string, onResult: (err: any, statusCode: number, connectedService: CoreInterfaces.WebApiConnectedServiceDetails) => void): void;
getConnectedServices(projectId: string, kind: CoreInterfaces.ConnectedServiceKind, onResult: (err: any, statusCode: number, connectedServices: CoreInterfaces.WebApiConnectedService[]) => void): void;
@ -53,8 +48,7 @@ export interface ICoreApi {
getTeams(projectId: string, teamId: string, top: number, skip: number, onResult: (err: any, statusCode: number, team: CoreInterfaces.WebApiTeam) => void): void;
}
export interface IQCoreApi {
connect(): Q.Promise<void>;
export interface IQCoreApi extends basem.QClientApiBase {
createConnectedService(connectedServiceCreationData: CoreInterfaces.WebApiConnectedServiceDetails, projectId: string): Q.Promise<CoreInterfaces.WebApiConnectedService>;
getConnectedServiceDetails(projectId: string, name: string): Q.Promise<CoreInterfaces.WebApiConnectedServiceDetails>;
@ -73,27 +67,10 @@ export interface IQCoreApi {
getTeams(projectId: string, teamId?: string, top?: number, skip?: number): Q.Promise<CoreInterfaces.WebApiTeam>;
}
export class CoreApi implements ICoreApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class CoreApi extends basem.ClientApiBase implements ICoreApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-Core-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-Core-api');
}
/**
@ -580,27 +557,12 @@ export class CoreApi implements ICoreApi {
}
export class QCoreApi implements IQCoreApi {
CoreApi: ICoreApi;
export class QCoreApi extends basem.QClientApiBase implements IQCoreApi {
api: CoreApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.CoreApi = new CoreApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.CoreApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, CoreApi);
}
@ -615,7 +577,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.WebApiConnectedService>();
this.CoreApi.createConnectedService(connectedServiceCreationData, projectId, (err: any, statusCode: number, connectedService: CoreInterfaces.WebApiConnectedService) => {
this.api.createConnectedService(connectedServiceCreationData, projectId, (err: any, statusCode: number, connectedService: CoreInterfaces.WebApiConnectedService) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -639,7 +601,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.WebApiConnectedServiceDetails>();
this.CoreApi.getConnectedServiceDetails(projectId, name, (err: any, statusCode: number, connectedService: CoreInterfaces.WebApiConnectedServiceDetails) => {
this.api.getConnectedServiceDetails(projectId, name, (err: any, statusCode: number, connectedService: CoreInterfaces.WebApiConnectedServiceDetails) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -663,7 +625,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.WebApiConnectedService[]>();
this.CoreApi.getConnectedServices(projectId, kind, (err: any, statusCode: number, connectedServices: CoreInterfaces.WebApiConnectedService[]) => {
this.api.getConnectedServices(projectId, kind, (err: any, statusCode: number, connectedServices: CoreInterfaces.WebApiConnectedService[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -685,7 +647,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<VSSInterfaces.IdentityRef[]>();
this.CoreApi.getIdentityMru(mruName, (err: any, statusCode: number, identityMru: VSSInterfaces.IdentityRef[]) => {
this.api.getIdentityMru(mruName, (err: any, statusCode: number, identityMru: VSSInterfaces.IdentityRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -713,7 +675,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<VSSInterfaces.IdentityRef[]>();
this.CoreApi.getTeamMembers(projectId, teamId, top, skip, (err: any, statusCode: number, members: VSSInterfaces.IdentityRef[]) => {
this.api.getTeamMembers(projectId, teamId, top, skip, (err: any, statusCode: number, members: VSSInterfaces.IdentityRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -737,7 +699,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.TeamProjectCollection>();
this.CoreApi.getProjectCollection(collectionId, (err: any, statusCode: number, projectCollection: CoreInterfaces.TeamProjectCollection) => {
this.api.getProjectCollection(collectionId, (err: any, statusCode: number, projectCollection: CoreInterfaces.TeamProjectCollection) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -763,7 +725,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.TeamProjectCollectionReference[]>();
this.CoreApi.getProjectCollections(top, skip, (err: any, statusCode: number, projectCollections: CoreInterfaces.TeamProjectCollectionReference[]) => {
this.api.getProjectCollections(top, skip, (err: any, statusCode: number, projectCollections: CoreInterfaces.TeamProjectCollectionReference[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -785,7 +747,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.TeamProjectReference[]>();
this.CoreApi.getProjectHistory(minRevision, (err: any, statusCode: number, projectHistory: CoreInterfaces.TeamProjectReference[]) => {
this.api.getProjectHistory(minRevision, (err: any, statusCode: number, projectHistory: CoreInterfaces.TeamProjectReference[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -813,7 +775,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.TeamProject>();
this.CoreApi.getProject(projectId, includeCapabilities, includeHistory, (err: any, statusCode: number, project: CoreInterfaces.TeamProject) => {
this.api.getProject(projectId, includeCapabilities, includeHistory, (err: any, statusCode: number, project: CoreInterfaces.TeamProject) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -841,7 +803,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.TeamProjectReference[]>();
this.CoreApi.getProjects(stateFilter, top, skip, (err: any, statusCode: number, projects: CoreInterfaces.TeamProjectReference[]) => {
this.api.getProjects(stateFilter, top, skip, (err: any, statusCode: number, projects: CoreInterfaces.TeamProjectReference[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -865,7 +827,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<OperationsInterfaces.OperationReference>();
this.CoreApi.queueCreateProject(projectToCreate, (err: any, statusCode: number, project: OperationsInterfaces.OperationReference) => {
this.api.queueCreateProject(projectToCreate, (err: any, statusCode: number, project: OperationsInterfaces.OperationReference) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -889,7 +851,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<OperationsInterfaces.OperationReference>();
this.CoreApi.queueDeleteProject(projectId, (err: any, statusCode: number, project: OperationsInterfaces.OperationReference) => {
this.api.queueDeleteProject(projectId, (err: any, statusCode: number, project: OperationsInterfaces.OperationReference) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -915,7 +877,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<OperationsInterfaces.OperationReference>();
this.CoreApi.updateProject(projectUpdate, projectId, (err: any, statusCode: number, project: OperationsInterfaces.OperationReference) => {
this.api.updateProject(projectUpdate, projectId, (err: any, statusCode: number, project: OperationsInterfaces.OperationReference) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -937,7 +899,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.Proxy[]>();
this.CoreApi.getProxies(proxyUrl, (err: any, statusCode: number, proxies: CoreInterfaces.Proxy[]) => {
this.api.getProxies(proxyUrl, (err: any, statusCode: number, proxies: CoreInterfaces.Proxy[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -965,7 +927,7 @@ export class QCoreApi implements IQCoreApi {
var deferred = Q.defer<CoreInterfaces.WebApiTeam>();
this.CoreApi.getTeams(projectId, teamId, top, skip, (err: any, statusCode: number, team: CoreInterfaces.WebApiTeam) => {
this.api.getTeams(projectId, teamId, top, skip, (err: any, statusCode: number, team: CoreInterfaces.WebApiTeam) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

Просмотреть файл

@ -20,17 +20,12 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import FileContainerInterfaces = require("./interfaces/FileContainerInterfaces");
import VSSInterfaces = require("./interfaces/common/VSSInterfaces");
export interface IFileContainerApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface IFileContainerApi extends basem.ClientApiBase {
createItem(containerId: number, itemPath: string, scope: string, onResult: (err: any, statusCode: number, Container: FileContainerInterfaces.FileContainerItem) => void): void;
createItems(items: VSSInterfaces.VssJsonCollectionWrapperV<FileContainerInterfaces.FileContainerItem[]>, containerId: number, scope: string, onResult: (err: any, statusCode: number, Container: FileContainerInterfaces.FileContainerItem[]) => void): void;
deleteItem(containerId: number, itemPath: string, scope: string, onResult: (err: any, statusCode: number) => void): void;
@ -38,8 +33,7 @@ export interface IFileContainerApi {
getItems(containerId: number, scope: string, itemPath: string, metadata: boolean, format: string, downloadFileName: string, includeDownloadTickets: boolean, onResult: (err: any, statusCode: number, Containers: FileContainerInterfaces.FileContainerItem[]) => void): void;
}
export interface IQFileContainerApi {
connect(): Q.Promise<void>;
export interface IQFileContainerApi extends basem.QClientApiBase {
createItem(containerId: number, itemPath: string, scope?: string): Q.Promise<FileContainerInterfaces.FileContainerItem>;
createItems(items: VSSInterfaces.VssJsonCollectionWrapperV<FileContainerInterfaces.FileContainerItem[]>, containerId: number, scope?: string): Q.Promise<FileContainerInterfaces.FileContainerItem[]>;
@ -47,27 +41,10 @@ export interface IQFileContainerApi {
getItems(containerId: number, scope?: string, itemPath?: string, metadata?: boolean, format?: string, downloadFileName?: string, includeDownloadTickets?: boolean): Q.Promise<FileContainerInterfaces.FileContainerItem[]>;
}
export class FileContainerApi implements IFileContainerApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class FileContainerApi extends basem.ClientApiBase implements IFileContainerApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-FileContainer-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-FileContainer-api');
}
/**
@ -245,27 +222,12 @@ export class FileContainerApi implements IFileContainerApi {
}
export class QFileContainerApi implements IQFileContainerApi {
FileContainerApi: IFileContainerApi;
export class QFileContainerApi extends basem.QClientApiBase implements IQFileContainerApi {
api: FileContainerApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.FileContainerApi = new FileContainerApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.FileContainerApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, FileContainerApi);
}
@ -284,7 +246,7 @@ export class QFileContainerApi implements IQFileContainerApi {
var deferred = Q.defer<FileContainerInterfaces.FileContainerItem>();
this.FileContainerApi.createItem(containerId, itemPath, scope, (err: any, statusCode: number, Container: FileContainerInterfaces.FileContainerItem) => {
this.api.createItem(containerId, itemPath, scope, (err: any, statusCode: number, Container: FileContainerInterfaces.FileContainerItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -312,7 +274,7 @@ export class QFileContainerApi implements IQFileContainerApi {
var deferred = Q.defer<FileContainerInterfaces.FileContainerItem[]>();
this.FileContainerApi.createItems(items, containerId, scope, (err: any, statusCode: number, Container: FileContainerInterfaces.FileContainerItem[]) => {
this.api.createItems(items, containerId, scope, (err: any, statusCode: number, Container: FileContainerInterfaces.FileContainerItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -338,7 +300,7 @@ export class QFileContainerApi implements IQFileContainerApi {
var deferred = Q.defer<FileContainerInterfaces.FileContainer[]>();
this.FileContainerApi.getContainers(scope, artifactUris, (err: any, statusCode: number, Containers: FileContainerInterfaces.FileContainer[]) => {
this.api.getContainers(scope, artifactUris, (err: any, statusCode: number, Containers: FileContainerInterfaces.FileContainer[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -374,7 +336,7 @@ export class QFileContainerApi implements IQFileContainerApi {
var deferred = Q.defer<FileContainerInterfaces.FileContainerItem[]>();
this.FileContainerApi.getItems(containerId, scope, itemPath, metadata, format, downloadFileName, includeDownloadTickets, (err: any, statusCode: number, Containers: FileContainerInterfaces.FileContainerItem[]) => {
this.api.getItems(containerId, scope, itemPath, metadata, format, downloadFileName, includeDownloadTickets, (err: any, statusCode: number, Containers: FileContainerInterfaces.FileContainerItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

Просмотреть файл

@ -20,17 +20,12 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import GitInterfaces = require("./interfaces/GitInterfaces");
import VSSInterfaces = require("./interfaces/common/VSSInterfaces");
export interface IGitApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface IGitApi extends basem.ClientApiBase {
getBlob(repositoryId: string, sha1: string, project: string, download: boolean, fileName: string, onResult: (err: any, statusCode: number, Blob: GitInterfaces.GitBlobRef) => void): void;
getBlobContent(repositoryId: string, sha1: string, project: string, download: boolean, fileName: string, onResult: (err: any, statusCode: number, res: NodeJS.ReadableStream) => void): void;
getBlobsZip(blobIds: string[], repositoryId: string, project: string, filename: string, onResult: (err: any, statusCode: number, res: NodeJS.ReadableStream) => void): void;
@ -73,8 +68,7 @@ export interface IGitApi {
getTreeZip(repositoryId: string, sha1: string, project: string, projectId: string, recursive: boolean, fileName: string, onResult: (err: any, statusCode: number, res: NodeJS.ReadableStream) => void): void;
}
export interface IQGitApi {
connect(): Q.Promise<void>;
export interface IQGitApi extends basem.QClientApiBase {
getBlob(repositoryId: string, sha1: string, project?: string, download?: boolean, fileName?: string): Q.Promise<GitInterfaces.GitBlobRef>;
getBranch(repositoryId: string, name: string, project?: string, baseVersionDescriptor?: GitInterfaces.GitVersionDescriptor): Q.Promise<GitInterfaces.GitBranchStats>;
@ -109,27 +103,10 @@ export interface IQGitApi {
getTree(repositoryId: string, sha1: string, project?: string, projectId?: string, recursive?: boolean, fileName?: string): Q.Promise<GitInterfaces.GitTreeRef>;
}
export class GitApi implements IGitApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class GitApi extends basem.ClientApiBase implements IGitApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-Git-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-Git-api');
}
/**
@ -1602,27 +1579,12 @@ export class GitApi implements IGitApi {
}
export class QGitApi implements IQGitApi {
GitApi: IGitApi;
export class QGitApi extends basem.QClientApiBase implements IQGitApi {
api: GitApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.GitApi = new GitApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.GitApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, GitApi);
}
@ -1645,7 +1607,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitBlobRef>();
this.GitApi.getBlob(repositoryId, sha1, project, download, fileName, (err: any, statusCode: number, Blob: GitInterfaces.GitBlobRef) => {
this.api.getBlob(repositoryId, sha1, project, download, fileName, (err: any, statusCode: number, Blob: GitInterfaces.GitBlobRef) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1675,7 +1637,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitBranchStats>();
this.GitApi.getBranch(repositoryId, name, project, baseVersionDescriptor, (err: any, statusCode: number, BranchStat: GitInterfaces.GitBranchStats) => {
this.api.getBranch(repositoryId, name, project, baseVersionDescriptor, (err: any, statusCode: number, BranchStat: GitInterfaces.GitBranchStats) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1703,7 +1665,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitBranchStats[]>();
this.GitApi.getBranches(repositoryId, project, baseVersionDescriptor, (err: any, statusCode: number, BranchStats: GitInterfaces.GitBranchStats[]) => {
this.api.getBranches(repositoryId, project, baseVersionDescriptor, (err: any, statusCode: number, BranchStats: GitInterfaces.GitBranchStats[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1735,7 +1697,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitCommitChanges>();
this.GitApi.getChanges(commitId, repositoryId, project, top, skip, (err: any, statusCode: number, Change: GitInterfaces.GitCommitChanges) => {
this.api.getChanges(commitId, repositoryId, project, top, skip, (err: any, statusCode: number, Change: GitInterfaces.GitCommitChanges) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1761,7 +1723,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitCommit>();
this.GitApi.createCommit(repositoryId, project, (err: any, statusCode: number, Commit: GitInterfaces.GitCommit) => {
this.api.createCommit(repositoryId, project, (err: any, statusCode: number, Commit: GitInterfaces.GitCommit) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1791,7 +1753,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitCommit>();
this.GitApi.getCommit(commitId, repositoryId, project, changeCount, (err: any, statusCode: number, Commit: GitInterfaces.GitCommit) => {
this.api.getCommit(commitId, repositoryId, project, changeCount, (err: any, statusCode: number, Commit: GitInterfaces.GitCommit) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1823,7 +1785,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitCommitRef[]>();
this.GitApi.getCommits(repositoryId, searchCriteria, project, skip, top, (err: any, statusCode: number, Commits: GitInterfaces.GitCommitRef[]) => {
this.api.getCommits(repositoryId, searchCriteria, project, skip, top, (err: any, statusCode: number, Commits: GitInterfaces.GitCommitRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1857,7 +1819,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitCommitRef[]>();
this.GitApi.getPushCommits(repositoryId, pushId, project, top, skip, includeLinks, (err: any, statusCode: number, Commits: GitInterfaces.GitCommitRef[]) => {
this.api.getPushCommits(repositoryId, pushId, project, top, skip, includeLinks, (err: any, statusCode: number, Commits: GitInterfaces.GitCommitRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1889,7 +1851,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitCommitRef[]>();
this.GitApi.getCommitsBatch(searchCriteria, repositoryId, project, skip, top, (err: any, statusCode: number, CommitsBatch: GitInterfaces.GitCommitRef[]) => {
this.api.getCommitsBatch(searchCriteria, repositoryId, project, skip, top, (err: any, statusCode: number, CommitsBatch: GitInterfaces.GitCommitRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1929,7 +1891,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitItem>();
this.GitApi.getItem(repositoryId, path, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, versionDescriptor, (err: any, statusCode: number, Item: GitInterfaces.GitItem) => {
this.api.getItem(repositoryId, path, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, versionDescriptor, (err: any, statusCode: number, Item: GitInterfaces.GitItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1969,7 +1931,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitItem[]>();
this.GitApi.getItems(repositoryId, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, includeLinks, versionDescriptor, (err: any, statusCode: number, Items: GitInterfaces.GitItem[]) => {
this.api.getItems(repositoryId, project, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, includeLinks, versionDescriptor, (err: any, statusCode: number, Items: GitInterfaces.GitItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1997,7 +1959,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitItem[][]>();
this.GitApi.getItemsBatch(requestData, repositoryId, project, (err: any, statusCode: number, ItemsBatch: GitInterfaces.GitItem[][]) => {
this.api.getItemsBatch(requestData, repositoryId, project, (err: any, statusCode: number, ItemsBatch: GitInterfaces.GitItem[][]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2029,7 +1991,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.IdentityRefWithVote>();
this.GitApi.createPullRequestReviewer(reviewer, repositoryId, pullRequestId, reviewerId, project, (err: any, statusCode: number, PullRequestReviewer: GitInterfaces.IdentityRefWithVote) => {
this.api.createPullRequestReviewer(reviewer, repositoryId, pullRequestId, reviewerId, project, (err: any, statusCode: number, PullRequestReviewer: GitInterfaces.IdentityRefWithVote) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2059,7 +2021,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.IdentityRefWithVote[]>();
this.GitApi.createPullRequestReviewers(reviewers, repositoryId, pullRequestId, project, (err: any, statusCode: number, PullRequestReviewers: GitInterfaces.IdentityRefWithVote[]) => {
this.api.createPullRequestReviewers(reviewers, repositoryId, pullRequestId, project, (err: any, statusCode: number, PullRequestReviewers: GitInterfaces.IdentityRefWithVote[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2089,7 +2051,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.IdentityRefWithVote>();
this.GitApi.getPullRequestReviewer(repositoryId, pullRequestId, reviewerId, project, (err: any, statusCode: number, PullRequestReviewer: GitInterfaces.IdentityRefWithVote) => {
this.api.getPullRequestReviewer(repositoryId, pullRequestId, reviewerId, project, (err: any, statusCode: number, PullRequestReviewer: GitInterfaces.IdentityRefWithVote) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2117,7 +2079,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.IdentityRefWithVote[]>();
this.GitApi.getPullRequestReviewers(repositoryId, pullRequestId, project, (err: any, statusCode: number, PullRequestReviewers: GitInterfaces.IdentityRefWithVote[]) => {
this.api.getPullRequestReviewers(repositoryId, pullRequestId, project, (err: any, statusCode: number, PullRequestReviewers: GitInterfaces.IdentityRefWithVote[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2145,7 +2107,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitPullRequest>();
this.GitApi.createPullRequest(gitPullRequestToCreate, repositoryId, project, (err: any, statusCode: number, PullRequest: GitInterfaces.GitPullRequest) => {
this.api.createPullRequest(gitPullRequestToCreate, repositoryId, project, (err: any, statusCode: number, PullRequest: GitInterfaces.GitPullRequest) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2179,7 +2141,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitPullRequest>();
this.GitApi.getPullRequest(repositoryId, pullRequestId, project, maxCommentLength, skip, top, (err: any, statusCode: number, PullRequest: GitInterfaces.GitPullRequest) => {
this.api.getPullRequest(repositoryId, pullRequestId, project, maxCommentLength, skip, top, (err: any, statusCode: number, PullRequest: GitInterfaces.GitPullRequest) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2213,7 +2175,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitPullRequest[]>();
this.GitApi.getPullRequests(repositoryId, searchCriteria, project, maxCommentLength, skip, top, (err: any, statusCode: number, PullRequests: GitInterfaces.GitPullRequest[]) => {
this.api.getPullRequests(repositoryId, searchCriteria, project, maxCommentLength, skip, top, (err: any, statusCode: number, PullRequests: GitInterfaces.GitPullRequest[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2243,7 +2205,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitPullRequest>();
this.GitApi.updatePullRequest(gitPullRequestToUpdate, repositoryId, pullRequestId, project, (err: any, statusCode: number, PullRequest: GitInterfaces.GitPullRequest) => {
this.api.updatePullRequest(gitPullRequestToUpdate, repositoryId, pullRequestId, project, (err: any, statusCode: number, PullRequest: GitInterfaces.GitPullRequest) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2275,7 +2237,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.AssociatedWorkItem[]>();
this.GitApi.getPullRequestWorkItems(repositoryId, pullRequestId, project, commitsTop, commitsSkip, (err: any, statusCode: number, PullRequestWorkItems: GitInterfaces.AssociatedWorkItem[]) => {
this.api.getPullRequestWorkItems(repositoryId, pullRequestId, project, commitsTop, commitsSkip, (err: any, statusCode: number, PullRequestWorkItems: GitInterfaces.AssociatedWorkItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2303,7 +2265,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitPush>();
this.GitApi.createPush(push, repositoryId, project, (err: any, statusCode: number, pushe: GitInterfaces.GitPush) => {
this.api.createPush(push, repositoryId, project, (err: any, statusCode: number, pushe: GitInterfaces.GitPush) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2335,7 +2297,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitPush>();
this.GitApi.getPush(repositoryId, pushId, project, includeCommits, includeRefUpdates, (err: any, statusCode: number, pushe: GitInterfaces.GitPush) => {
this.api.getPush(repositoryId, pushId, project, includeCommits, includeRefUpdates, (err: any, statusCode: number, pushe: GitInterfaces.GitPush) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2367,7 +2329,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitPush[]>();
this.GitApi.getPushes(repositoryId, project, skip, top, searchCriteria, (err: any, statusCode: number, pushes: GitInterfaces.GitPush[]) => {
this.api.getPushes(repositoryId, project, skip, top, searchCriteria, (err: any, statusCode: number, pushes: GitInterfaces.GitPush[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2397,7 +2359,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitRef[]>();
this.GitApi.getRefs(repositoryId, project, filter, includeLinks, (err: any, statusCode: number, refs: GitInterfaces.GitRef[]) => {
this.api.getRefs(repositoryId, project, filter, includeLinks, (err: any, statusCode: number, refs: GitInterfaces.GitRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2427,7 +2389,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitRefUpdateResult[]>();
this.GitApi.updateRefs(refUpdates, repositoryId, project, projectId, (err: any, statusCode: number, refs: GitInterfaces.GitRefUpdateResult[]) => {
this.api.updateRefs(refUpdates, repositoryId, project, projectId, (err: any, statusCode: number, refs: GitInterfaces.GitRefUpdateResult[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2453,7 +2415,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitRepository>();
this.GitApi.createRepository(gitRepositoryToCreate, project, (err: any, statusCode: number, Repositorie: GitInterfaces.GitRepository) => {
this.api.createRepository(gitRepositoryToCreate, project, (err: any, statusCode: number, Repositorie: GitInterfaces.GitRepository) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2479,7 +2441,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitRepository[]>();
this.GitApi.getRepositories(project, includeLinks, (err: any, statusCode: number, Repositories: GitInterfaces.GitRepository[]) => {
this.api.getRepositories(project, includeLinks, (err: any, statusCode: number, Repositories: GitInterfaces.GitRepository[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2503,7 +2465,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitRepository>();
this.GitApi.getRepository(repositoryId, project, (err: any, statusCode: number, Repositorie: GitInterfaces.GitRepository) => {
this.api.getRepository(repositoryId, project, (err: any, statusCode: number, Repositorie: GitInterfaces.GitRepository) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2531,7 +2493,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitRepository>();
this.GitApi.updateRepository(newRepositoryInfo, repositoryId, project, (err: any, statusCode: number, Repositorie: GitInterfaces.GitRepository) => {
this.api.updateRepository(newRepositoryInfo, repositoryId, project, (err: any, statusCode: number, Repositorie: GitInterfaces.GitRepository) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2563,7 +2525,7 @@ export class QGitApi implements IQGitApi {
var deferred = Q.defer<GitInterfaces.GitTreeRef>();
this.GitApi.getTree(repositoryId, sha1, project, projectId, recursive, fileName, (err: any, statusCode: number, Tree: GitInterfaces.GitTreeRef) => {
this.api.getTree(repositoryId, sha1, project, projectId, recursive, fileName, (err: any, statusCode: number, Tree: GitInterfaces.GitTreeRef) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

Просмотреть файл

@ -20,17 +20,12 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import TaskAgentInterfaces = require("./interfaces/TaskAgentInterfaces");
import VSSInterfaces = require("./interfaces/common/VSSInterfaces");
export interface ITaskAgentApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface ITaskAgentApi extends basem.ClientApiBase {
createAgent(agent: TaskAgentInterfaces.TaskAgent, poolId: number, onResult: (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => void): void;
deleteAgent(poolId: number, agentId: number, onResult: (err: any, statusCode: number) => void): void;
getAgent(poolId: number, agentId: number, includeCapabilities: boolean, propertyFilters: string, onResult: (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => void): void;
@ -67,8 +62,7 @@ export interface ITaskAgentApi {
updateUserCapabilities(userCapabilities: { [key: string] : string; }, poolId: number, agentId: number, onResult: (err: any, statusCode: number, usercapabilitie: TaskAgentInterfaces.TaskAgent) => void): void;
}
export interface IQTaskAgentApi {
connect(): Q.Promise<void>;
export interface IQTaskAgentApi extends basem.QClientApiBase {
createAgent(agent: TaskAgentInterfaces.TaskAgent, poolId: number): Q.Promise<TaskAgentInterfaces.TaskAgent>;
getAgent(poolId: number, agentId: number, includeCapabilities?: boolean, propertyFilters?: string): Q.Promise<TaskAgentInterfaces.TaskAgent>;
@ -94,27 +88,10 @@ export interface IQTaskAgentApi {
updateUserCapabilities(userCapabilities: { [key: string] : string; }, poolId: number, agentId: number): Q.Promise<TaskAgentInterfaces.TaskAgent>;
}
export class TaskAgentApi implements ITaskAgentApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class TaskAgentApi extends basem.ClientApiBase implements ITaskAgentApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-TaskAgent-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-TaskAgent-api');
}
/**
@ -1022,27 +999,12 @@ export class TaskAgentApi implements ITaskAgentApi {
}
export class QTaskAgentApi implements IQTaskAgentApi {
TaskAgentApi: ITaskAgentApi;
export class QTaskAgentApi extends basem.QClientApiBase implements IQTaskAgentApi {
api: TaskAgentApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.TaskAgentApi = new TaskAgentApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.TaskAgentApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, TaskAgentApi);
}
@ -1057,7 +1019,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgent>();
this.TaskAgentApi.createAgent(agent, poolId, (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => {
this.api.createAgent(agent, poolId, (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1085,7 +1047,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgent>();
this.TaskAgentApi.getAgent(poolId, agentId, includeCapabilities, propertyFilters, (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => {
this.api.getAgent(poolId, agentId, includeCapabilities, propertyFilters, (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1115,7 +1077,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgent[]>();
this.TaskAgentApi.getAgents(poolId, agentName, includeCapabilities, propertyFilters, demands, (err: any, statusCode: number, agents: TaskAgentInterfaces.TaskAgent[]) => {
this.api.getAgents(poolId, agentName, includeCapabilities, propertyFilters, demands, (err: any, statusCode: number, agents: TaskAgentInterfaces.TaskAgent[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1141,7 +1103,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgent>();
this.TaskAgentApi.replaceAgent(agent, poolId, agentId, (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => {
this.api.replaceAgent(agent, poolId, agentId, (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1167,7 +1129,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgent>();
this.TaskAgentApi.updateAgent(agent, poolId, agentId, (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => {
this.api.updateAgent(agent, poolId, agentId, (err: any, statusCode: number, agent: TaskAgentInterfaces.TaskAgent) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1191,7 +1153,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<string[]>();
this.TaskAgentApi.queryEndpoint(endpoint, (err: any, statusCode: number, endpoint: string[]) => {
this.api.queryEndpoint(endpoint, (err: any, statusCode: number, endpoint: string[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1215,7 +1177,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentJobRequest>();
this.TaskAgentApi.getRequest(poolId, requestId, (err: any, statusCode: number, jobrequest: TaskAgentInterfaces.TaskAgentJobRequest) => {
this.api.getRequest(poolId, requestId, (err: any, statusCode: number, jobrequest: TaskAgentInterfaces.TaskAgentJobRequest) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1239,7 +1201,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentJobRequest>();
this.TaskAgentApi.queueRequest(request, poolId, (err: any, statusCode: number, jobrequest: TaskAgentInterfaces.TaskAgentJobRequest) => {
this.api.queueRequest(request, poolId, (err: any, statusCode: number, jobrequest: TaskAgentInterfaces.TaskAgentJobRequest) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1267,7 +1229,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentJobRequest>();
this.TaskAgentApi.updateRequest(request, poolId, requestId, lockToken, (err: any, statusCode: number, jobrequest: TaskAgentInterfaces.TaskAgentJobRequest) => {
this.api.updateRequest(request, poolId, requestId, lockToken, (err: any, statusCode: number, jobrequest: TaskAgentInterfaces.TaskAgentJobRequest) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1293,7 +1255,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentMessage>();
this.TaskAgentApi.getMessage(poolId, sessionId, lastMessageId, (err: any, statusCode: number, message: TaskAgentInterfaces.TaskAgentMessage) => {
this.api.getMessage(poolId, sessionId, lastMessageId, (err: any, statusCode: number, message: TaskAgentInterfaces.TaskAgentMessage) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1315,7 +1277,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentPool>();
this.TaskAgentApi.createPool(pool, (err: any, statusCode: number, pool: TaskAgentInterfaces.TaskAgentPool) => {
this.api.createPool(pool, (err: any, statusCode: number, pool: TaskAgentInterfaces.TaskAgentPool) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1339,7 +1301,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentPool>();
this.TaskAgentApi.getPool(poolId, properties, (err: any, statusCode: number, pool: TaskAgentInterfaces.TaskAgentPool) => {
this.api.getPool(poolId, properties, (err: any, statusCode: number, pool: TaskAgentInterfaces.TaskAgentPool) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1363,7 +1325,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentPool[]>();
this.TaskAgentApi.getPools(poolName, properties, (err: any, statusCode: number, pools: TaskAgentInterfaces.TaskAgentPool[]) => {
this.api.getPools(poolName, properties, (err: any, statusCode: number, pools: TaskAgentInterfaces.TaskAgentPool[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1387,7 +1349,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentPool>();
this.TaskAgentApi.updatePool(pool, poolId, (err: any, statusCode: number, pool: TaskAgentInterfaces.TaskAgentPool) => {
this.api.updatePool(pool, poolId, (err: any, statusCode: number, pool: TaskAgentInterfaces.TaskAgentPool) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1409,7 +1371,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<VSSInterfaces.IdentityRef[]>();
this.TaskAgentApi.getAgentPoolRoles(poolId, (err: any, statusCode: number, roles: VSSInterfaces.IdentityRef[]) => {
this.api.getAgentPoolRoles(poolId, (err: any, statusCode: number, roles: VSSInterfaces.IdentityRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1435,7 +1397,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.ServiceEndpoint>();
this.TaskAgentApi.createServiceEndpoint(endpoint, scopeIdentifier, endpointId, (err: any, statusCode: number, serviceendpoint: TaskAgentInterfaces.ServiceEndpoint) => {
this.api.createServiceEndpoint(endpoint, scopeIdentifier, endpointId, (err: any, statusCode: number, serviceendpoint: TaskAgentInterfaces.ServiceEndpoint) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1459,7 +1421,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.ServiceEndpoint>();
this.TaskAgentApi.getServiceEndpointDetails(scopeIdentifier, endpointId, (err: any, statusCode: number, serviceendpoint: TaskAgentInterfaces.ServiceEndpoint) => {
this.api.getServiceEndpointDetails(scopeIdentifier, endpointId, (err: any, statusCode: number, serviceendpoint: TaskAgentInterfaces.ServiceEndpoint) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1483,7 +1445,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.ServiceEndpoint[]>();
this.TaskAgentApi.getServiceEndpoints(scopeIdentifier, type, (err: any, statusCode: number, serviceendpoints: TaskAgentInterfaces.ServiceEndpoint[]) => {
this.api.getServiceEndpoints(scopeIdentifier, type, (err: any, statusCode: number, serviceendpoints: TaskAgentInterfaces.ServiceEndpoint[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1507,7 +1469,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgentSession>();
this.TaskAgentApi.createSession(session, poolId, (err: any, statusCode: number, session: TaskAgentInterfaces.TaskAgentSession) => {
this.api.createSession(session, poolId, (err: any, statusCode: number, session: TaskAgentInterfaces.TaskAgentSession) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1531,7 +1493,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskDefinition[]>();
this.TaskAgentApi.getTaskContent(taskId, versionString, (err: any, statusCode: number, tasks: TaskAgentInterfaces.TaskDefinition[]) => {
this.api.getTaskContent(taskId, versionString, (err: any, statusCode: number, tasks: TaskAgentInterfaces.TaskDefinition[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1553,7 +1515,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskDefinition[]>();
this.TaskAgentApi.getTaskDefinitions(visibility, (err: any, statusCode: number, tasks: TaskAgentInterfaces.TaskDefinition[]) => {
this.api.getTaskDefinitions(visibility, (err: any, statusCode: number, tasks: TaskAgentInterfaces.TaskDefinition[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1579,7 +1541,7 @@ export class QTaskAgentApi implements IQTaskAgentApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskAgent>();
this.TaskAgentApi.updateUserCapabilities(userCapabilities, poolId, agentId, (err: any, statusCode: number, usercapabilitie: TaskAgentInterfaces.TaskAgent) => {
this.api.updateUserCapabilities(userCapabilities, poolId, agentId, (err: any, statusCode: number, usercapabilitie: TaskAgentInterfaces.TaskAgent) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

Просмотреть файл

@ -20,17 +20,12 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import TaskAgentInterfaces = require("./interfaces/TaskAgentInterfaces");
import VSSInterfaces = require("./interfaces/common/VSSInterfaces");
export interface ITaskApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface ITaskApi extends basem.ClientApiBase {
postEvent(eventData: TaskAgentInterfaces.JobEvent, scopeIdentifier: string, hubName: string, planId: string, onResult: (err: any, statusCode: number) => void): void;
postLines(lines: VSSInterfaces.VssJsonCollectionWrapperV<string[]>, scopeIdentifier: string, hubName: string, planId: string, timelineId: string, recordId: string, onResult: (err: any, statusCode: number) => void): void;
appendLog(contentStream: NodeJS.ReadableStream, customHeaders: any, content: string, scopeIdentifier: string, hubName: string, planId: string, logId: number, onResult: (err: any, statusCode: number, log: TaskAgentInterfaces.TaskLog) => void): void;
@ -46,8 +41,7 @@ export interface ITaskApi {
getTimelines(scopeIdentifier: string, hubName: string, planId: string, onResult: (err: any, statusCode: number, timelines: TaskAgentInterfaces.Timeline[]) => void): void;
}
export interface IQTaskApi {
connect(): Q.Promise<void>;
export interface IQTaskApi extends basem.QClientApiBase {
appendLog(contentStream: NodeJS.ReadableStream, customHeaders: any, content: string, scopeIdentifier: string, hubName: string, planId: string, logId: number): Q.Promise<TaskAgentInterfaces.TaskLog>;
createLog(log: TaskAgentInterfaces.TaskLog, scopeIdentifier: string, hubName: string, planId: string): Q.Promise<TaskAgentInterfaces.TaskLog>;
@ -61,27 +55,10 @@ export interface IQTaskApi {
getTimelines(scopeIdentifier: string, hubName: string, planId: string): Q.Promise<TaskAgentInterfaces.Timeline[]>;
}
export class TaskApi implements ITaskApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class TaskApi extends basem.ClientApiBase implements ITaskApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-Task-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-Task-api');
}
/**
@ -512,27 +489,12 @@ export class TaskApi implements ITaskApi {
}
export class QTaskApi implements IQTaskApi {
TaskApi: ITaskApi;
export class QTaskApi extends basem.QClientApiBase implements IQTaskApi {
api: TaskApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.TaskApi = new TaskApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.TaskApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, TaskApi);
}
@ -555,7 +517,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskLog>();
this.TaskApi.appendLog(contentStream, customHeaders, content, scopeIdentifier, hubName, planId, logId, (err: any, statusCode: number, log: TaskAgentInterfaces.TaskLog) => {
this.api.appendLog(contentStream, customHeaders, content, scopeIdentifier, hubName, planId, logId, (err: any, statusCode: number, log: TaskAgentInterfaces.TaskLog) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -583,7 +545,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskLog>();
this.TaskApi.createLog(log, scopeIdentifier, hubName, planId, (err: any, statusCode: number, log: TaskAgentInterfaces.TaskLog) => {
this.api.createLog(log, scopeIdentifier, hubName, planId, (err: any, statusCode: number, log: TaskAgentInterfaces.TaskLog) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -615,7 +577,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<string[]>();
this.TaskApi.getLog(scopeIdentifier, hubName, planId, logId, startLine, endLine, (err: any, statusCode: number, logs: string[]) => {
this.api.getLog(scopeIdentifier, hubName, planId, logId, startLine, endLine, (err: any, statusCode: number, logs: string[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -641,7 +603,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskLog[]>();
this.TaskApi.getLogs(scopeIdentifier, hubName, planId, (err: any, statusCode: number, logs: TaskAgentInterfaces.TaskLog[]) => {
this.api.getLogs(scopeIdentifier, hubName, planId, (err: any, statusCode: number, logs: TaskAgentInterfaces.TaskLog[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -667,7 +629,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.TaskOrchestrationPlan>();
this.TaskApi.getPlan(scopeIdentifier, hubName, planId, (err: any, statusCode: number, plan: TaskAgentInterfaces.TaskOrchestrationPlan) => {
this.api.getPlan(scopeIdentifier, hubName, planId, (err: any, statusCode: number, plan: TaskAgentInterfaces.TaskOrchestrationPlan) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -697,7 +659,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.TimelineRecord[]>();
this.TaskApi.getRecords(scopeIdentifier, hubName, planId, timelineId, changeId, (err: any, statusCode: number, records: TaskAgentInterfaces.TimelineRecord[]) => {
this.api.getRecords(scopeIdentifier, hubName, planId, timelineId, changeId, (err: any, statusCode: number, records: TaskAgentInterfaces.TimelineRecord[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -727,7 +689,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.TimelineRecord[]>();
this.TaskApi.updateRecords(records, scopeIdentifier, hubName, planId, timelineId, (err: any, statusCode: number, record: TaskAgentInterfaces.TimelineRecord[]) => {
this.api.updateRecords(records, scopeIdentifier, hubName, planId, timelineId, (err: any, statusCode: number, record: TaskAgentInterfaces.TimelineRecord[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -755,7 +717,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.Timeline>();
this.TaskApi.createTimeline(timeline, scopeIdentifier, hubName, planId, (err: any, statusCode: number, timeline: TaskAgentInterfaces.Timeline) => {
this.api.createTimeline(timeline, scopeIdentifier, hubName, planId, (err: any, statusCode: number, timeline: TaskAgentInterfaces.Timeline) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -787,7 +749,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.Timeline>();
this.TaskApi.getTimeline(scopeIdentifier, hubName, planId, timelineId, changeId, includeRecords, (err: any, statusCode: number, timeline: TaskAgentInterfaces.Timeline) => {
this.api.getTimeline(scopeIdentifier, hubName, planId, timelineId, changeId, includeRecords, (err: any, statusCode: number, timeline: TaskAgentInterfaces.Timeline) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -813,7 +775,7 @@ export class QTaskApi implements IQTaskApi {
var deferred = Q.defer<TaskAgentInterfaces.Timeline[]>();
this.TaskApi.getTimelines(scopeIdentifier, hubName, planId, (err: any, statusCode: number, timelines: TaskAgentInterfaces.Timeline[]) => {
this.api.getTimelines(scopeIdentifier, hubName, planId, (err: any, statusCode: number, timelines: TaskAgentInterfaces.Timeline[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

Просмотреть файл

@ -20,16 +20,11 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import TestInterfaces = require("./interfaces/TestInterfaces");
export interface ITestApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface ITestApi extends basem.ClientApiBase {
createTestResultAttachment(attachmentRequestModel: TestInterfaces.TestAttachmentRequestModel, project: string, runId: number, testCaseResultId: number, onResult: (err: any, statusCode: number, Attachment: TestInterfaces.TestAttachmentReference) => void): void;
createTestRunAttachment(attachmentRequestModel: TestInterfaces.TestAttachmentRequestModel, project: string, runId: number, onResult: (err: any, statusCode: number, Attachment: TestInterfaces.TestAttachmentReference) => void): void;
getBuildCodeCoverage(project: string, buildId: number, flags: number, onResult: (err: any, statusCode: number, CodeCoverage: TestInterfaces.BuildCoverage[]) => void): void;
@ -74,8 +69,7 @@ export interface ITestApi {
getTestSettingsById(project: string, testSettingsId: number, onResult: (err: any, statusCode: number, TestSetting: TestInterfaces.TestSettings) => void): void;
}
export interface IQTestApi {
connect(): Q.Promise<void>;
export interface IQTestApi extends basem.QClientApiBase {
createTestResultAttachment(attachmentRequestModel: TestInterfaces.TestAttachmentRequestModel, project: string, runId: number, testCaseResultId: number): Q.Promise<TestInterfaces.TestAttachmentReference>;
createTestRunAttachment(attachmentRequestModel: TestInterfaces.TestAttachmentRequestModel, project: string, runId: number): Q.Promise<TestInterfaces.TestAttachmentReference>;
@ -117,27 +111,10 @@ export interface IQTestApi {
getTestSettingsById(project: string, testSettingsId: number): Q.Promise<TestInterfaces.TestSettings>;
}
export class TestApi implements ITestApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class TestApi extends basem.ClientApiBase implements ITestApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-Test-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-Test-api');
}
/**
@ -1447,27 +1424,12 @@ export class TestApi implements ITestApi {
}
export class QTestApi implements IQTestApi {
TestApi: ITestApi;
export class QTestApi extends basem.QClientApiBase implements IQTestApi {
api: TestApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.TestApi = new TestApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.TestApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, TestApi);
}
@ -1486,7 +1448,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestAttachmentReference>();
this.TestApi.createTestResultAttachment(attachmentRequestModel, project, runId, testCaseResultId, (err: any, statusCode: number, Attachment: TestInterfaces.TestAttachmentReference) => {
this.api.createTestResultAttachment(attachmentRequestModel, project, runId, testCaseResultId, (err: any, statusCode: number, Attachment: TestInterfaces.TestAttachmentReference) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1512,7 +1474,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestAttachmentReference>();
this.TestApi.createTestRunAttachment(attachmentRequestModel, project, runId, (err: any, statusCode: number, Attachment: TestInterfaces.TestAttachmentReference) => {
this.api.createTestRunAttachment(attachmentRequestModel, project, runId, (err: any, statusCode: number, Attachment: TestInterfaces.TestAttachmentReference) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1538,7 +1500,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.BuildCoverage[]>();
this.TestApi.getBuildCodeCoverage(project, buildId, flags, (err: any, statusCode: number, CodeCoverage: TestInterfaces.BuildCoverage[]) => {
this.api.getBuildCodeCoverage(project, buildId, flags, (err: any, statusCode: number, CodeCoverage: TestInterfaces.BuildCoverage[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1564,7 +1526,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestRunCoverage[]>();
this.TestApi.getTestRunCodeCoverage(project, runId, flags, (err: any, statusCode: number, CodeCoverage: TestInterfaces.TestRunCoverage[]) => {
this.api.getTestRunCodeCoverage(project, runId, flags, (err: any, statusCode: number, CodeCoverage: TestInterfaces.TestRunCoverage[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1588,7 +1550,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestMessageLogDetails[]>();
this.TestApi.getTestRunLogs(project, runId, (err: any, statusCode: number, MessageLogs: TestInterfaces.TestMessageLogDetails[]) => {
this.api.getTestRunLogs(project, runId, (err: any, statusCode: number, MessageLogs: TestInterfaces.TestMessageLogDetails[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1612,7 +1574,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestPlan>();
this.TestApi.createTestPlan(testPlan, project, (err: any, statusCode: number, Plan: TestInterfaces.TestPlan) => {
this.api.createTestPlan(testPlan, project, (err: any, statusCode: number, Plan: TestInterfaces.TestPlan) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1636,7 +1598,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestPlan>();
this.TestApi.getPlanById(project, planId, (err: any, statusCode: number, Plan: TestInterfaces.TestPlan) => {
this.api.getPlanById(project, planId, (err: any, statusCode: number, Plan: TestInterfaces.TestPlan) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1668,7 +1630,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestPlan[]>();
this.TestApi.getPlans(project, owner, skip, top, includePlanDetails, filterActivePlans, (err: any, statusCode: number, Plans: TestInterfaces.TestPlan[]) => {
this.api.getPlans(project, owner, skip, top, includePlanDetails, filterActivePlans, (err: any, statusCode: number, Plans: TestInterfaces.TestPlan[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1694,7 +1656,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestPlan>();
this.TestApi.updateTestPlan(planUpdateModel, project, planId, (err: any, statusCode: number, Plan: TestInterfaces.TestPlan) => {
this.api.updateTestPlan(planUpdateModel, project, planId, (err: any, statusCode: number, Plan: TestInterfaces.TestPlan) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1724,7 +1686,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestPoint>();
this.TestApi.getPoint(project, planId, suiteId, pointIds, witFields, (err: any, statusCode: number, Point: TestInterfaces.TestPoint) => {
this.api.getPoint(project, planId, suiteId, pointIds, witFields, (err: any, statusCode: number, Point: TestInterfaces.TestPoint) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1764,7 +1726,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestPoint[]>();
this.TestApi.getPoints(project, planId, suiteId, witFields, configurationId, testCaseId, testPointIds, includePointDetails, skip, top, (err: any, statusCode: number, Points: TestInterfaces.TestPoint[]) => {
this.api.getPoints(project, planId, suiteId, witFields, configurationId, testCaseId, testPointIds, includePointDetails, skip, top, (err: any, statusCode: number, Points: TestInterfaces.TestPoint[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1794,7 +1756,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestPoint[]>();
this.TestApi.updateTestPoints(pointUpdateModel, project, planId, suiteId, pointIds, (err: any, statusCode: number, Point: TestInterfaces.TestPoint[]) => {
this.api.updateTestPoints(pointUpdateModel, project, planId, suiteId, pointIds, (err: any, statusCode: number, Point: TestInterfaces.TestPoint[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1824,7 +1786,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestIterationDetailsModel>();
this.TestApi.getTestIteration(project, runId, testCaseResultId, iterationId, includeActionResults, (err: any, statusCode: number, Result: TestInterfaces.TestIterationDetailsModel) => {
this.api.getTestIteration(project, runId, testCaseResultId, iterationId, includeActionResults, (err: any, statusCode: number, Result: TestInterfaces.TestIterationDetailsModel) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1852,7 +1814,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestIterationDetailsModel[]>();
this.TestApi.getTestIterations(project, runId, testCaseResultId, includeActionResults, (err: any, statusCode: number, Results: TestInterfaces.TestIterationDetailsModel[]) => {
this.api.getTestIterations(project, runId, testCaseResultId, includeActionResults, (err: any, statusCode: number, Results: TestInterfaces.TestIterationDetailsModel[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1878,7 +1840,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestCaseResult[]>();
this.TestApi.addTestResultsToTestRun(resultCreateModels, project, runId, (err: any, statusCode: number, Results: TestInterfaces.TestCaseResult[]) => {
this.api.addTestResultsToTestRun(resultCreateModels, project, runId, (err: any, statusCode: number, Results: TestInterfaces.TestCaseResult[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1906,7 +1868,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestCaseResult[]>();
this.TestApi.bulkUpdateTestResults(resultUpdateModel, project, runId, resultIds, (err: any, statusCode: number, Result: TestInterfaces.TestCaseResult[]) => {
this.api.bulkUpdateTestResults(resultUpdateModel, project, runId, resultIds, (err: any, statusCode: number, Result: TestInterfaces.TestCaseResult[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1934,7 +1896,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestCaseResult>();
this.TestApi.getTestCaseResultById(project, runId, testCaseResultId, includeIterationDetails, (err: any, statusCode: number, Result: TestInterfaces.TestCaseResult) => {
this.api.getTestCaseResultById(project, runId, testCaseResultId, includeIterationDetails, (err: any, statusCode: number, Result: TestInterfaces.TestCaseResult) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1960,7 +1922,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestCaseResult[]>();
this.TestApi.getTestCaseResults(project, runId, includeIterationDetails, (err: any, statusCode: number, Results: TestInterfaces.TestCaseResult[]) => {
this.api.getTestCaseResults(project, runId, includeIterationDetails, (err: any, statusCode: number, Results: TestInterfaces.TestCaseResult[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1986,7 +1948,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestCaseResult[]>();
this.TestApi.updateTestResults(resultUpdateModels, project, runId, (err: any, statusCode: number, Results: TestInterfaces.TestCaseResult[]) => {
this.api.updateTestResults(resultUpdateModels, project, runId, (err: any, statusCode: number, Results: TestInterfaces.TestCaseResult[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2016,7 +1978,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestActionResultModel[]>();
this.TestApi.getActionResults(project, runId, testCaseResultId, iterationId, actionPath, (err: any, statusCode: number, Results: TestInterfaces.TestActionResultModel[]) => {
this.api.getActionResults(project, runId, testCaseResultId, iterationId, actionPath, (err: any, statusCode: number, Results: TestInterfaces.TestActionResultModel[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2046,7 +2008,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestResultParameterModel[]>();
this.TestApi.getResultParameters(project, runId, testCaseResultId, iterationId, paramName, (err: any, statusCode: number, Results: TestInterfaces.TestResultParameterModel[]) => {
this.api.getResultParameters(project, runId, testCaseResultId, iterationId, paramName, (err: any, statusCode: number, Results: TestInterfaces.TestResultParameterModel[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2078,7 +2040,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestCaseResult[]>();
this.TestApi.getTestResultsByQuery(query, project, includeResultDetails, includeIterationDetails, skip, top, (err: any, statusCode: number, Result: TestInterfaces.TestCaseResult[]) => {
this.api.getTestResultsByQuery(query, project, includeResultDetails, includeIterationDetails, skip, top, (err: any, statusCode: number, Result: TestInterfaces.TestCaseResult[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2102,7 +2064,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestRunStatistic>();
this.TestApi.getTestRunStatistics(project, runId, (err: any, statusCode: number, Run: TestInterfaces.TestRunStatistic) => {
this.api.getTestRunStatistics(project, runId, (err: any, statusCode: number, Run: TestInterfaces.TestRunStatistic) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2132,7 +2094,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestRun[]>();
this.TestApi.getTestRunsByQuery(query, project, includeRunDetails, skip, top, (err: any, statusCode: number, Run: TestInterfaces.TestRun[]) => {
this.api.getTestRunsByQuery(query, project, includeRunDetails, skip, top, (err: any, statusCode: number, Run: TestInterfaces.TestRun[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2156,7 +2118,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestRun>();
this.TestApi.createTestRun(testRun, project, (err: any, statusCode: number, Run: TestInterfaces.TestRun) => {
this.api.createTestRun(testRun, project, (err: any, statusCode: number, Run: TestInterfaces.TestRun) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2180,7 +2142,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestRun>();
this.TestApi.getTestRunById(project, runId, (err: any, statusCode: number, Run: TestInterfaces.TestRun) => {
this.api.getTestRunById(project, runId, (err: any, statusCode: number, Run: TestInterfaces.TestRun) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2218,7 +2180,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestRun[]>();
this.TestApi.getTestRuns(project, buildUri, owner, tmiRunId, planId, includeRunDetails, automated, skip, top, (err: any, statusCode: number, Runs: TestInterfaces.TestRun[]) => {
this.api.getTestRuns(project, buildUri, owner, tmiRunId, planId, includeRunDetails, automated, skip, top, (err: any, statusCode: number, Runs: TestInterfaces.TestRun[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2244,7 +2206,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestRun>();
this.TestApi.updateTestRun(runUpdateModel, project, runId, (err: any, statusCode: number, Run: TestInterfaces.TestRun) => {
this.api.updateTestRun(runUpdateModel, project, runId, (err: any, statusCode: number, Run: TestInterfaces.TestRun) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2272,7 +2234,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.SuiteTestCase[]>();
this.TestApi.addTestCasesToSuite(project, planId, suiteId, testCaseIds, (err: any, statusCode: number, Suites: TestInterfaces.SuiteTestCase[]) => {
this.api.addTestCasesToSuite(project, planId, suiteId, testCaseIds, (err: any, statusCode: number, Suites: TestInterfaces.SuiteTestCase[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2300,7 +2262,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.SuiteTestCase>();
this.TestApi.getTestCaseById(project, planId, suiteId, testCaseIds, (err: any, statusCode: number, Suite: TestInterfaces.SuiteTestCase) => {
this.api.getTestCaseById(project, planId, suiteId, testCaseIds, (err: any, statusCode: number, Suite: TestInterfaces.SuiteTestCase) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2326,7 +2288,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.SuiteTestCase[]>();
this.TestApi.getTestCases(project, planId, suiteId, (err: any, statusCode: number, Suites: TestInterfaces.SuiteTestCase[]) => {
this.api.getTestCases(project, planId, suiteId, (err: any, statusCode: number, Suites: TestInterfaces.SuiteTestCase[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2354,7 +2316,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestSuite[]>();
this.TestApi.createTestSuite(testSuite, project, planId, suiteId, (err: any, statusCode: number, Suite: TestInterfaces.TestSuite[]) => {
this.api.createTestSuite(testSuite, project, planId, suiteId, (err: any, statusCode: number, Suite: TestInterfaces.TestSuite[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2382,7 +2344,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestSuite>();
this.TestApi.getTestSuiteById(project, planId, suiteId, includeChildSuites, (err: any, statusCode: number, Suite: TestInterfaces.TestSuite) => {
this.api.getTestSuiteById(project, planId, suiteId, includeChildSuites, (err: any, statusCode: number, Suite: TestInterfaces.TestSuite) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2412,7 +2374,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestSuite[]>();
this.TestApi.getTestSuitesForPlan(project, planId, includeSuites, skip, top, (err: any, statusCode: number, Suites: TestInterfaces.TestSuite[]) => {
this.api.getTestSuitesForPlan(project, planId, includeSuites, skip, top, (err: any, statusCode: number, Suites: TestInterfaces.TestSuite[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2440,7 +2402,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestSuite>();
this.TestApi.updateTestSuite(suiteUpdateModel, project, planId, suiteId, (err: any, statusCode: number, Suite: TestInterfaces.TestSuite) => {
this.api.updateTestSuite(suiteUpdateModel, project, planId, suiteId, (err: any, statusCode: number, Suite: TestInterfaces.TestSuite) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2462,7 +2424,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestSuite[]>();
this.TestApi.getSuitesByTestCaseId(testCaseId, (err: any, statusCode: number, Suites: TestInterfaces.TestSuite[]) => {
this.api.getSuitesByTestCaseId(testCaseId, (err: any, statusCode: number, Suites: TestInterfaces.TestSuite[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2486,7 +2448,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<number>();
this.TestApi.createTestSettings(testSettings, project, (err: any, statusCode: number, TestSetting: number) => {
this.api.createTestSettings(testSettings, project, (err: any, statusCode: number, TestSetting: number) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2510,7 +2472,7 @@ export class QTestApi implements IQTestApi {
var deferred = Q.defer<TestInterfaces.TestSettings>();
this.TestApi.getTestSettingsById(project, testSettingsId, (err: any, statusCode: number, TestSetting: TestInterfaces.TestSettings) => {
this.api.getTestSettingsById(project, testSettingsId, (err: any, statusCode: number, TestSetting: TestInterfaces.TestSettings) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

Просмотреть файл

@ -20,16 +20,11 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import TfvcInterfaces = require("./interfaces/TfvcInterfaces");
export interface ITfvcApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface ITfvcApi extends basem.ClientApiBase {
getBranch(path: string, project: string, includeParent: boolean, includeChildren: boolean, onResult: (err: any, statusCode: number, Branche: TfvcInterfaces.TfvcBranch) => void): void;
getBranches(project: string, includeParent: boolean, includeChildren: boolean, includeDeleted: boolean, includeLinks: boolean, onResult: (err: any, statusCode: number, Branches: TfvcInterfaces.TfvcBranch[]) => void): void;
getBranchRefs(scopePath: string, project: string, includeDeleted: boolean, includeLinks: boolean, onResult: (err: any, statusCode: number, Branches: TfvcInterfaces.TfvcBranchRef[]) => void): void;
@ -56,8 +51,7 @@ export interface ITfvcApi {
getShelvesetWorkItems(shelvesetId: string, onResult: (err: any, statusCode: number, ShelvesetWorkItems: TfvcInterfaces.AssociatedWorkItem[]) => void): void;
}
export interface IQTfvcApi {
connect(): Q.Promise<void>;
export interface IQTfvcApi extends basem.QClientApiBase {
getBranch(path: string, project?: string, includeParent?: boolean, includeChildren?: boolean): Q.Promise<TfvcInterfaces.TfvcBranch>;
getBranches(project?: string, includeParent?: boolean, includeChildren?: boolean, includeDeleted?: boolean, includeLinks?: boolean): Q.Promise<TfvcInterfaces.TfvcBranch[]>;
@ -82,27 +76,10 @@ export interface IQTfvcApi {
getShelvesetWorkItems( shelvesetId: string): Q.Promise<TfvcInterfaces.AssociatedWorkItem[]>;
}
export class TfvcApi implements ITfvcApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class TfvcApi extends basem.ClientApiBase implements ITfvcApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-Tfvc-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-Tfvc-api');
}
/**
@ -951,27 +928,12 @@ export class TfvcApi implements ITfvcApi {
}
export class QTfvcApi implements IQTfvcApi {
TfvcApi: ITfvcApi;
export class QTfvcApi extends basem.QClientApiBase implements IQTfvcApi {
api: TfvcApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.TfvcApi = new TfvcApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.TfvcApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, TfvcApi);
}
@ -992,7 +954,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcBranch>();
this.TfvcApi.getBranch(path, project, includeParent, includeChildren, (err: any, statusCode: number, Branche: TfvcInterfaces.TfvcBranch) => {
this.api.getBranch(path, project, includeParent, includeChildren, (err: any, statusCode: number, Branche: TfvcInterfaces.TfvcBranch) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1024,7 +986,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcBranch[]>();
this.TfvcApi.getBranches(project, includeParent, includeChildren, includeDeleted, includeLinks, (err: any, statusCode: number, Branches: TfvcInterfaces.TfvcBranch[]) => {
this.api.getBranches(project, includeParent, includeChildren, includeDeleted, includeLinks, (err: any, statusCode: number, Branches: TfvcInterfaces.TfvcBranch[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1054,7 +1016,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcBranchRef[]>();
this.TfvcApi.getBranchRefs(scopePath, project, includeDeleted, includeLinks, (err: any, statusCode: number, Branches: TfvcInterfaces.TfvcBranchRef[]) => {
this.api.getBranchRefs(scopePath, project, includeDeleted, includeLinks, (err: any, statusCode: number, Branches: TfvcInterfaces.TfvcBranchRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1082,7 +1044,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcChange[]>();
this.TfvcApi.getChangesetChanges(id, skip, top, (err: any, statusCode: number, ChangesetChanges: TfvcInterfaces.TfvcChange[]) => {
this.api.getChangesetChanges(id, skip, top, (err: any, statusCode: number, ChangesetChanges: TfvcInterfaces.TfvcChange[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1106,7 +1068,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcChangesetRef>();
this.TfvcApi.createChangeset(changeset, project, (err: any, statusCode: number, Changeset: TfvcInterfaces.TfvcChangesetRef) => {
this.api.createChangeset(changeset, project, (err: any, statusCode: number, Changeset: TfvcInterfaces.TfvcChangesetRef) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1150,7 +1112,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcChangeset>();
this.TfvcApi.getChangeset(id, project, maxChangeCount, includeDetails, includeWorkItems, maxCommentLength, includeSourceRename, skip, top, orderby, searchCriteria, (err: any, statusCode: number, Changeset: TfvcInterfaces.TfvcChangeset) => {
this.api.getChangeset(id, project, maxChangeCount, includeDetails, includeWorkItems, maxCommentLength, includeSourceRename, skip, top, orderby, searchCriteria, (err: any, statusCode: number, Changeset: TfvcInterfaces.TfvcChangeset) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1192,7 +1154,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcChangesetRef[]>();
this.TfvcApi.getChangesets(project, maxChangeCount, includeDetails, includeWorkItems, maxCommentLength, includeSourceRename, skip, top, orderby, searchCriteria, (err: any, statusCode: number, Changesets: TfvcInterfaces.TfvcChangesetRef[]) => {
this.api.getChangesets(project, maxChangeCount, includeDetails, includeWorkItems, maxCommentLength, includeSourceRename, skip, top, orderby, searchCriteria, (err: any, statusCode: number, Changesets: TfvcInterfaces.TfvcChangesetRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1214,7 +1176,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcChangesetRef[]>();
this.TfvcApi.getBatchedChangesets(changesetsRequestData, (err: any, statusCode: number, ChangesetsBatch: TfvcInterfaces.TfvcChangesetRef[]) => {
this.api.getBatchedChangesets(changesetsRequestData, (err: any, statusCode: number, ChangesetsBatch: TfvcInterfaces.TfvcChangesetRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1236,7 +1198,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.AssociatedWorkItem[]>();
this.TfvcApi.getChangesetWorkItems(id, (err: any, statusCode: number, ChangesetWorkItems: TfvcInterfaces.AssociatedWorkItem[]) => {
this.api.getChangesetWorkItems(id, (err: any, statusCode: number, ChangesetWorkItems: TfvcInterfaces.AssociatedWorkItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1262,7 +1224,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcItem[][]>();
this.TfvcApi.getItemsBatch(itemRequestData, project, (err: any, statusCode: number, ItemBatch: TfvcInterfaces.TfvcItem[][]) => {
this.api.getItemsBatch(itemRequestData, project, (err: any, statusCode: number, ItemBatch: TfvcInterfaces.TfvcItem[][]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1298,7 +1260,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcItem>();
this.TfvcApi.getItem(path, project, fileName, download, scopePath, recursionLevel, versionDescriptor, (err: any, statusCode: number, Item: TfvcInterfaces.TfvcItem) => {
this.api.getItem(path, project, fileName, download, scopePath, recursionLevel, versionDescriptor, (err: any, statusCode: number, Item: TfvcInterfaces.TfvcItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1330,7 +1292,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcItem[]>();
this.TfvcApi.getItems(project, scopePath, recursionLevel, includeLinks, versionDescriptor, (err: any, statusCode: number, Items: TfvcInterfaces.TfvcItem[]) => {
this.api.getItems(project, scopePath, recursionLevel, includeLinks, versionDescriptor, (err: any, statusCode: number, Items: TfvcInterfaces.TfvcItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1358,7 +1320,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcItem[]>();
this.TfvcApi.getLabelItems(labelId, top, skip, (err: any, statusCode: number, LabelItems: TfvcInterfaces.TfvcItem[]) => {
this.api.getLabelItems(labelId, top, skip, (err: any, statusCode: number, LabelItems: TfvcInterfaces.TfvcItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1386,7 +1348,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcLabel>();
this.TfvcApi.getLabel(labelId, requestData, project, (err: any, statusCode: number, Label: TfvcInterfaces.TfvcLabel) => {
this.api.getLabel(labelId, requestData, project, (err: any, statusCode: number, Label: TfvcInterfaces.TfvcLabel) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1416,7 +1378,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcLabelRef[]>();
this.TfvcApi.getLabels(requestData, project, top, skip, (err: any, statusCode: number, Labels: TfvcInterfaces.TfvcLabelRef[]) => {
this.api.getLabels(requestData, project, top, skip, (err: any, statusCode: number, Labels: TfvcInterfaces.TfvcLabelRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1442,7 +1404,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.VersionControlProjectInfo>();
this.TfvcApi.getProjectInfo(projectId, project, (err: any, statusCode: number, ProjectInfo: TfvcInterfaces.VersionControlProjectInfo) => {
this.api.getProjectInfo(projectId, project, (err: any, statusCode: number, ProjectInfo: TfvcInterfaces.VersionControlProjectInfo) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1464,7 +1426,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.VersionControlProjectInfo[]>();
this.TfvcApi.getProjectInfos(project, (err: any, statusCode: number, ProjectInfo: TfvcInterfaces.VersionControlProjectInfo[]) => {
this.api.getProjectInfos(project, (err: any, statusCode: number, ProjectInfo: TfvcInterfaces.VersionControlProjectInfo[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1492,7 +1454,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcChange[]>();
this.TfvcApi.getShelvesetChanges(shelvesetId, top, skip, (err: any, statusCode: number, ShelvesetChanges: TfvcInterfaces.TfvcChange[]) => {
this.api.getShelvesetChanges(shelvesetId, top, skip, (err: any, statusCode: number, ShelvesetChanges: TfvcInterfaces.TfvcChange[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1518,7 +1480,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcShelveset>();
this.TfvcApi.getShelveset(shelvesetId, requestData, (err: any, statusCode: number, Shelveset: TfvcInterfaces.TfvcShelveset) => {
this.api.getShelveset(shelvesetId, requestData, (err: any, statusCode: number, Shelveset: TfvcInterfaces.TfvcShelveset) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1546,7 +1508,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.TfvcShelvesetRef[]>();
this.TfvcApi.getShelvesets(requestData, top, skip, (err: any, statusCode: number, Shelvesets: TfvcInterfaces.TfvcShelvesetRef[]) => {
this.api.getShelvesets(requestData, top, skip, (err: any, statusCode: number, Shelvesets: TfvcInterfaces.TfvcShelvesetRef[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1570,7 +1532,7 @@ export class QTfvcApi implements IQTfvcApi {
var deferred = Q.defer<TfvcInterfaces.AssociatedWorkItem[]>();
this.TfvcApi.getShelvesetWorkItems(shelvesetId, (err: any, statusCode: number, ShelvesetWorkItems: TfvcInterfaces.AssociatedWorkItem[]) => {
this.api.getShelvesetWorkItems(shelvesetId, (err: any, statusCode: number, ShelvesetWorkItems: TfvcInterfaces.AssociatedWorkItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

121
src/api/WebApi.ts Normal file
Просмотреть файл

@ -0,0 +1,121 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import basem = require('./ClientApiBases');
import buildm = require('./BuildApi');
import corem = require('./CoreApi');
import filecontainerm = require('./FileContainerApi');
import gitm = require('./GitApi');
import taskagentm = require('./TaskAgentApi');
import taskm = require('./TaskApi');
import testm = require('./TestApi');
import tfvcm = require('./TfvcApi');
import workitemtrackingm = require('./WorkItemTrackingApi');
import apivm = require('./handlers/apiversion');
import basicm = require('./handlers/basiccreds');
import bearm = require('./handlers/bearertoken');
// ---------------------------------------------------------------------------
// factory to return client apis
//----------------------------------------------------------------------------
export class WebApi {
serverUrl: string;
authHandler: VsoBaseInterfaces.IRequestHandler;
/*
* Factory to return client apis
* @param defaultServerUrl default server url to use when creating new apis from factory methods
* @param defaultAuthHandler default authentication credentials to use when creating new apis from factory methods
*/
constructor(serverUrl: string, authHandler: VsoBaseInterfaces.IRequestHandler) {
this.serverUrl = serverUrl;
this.authHandler = authHandler;
}
public getVersionHandler(apiVersion: string) {
return new apivm.ApiVersionHandler(apiVersion);
}
public getBasicHandler(username: string, password: string) {
return new basicm.BasicCredentialHandler(username, password);
}
public getBearerHandler(token) {
return new bearm.BearerCredentialHandler(token);
}
public getBuildApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): buildm.IBuildApi {
return new buildm.BuildApi(serverUrl, handlers);
}
public getQBuildApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): buildm.IQBuildApi {
return new buildm.QBuildApi(serverUrl, handlers);
}
public getCoreApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): corem.ICoreApi {
return new corem.CoreApi(serverUrl, handlers);
}
public getQCoreApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): corem.IQCoreApi {
return new corem.QCoreApi(serverUrl, handlers);
}
public getFileContainerApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): filecontainerm.IFileContainerApi {
return new filecontainerm.FileContainerApi(serverUrl, handlers);
}
public getQFileContainerApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): filecontainerm.IQFileContainerApi {
return new filecontainerm.QFileContainerApi(serverUrl, handlers);
}
public getGitApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): gitm.IGitApi {
return new gitm.GitApi(serverUrl, handlers);
}
public getQGitApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): gitm.IQGitApi {
return new gitm.QGitApi(serverUrl, handlers);
}
public getTaskApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): taskm.ITaskApi {
return new taskm.TaskApi(serverUrl, handlers);
}
public getQTaskApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): taskm.IQTaskApi {
return new taskm.QTaskApi(serverUrl, handlers);
}
public getTaskAgentApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): taskagentm.ITaskAgentApi {
return new taskagentm.TaskAgentApi(serverUrl, handlers);
}
public getQTaskAgentApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): taskagentm.IQTaskAgentApi {
return new taskagentm.QTaskAgentApi(serverUrl, handlers);
}
public getTestApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): testm.ITestApi {
return new testm.TestApi(serverUrl, handlers);
}
public getQTestApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): testm.IQTestApi {
return new testm.QTestApi(serverUrl, handlers);
}
public getTfvcApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): tfvcm.ITfvcApi {
return new tfvcm.TfvcApi(serverUrl, handlers);
}
public getQTfvcApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): tfvcm.IQTfvcApi {
return new tfvcm.QTfvcApi(serverUrl, handlers);
}
public getWorkItemTrackingApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): workitemtrackingm.IWorkItemTrackingApi {
return new workitemtrackingm.WorkItemTrackingApi(serverUrl, handlers);
}
public getQWorkItemTrackingApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): workitemtrackingm.IQWorkItemTrackingApi {
return new workitemtrackingm.QWorkItemTrackingApi(serverUrl, handlers);
}
}

Просмотреть файл

@ -20,17 +20,12 @@ import Q = require('q');
import restm = require('./restclient');
import httpm = require('./httpclient');
import vsom = require('./VsoClient');
import basem = require('./ClientApiBases');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import VSSInterfaces = require("./interfaces/common/VSSInterfaces");
import WorkItemTrackingInterfaces = require("./interfaces/WorkItemTrackingInterfaces");
export interface IWorkItemTrackingApi {
baseUrl: string;
userAgent: string;
httpClient: VsoBaseInterfaces.IHttpClient;
restClient: VsoBaseInterfaces.IRestClient;
vsoClient: vsom.VsoClient;
connect(onResult: (err: any, statusCode: number, obj: any) => void): void;
export interface IWorkItemTrackingApi extends basem.ClientApiBase {
createAttachment(contentStream: NodeJS.ReadableStream, customHeaders: any, content: string, fileName: string, uploadType: string, onResult: (err: any, statusCode: number, attachment: WorkItemTrackingInterfaces.AttachmentReference) => void): void;
getAttachmentContent(id: string, fileName: string, onResult: (err: any, statusCode: number, res: NodeJS.ReadableStream) => void): void;
getAttachmentZip(id: string, fileName: string, onResult: (err: any, statusCode: number, res: NodeJS.ReadableStream) => void): void;
@ -74,8 +69,7 @@ export interface IWorkItemTrackingApi {
updateWorkItemTypeDefinition(updateModel: WorkItemTrackingInterfaces.WorkItemTypeTemplateUpdateModel, project: string, onResult: (err: any, statusCode: number, workItemTypeTemplate: WorkItemTrackingInterfaces.ProvisioningResult) => void): void;
}
export interface IQWorkItemTrackingApi {
connect(): Q.Promise<void>;
export interface IQWorkItemTrackingApi extends basem.QClientApiBase {
createAttachment(contentStream: NodeJS.ReadableStream, customHeaders: any, content: string, fileName?: string, uploadType?: string): Q.Promise<WorkItemTrackingInterfaces.AttachmentReference>;
getRootNodes(project: string, depth?: number): Q.Promise<WorkItemTrackingInterfaces.WorkItemClassificationNode[]>;
@ -115,27 +109,10 @@ export interface IQWorkItemTrackingApi {
updateWorkItemTypeDefinition(updateModel: WorkItemTrackingInterfaces.WorkItemTypeTemplateUpdateModel, project?: string): Q.Promise<WorkItemTrackingInterfaces.ProvisioningResult>;
}
export class WorkItemTrackingApi implements IWorkItemTrackingApi {
baseUrl: string;
userAgent: string;
httpClient: httpm.HttpClient;
restClient: restm.RestClient;
vsoClient: vsom.VsoClient
export class WorkItemTrackingApi extends basem.ClientApiBase implements IWorkItemTrackingApi {
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.baseUrl = baseUrl;
this.httpClient = new httpm.HttpClient('node-WorkItemTracking-api', handlers);
this.restClient = new restm.RestClient(this.httpClient);
this.vsoClient = new vsom.VsoClient(baseUrl, this.restClient);
}
setUserAgent(userAgent: string) {
this.userAgent = userAgent;
this.httpClient.userAgent = userAgent;
}
connect(onResult: (err: any, statusCode: number, obj: any) => void): void {
this.restClient.getJson(this.vsoClient.resolveUrl('/_apis/connectionData'), "", null, onResult);
super(baseUrl, handlers, 'node-WorkItemTracking-api');
}
/**
@ -1357,27 +1334,12 @@ export class WorkItemTrackingApi implements IWorkItemTrackingApi {
}
export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
WorkItemTrackingApi: IWorkItemTrackingApi;
export class QWorkItemTrackingApi extends basem.QClientApiBase implements IQWorkItemTrackingApi {
api: WorkItemTrackingApi;
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[]) {
this.WorkItemTrackingApi = new WorkItemTrackingApi(baseUrl, handlers);
}
public connect(): Q.Promise<any> {
var defer = Q.defer();
this.WorkItemTrackingApi.connect((err: any, statusCode: number, obj: any) => {
if (err) {
err.statusCode = statusCode;
defer.reject(err);
}
else {
defer.resolve(obj);
}
});
return defer.promise;
super(baseUrl, handlers, WorkItemTrackingApi);
}
@ -1398,7 +1360,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.AttachmentReference>();
this.WorkItemTrackingApi.createAttachment(contentStream, customHeaders, content, fileName, uploadType, (err: any, statusCode: number, attachment: WorkItemTrackingInterfaces.AttachmentReference) => {
this.api.createAttachment(contentStream, customHeaders, content, fileName, uploadType, (err: any, statusCode: number, attachment: WorkItemTrackingInterfaces.AttachmentReference) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1422,7 +1384,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemClassificationNode[]>();
this.WorkItemTrackingApi.getRootNodes(project, depth, (err: any, statusCode: number, classificationNodes: WorkItemTrackingInterfaces.WorkItemClassificationNode[]) => {
this.api.getRootNodes(project, depth, (err: any, statusCode: number, classificationNodes: WorkItemTrackingInterfaces.WorkItemClassificationNode[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1450,7 +1412,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemClassificationNode>();
this.WorkItemTrackingApi.createOrUpdateClassificationNode(postedNode, project, structureGroup, path, (err: any, statusCode: number, classificationNode: WorkItemTrackingInterfaces.WorkItemClassificationNode) => {
this.api.createOrUpdateClassificationNode(postedNode, project, structureGroup, path, (err: any, statusCode: number, classificationNode: WorkItemTrackingInterfaces.WorkItemClassificationNode) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1478,7 +1440,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemClassificationNode>();
this.WorkItemTrackingApi.getClassificationNode(project, structureGroup, path, depth, (err: any, statusCode: number, classificationNode: WorkItemTrackingInterfaces.WorkItemClassificationNode) => {
this.api.getClassificationNode(project, structureGroup, path, depth, (err: any, statusCode: number, classificationNode: WorkItemTrackingInterfaces.WorkItemClassificationNode) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1506,7 +1468,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemClassificationNode>();
this.WorkItemTrackingApi.updateClassificationNode(postedNode, project, structureGroup, path, (err: any, statusCode: number, classificationNode: WorkItemTrackingInterfaces.WorkItemClassificationNode) => {
this.api.updateClassificationNode(postedNode, project, structureGroup, path, (err: any, statusCode: number, classificationNode: WorkItemTrackingInterfaces.WorkItemClassificationNode) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1528,7 +1490,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemField>();
this.WorkItemTrackingApi.getField(field, (err: any, statusCode: number, field: WorkItemTrackingInterfaces.WorkItemField) => {
this.api.getField(field, (err: any, statusCode: number, field: WorkItemTrackingInterfaces.WorkItemField) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1548,7 +1510,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemField[]>();
this.WorkItemTrackingApi.getFields((err: any, statusCode: number, fields: WorkItemTrackingInterfaces.WorkItemField[]) => {
this.api.getFields((err: any, statusCode: number, fields: WorkItemTrackingInterfaces.WorkItemField[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1576,7 +1538,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemHistory[]>();
this.WorkItemTrackingApi.getHistory(id, top, skip, (err: any, statusCode: number, history: WorkItemTrackingInterfaces.WorkItemHistory[]) => {
this.api.getHistory(id, top, skip, (err: any, statusCode: number, history: WorkItemTrackingInterfaces.WorkItemHistory[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1602,7 +1564,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemHistory>();
this.WorkItemTrackingApi.getHistoryById(id, revisionNumber, (err: any, statusCode: number, history: WorkItemTrackingInterfaces.WorkItemHistory) => {
this.api.getHistoryById(id, revisionNumber, (err: any, statusCode: number, history: WorkItemTrackingInterfaces.WorkItemHistory) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1630,7 +1592,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.QueryHierarchyItem>();
this.WorkItemTrackingApi.createQuery(postedQuery, project, query, (err: any, statusCode: number, querie: WorkItemTrackingInterfaces.QueryHierarchyItem) => {
this.api.createQuery(postedQuery, project, query, (err: any, statusCode: number, querie: WorkItemTrackingInterfaces.QueryHierarchyItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1660,7 +1622,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.QueryHierarchyItem[]>();
this.WorkItemTrackingApi.getQueries(project, expand, depth, includeDeleted, (err: any, statusCode: number, queries: WorkItemTrackingInterfaces.QueryHierarchyItem[]) => {
this.api.getQueries(project, expand, depth, includeDeleted, (err: any, statusCode: number, queries: WorkItemTrackingInterfaces.QueryHierarchyItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1692,7 +1654,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.QueryHierarchyItem>();
this.WorkItemTrackingApi.getQuery(project, query, expand, depth, includeDeleted, (err: any, statusCode: number, querie: WorkItemTrackingInterfaces.QueryHierarchyItem) => {
this.api.getQuery(project, query, expand, depth, includeDeleted, (err: any, statusCode: number, querie: WorkItemTrackingInterfaces.QueryHierarchyItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1720,7 +1682,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.QueryHierarchyItem>();
this.WorkItemTrackingApi.updateQuery(queryUpdate, project, query, undeleteDescendants, (err: any, statusCode: number, querie: WorkItemTrackingInterfaces.QueryHierarchyItem) => {
this.api.updateQuery(queryUpdate, project, query, undeleteDescendants, (err: any, statusCode: number, querie: WorkItemTrackingInterfaces.QueryHierarchyItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1748,7 +1710,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItem>();
this.WorkItemTrackingApi.getRevision(id, revisionNumber, expand, (err: any, statusCode: number, revision: WorkItemTrackingInterfaces.WorkItem) => {
this.api.getRevision(id, revisionNumber, expand, (err: any, statusCode: number, revision: WorkItemTrackingInterfaces.WorkItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1778,7 +1740,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItem[]>();
this.WorkItemTrackingApi.getRevisions(id, top, skip, expand, (err: any, statusCode: number, revisions: WorkItemTrackingInterfaces.WorkItem[]) => {
this.api.getRevisions(id, top, skip, expand, (err: any, statusCode: number, revisions: WorkItemTrackingInterfaces.WorkItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1804,7 +1766,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemUpdate>();
this.WorkItemTrackingApi.getUpdate(id, updateNumber, (err: any, statusCode: number, update: WorkItemTrackingInterfaces.WorkItemUpdate) => {
this.api.getUpdate(id, updateNumber, (err: any, statusCode: number, update: WorkItemTrackingInterfaces.WorkItemUpdate) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1832,7 +1794,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemUpdate[]>();
this.WorkItemTrackingApi.getUpdates(id, top, skip, (err: any, statusCode: number, updates: WorkItemTrackingInterfaces.WorkItemUpdate[]) => {
this.api.getUpdates(id, top, skip, (err: any, statusCode: number, updates: WorkItemTrackingInterfaces.WorkItemUpdate[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1858,7 +1820,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemQueryResult>();
this.WorkItemTrackingApi.queryByWiql(wiql, project, (err: any, statusCode: number, wiql: WorkItemTrackingInterfaces.WorkItemQueryResult) => {
this.api.queryByWiql(wiql, project, (err: any, statusCode: number, wiql: WorkItemTrackingInterfaces.WorkItemQueryResult) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1884,7 +1846,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemQueryResult>();
this.WorkItemTrackingApi.queryById(id, project, (err: any, statusCode: number, wiql: WorkItemTrackingInterfaces.WorkItemQueryResult) => {
this.api.queryById(id, project, (err: any, statusCode: number, wiql: WorkItemTrackingInterfaces.WorkItemQueryResult) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1908,7 +1870,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.ReportingWorkItemLinksBatch>();
this.WorkItemTrackingApi.getReportingLinks(project, watermark, (err: any, statusCode: number, workItemLink: WorkItemTrackingInterfaces.ReportingWorkItemLinksBatch) => {
this.api.getReportingLinks(project, watermark, (err: any, statusCode: number, workItemLink: WorkItemTrackingInterfaces.ReportingWorkItemLinksBatch) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1932,7 +1894,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemRelationType>();
this.WorkItemTrackingApi.getRelationType(relation, (err: any, statusCode: number, workItemRelationType: WorkItemTrackingInterfaces.WorkItemRelationType) => {
this.api.getRelationType(relation, (err: any, statusCode: number, workItemRelationType: WorkItemTrackingInterfaces.WorkItemRelationType) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1952,7 +1914,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemRelationType[]>();
this.WorkItemTrackingApi.getRelationTypes((err: any, statusCode: number, workItemRelationTypes: WorkItemTrackingInterfaces.WorkItemRelationType[]) => {
this.api.getRelationTypes((err: any, statusCode: number, workItemRelationTypes: WorkItemTrackingInterfaces.WorkItemRelationType[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -1978,7 +1940,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.ReportingWorkItemRevisionsBatch>();
this.WorkItemTrackingApi.readReportingRevisionsGet(project, fields, watermark, (err: any, statusCode: number, workItemRevision: WorkItemTrackingInterfaces.ReportingWorkItemRevisionsBatch) => {
this.api.readReportingRevisionsGet(project, fields, watermark, (err: any, statusCode: number, workItemRevision: WorkItemTrackingInterfaces.ReportingWorkItemRevisionsBatch) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2004,7 +1966,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.ReportingWorkItemRevisionsBatch>();
this.WorkItemTrackingApi.readReportingRevisionsPost(fieldsList, project, watermark, (err: any, statusCode: number, workItemRevision: WorkItemTrackingInterfaces.ReportingWorkItemRevisionsBatch) => {
this.api.readReportingRevisionsPost(fieldsList, project, watermark, (err: any, statusCode: number, workItemRevision: WorkItemTrackingInterfaces.ReportingWorkItemRevisionsBatch) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2034,7 +1996,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItem>();
this.WorkItemTrackingApi.getWorkItem(id, fields, asOf, expand, (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => {
this.api.getWorkItem(id, fields, asOf, expand, (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2064,7 +2026,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItem[]>();
this.WorkItemTrackingApi.getWorkItems(ids, fields, asOf, expand, (err: any, statusCode: number, workItems: WorkItemTrackingInterfaces.WorkItem[]) => {
this.api.getWorkItems(ids, fields, asOf, expand, (err: any, statusCode: number, workItems: WorkItemTrackingInterfaces.WorkItem[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2092,7 +2054,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItem>();
this.WorkItemTrackingApi.updateWorkItem(document, id, validateOnly, bypassRules, (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => {
this.api.updateWorkItem(document, id, validateOnly, bypassRules, (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2124,7 +2086,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItem>();
this.WorkItemTrackingApi.getWorkItemTemplate(project, type, fields, asOf, expand, (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => {
this.api.getWorkItemTemplate(project, type, fields, asOf, expand, (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2154,7 +2116,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItem>();
this.WorkItemTrackingApi.updateWorkItemTemplate(document, project, type, validateOnly, bypassRules, (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => {
this.api.updateWorkItemTemplate(document, project, type, validateOnly, bypassRules, (err: any, statusCode: number, workItem: WorkItemTrackingInterfaces.WorkItem) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2176,7 +2138,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemTypeCategory[]>();
this.WorkItemTrackingApi.getWorkItemTypeCategories(project, (err: any, statusCode: number, workItemTypeCategories: WorkItemTrackingInterfaces.WorkItemTypeCategory[]) => {
this.api.getWorkItemTypeCategories(project, (err: any, statusCode: number, workItemTypeCategories: WorkItemTrackingInterfaces.WorkItemTypeCategory[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2202,7 +2164,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemTypeCategory>();
this.WorkItemTrackingApi.getWorkItemTypeCategory(project, category, (err: any, statusCode: number, workItemTypeCategorie: WorkItemTrackingInterfaces.WorkItemTypeCategory) => {
this.api.getWorkItemTypeCategory(project, category, (err: any, statusCode: number, workItemTypeCategorie: WorkItemTrackingInterfaces.WorkItemTypeCategory) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2228,7 +2190,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemType>();
this.WorkItemTrackingApi.getWorkItemType(project, type, (err: any, statusCode: number, workItemType: WorkItemTrackingInterfaces.WorkItemType) => {
this.api.getWorkItemType(project, type, (err: any, statusCode: number, workItemType: WorkItemTrackingInterfaces.WorkItemType) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2250,7 +2212,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemType[]>();
this.WorkItemTrackingApi.getWorkItemTypes(project, (err: any, statusCode: number, workItemTypes: WorkItemTrackingInterfaces.WorkItemType[]) => {
this.api.getWorkItemTypes(project, (err: any, statusCode: number, workItemTypes: WorkItemTrackingInterfaces.WorkItemType[]) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2278,7 +2240,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.FieldDependentRule>();
this.WorkItemTrackingApi.getDependentFields(project, type, field, (err: any, statusCode: number, workItemTypesField: WorkItemTrackingInterfaces.FieldDependentRule) => {
this.api.getDependentFields(project, type, field, (err: any, statusCode: number, workItemTypesField: WorkItemTrackingInterfaces.FieldDependentRule) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2306,7 +2268,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.WorkItemTypeTemplate>();
this.WorkItemTrackingApi.exportWorkItemTypeDefinition(project, type, exportGlobalLists, (err: any, statusCode: number, workItemTypeTemplate: WorkItemTrackingInterfaces.WorkItemTypeTemplate) => {
this.api.exportWorkItemTypeDefinition(project, type, exportGlobalLists, (err: any, statusCode: number, workItemTypeTemplate: WorkItemTrackingInterfaces.WorkItemTypeTemplate) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);
@ -2332,7 +2294,7 @@ export class QWorkItemTrackingApi implements IQWorkItemTrackingApi {
var deferred = Q.defer<WorkItemTrackingInterfaces.ProvisioningResult>();
this.WorkItemTrackingApi.updateWorkItemTypeDefinition(updateModel, project, (err: any, statusCode: number, workItemTypeTemplate: WorkItemTrackingInterfaces.ProvisioningResult) => {
this.api.updateWorkItemTypeDefinition(updateModel, project, (err: any, statusCode: number, workItemTypeTemplate: WorkItemTrackingInterfaces.ProvisioningResult) => {
if(err) {
err.statusCode = statusCode;
deferred.reject(err);

Просмотреть файл

@ -0,0 +1,22 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/// <reference path="../definitions/node.d.ts"/>
import VsoBaseInterfaces = require('../interfaces/common/VsoBaseInterfaces');
export class ApiVersionHandler implements VsoBaseInterfaces.IRequestHandler {
apiVersion: string;
constructor(apiVersion: string) {
this.apiVersion = apiVersion;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest(options:any): void {
if (options.headers && options.headers['Accept']) {
options.headers["Accept"] = options.headers['Accept'] + '; api-version=' + this.apiVersion;
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/// <reference path="../definitions/node.d.ts"/>
import VsoBaseInterfaces = require('../interfaces/common/VsoBaseInterfaces');
export class BasicCredentialHandler implements VsoBaseInterfaces.IRequestHandler {
username: string;
password: string;
constructor(username: string, password: string) {
this.username = username;
this.password = password;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest(options:any): void {
options.headers['Authorization'] = 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64');
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
}
}

Просмотреть файл

@ -0,0 +1,21 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/// <reference path="../definitions/node.d.ts"/>
import VsoBaseInterfaces = require('../interfaces/common/VsoBaseInterfaces');
export class BearerCredentialHandler implements VsoBaseInterfaces.IRequestHandler {
token: string;
constructor(token: string) {
this.token = token;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest(options:any): void {
options.headers['Authorization'] = 'Bearer ' + this.token;
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
}
}

Просмотреть файл

@ -59,6 +59,10 @@ export interface IHttpResponse {
headers: any;
}
export interface IQCoreApi {
connect(): Q.Promise<void>;
}
export interface IHttpClient {
get(verb: string, requestUrl: string, headers: any, onResult: (err: any, res: IHttpResponse, contents: string) => void): void;
send(verb: string, requestUrl: string, objs: any, headers: any, onResult: (err: any, res: IHttpResponse, contents: string) => void): void;

Просмотреть файл

@ -11,14 +11,14 @@ describe('Dummy test', function () {
})
// TODO: fix tests below to work with newest clients and structure
// //TODO: fix tests below to work with newest clients and structure
//import agentifm = require('./interfaces/TaskAgentInterfaces');
//import buildifm = require('./interfaces/BuildInterfaces');
//import agentm = require('./TaskAgentApi');
//import buildm = require('./BuildApi');
//import taskm = require('./TaskApi');
//import restm = require('./RestClient');
//import agentifm = require('../api/interfaces/TaskAgentInterfaces');
//import buildifm = require('../api/interfaces/BuildInterfaces');
//import agentm = require('../api/TaskAgentApi');
//import buildm = require('../api/BuildApi');
//import taskm = require('../api/TaskApi');
//import restm = require('../api/RestClient');
//import httpm = require('./httpclient');
//import assert = require('assert');
//import Q = require('q');
@ -28,6 +28,49 @@ describe('Dummy test', function () {
//var httpClient = new httpm.HttpClient("TestUser")
//var restClient = new restm.RestClient("", httpClient);
////TODO: change to testserver before committing
//var TaskAgentApi = new agentm.TaskAgentApi("https://tedward.tfsbuildhost8.tfsallin.net/", []);
//it("TaskAgent tests", function () {
// //TaskAgentApi.connect();
// assert.notEqual(TaskAgentApi, null, "create an agent api");
// var agent = new DummyTaskAgent(1, "myagent", "1.0");
// //#createAgent
// var testagent;
// var createAgentOnResult = function (err: any, statusCode: number, retagent: agentifm.TaskAgent) {
// testagent = <DummyTaskAgent>retagent;
// };
// TaskAgentApi.createAgent(agent, 42, createAgentOnResult);
// //normally the following tests would have to be in onresult, but we're not actually making async calls
// assert.equal(testagent.id, 1, "createAgent agent remains the same - id test");
// assert.equal(testagent.name, "myagent", "createAgent agent remains the same - name test");
// assert.equal(testagent.version, "1.0", "createAgent agent remains the same - version test");
// assert.equal(testagent.verb, "POST", "createAgent calls correct Http Method -- POST");
// assert.equal(testagent.relativeUrl, "_apis/distributedtask/pools/42/agents", "createAgent route template formats correctly and is sent correctly");
// //#deleteAgent
// var retStatusCode;
// var deleteAgentOnResult = function (err: any, statusCode: number) {
// retStatusCode = statusCode;
// };
// TaskAgentApi.deleteAgent(42, 1, deleteAgentOnResult);
// assert.equal(retStatusCode, 200, "deleteAgent went through");
// var deleteAgentRouteValues = {
// poolId: 42,
// agentId: 1,
// area: "distributedtask",
// resource: "agents"
// };
// var path: string = restClient.formatRouteTemplate("_apis/{area}/pools/{poolId}/{resource}/{agentId}", deleteAgentRouteValues);
// assert.equal(path, "_apis/distributedtask/pools/42/agents/1", "deleteAgent route template formats correctly");
//}
//export class DummyTaskAgent implements agentifm.TaskAgent {
// id: number;
// name: string;