UNPKG

vso-node-api

Version:

Node client for Visual Studio Online/TFS REST APIs

1,086 lines 98.3 kB
"use strict"; /* * --------------------------------------------------------- * Copyright(C) Microsoft Corporation. All rights reserved. * --------------------------------------------------------- * * --------------------------------------------------------- * Generated file, DO NOT EDIT * --------------------------------------------------------- */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const basem = require("./ClientApiBases"); const WorkItemTrackingInterfaces = require("./interfaces/WorkItemTrackingInterfaces"); class WorkItemTrackingApi extends basem.ClientApiBase { constructor(baseUrl, handlers, options) { super(baseUrl, handlers, 'node-WorkItemTracking-api', options); } /** * INTERNAL ONLY: USED BY ACCOUNT MY WORK PAGE. This returns Doing, Done, Follows and activity work items details. * * @param {WorkItemTrackingInterfaces.QueryOption} queryOption */ getAccountMyWorkData(queryOption) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = {}; let queryValues = { '$queryOption': queryOption, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "def3d688-ddf5-4096-9024-69beea15cdbd", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.AccountMyWorkResult, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * INTERNAL ONLY: USED BY ACCOUNT MY WORK PAGE. This returns Doing, Done, Follows and activity work items details. * */ getRecentActivityData() { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = {}; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "1bc988f4-c15f-4072-ad35-497c87e3a909", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.AccountRecentActivityWorkItemModel, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * INTERNAL ONLY: USED BY ACCOUNT MY WORK PAGE. * */ getRecentMentions() { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = {}; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "d60eeb6e-e18c-4478-9e94-a0094e28f41c", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.AccountRecentMentionWorkItemModel, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Get the list of work item tracking outbound artifact link types. * */ getWorkArtifactLinkTypes() { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = {}; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "1a31de40-e318-41cd-a6c6-881077df52e3", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, null, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Queries work items linked to a given list of artifact URI. * * @param {WorkItemTrackingInterfaces.ArtifactUriQuery} artifactUriQuery - Defines a list of artifact URI for querying work items. */ queryWorkItemsForArtifactUris(artifactUriQuery) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = {}; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "a9a9aa7a-8c09-44d3-ad1b-46e855c1e3d3", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, artifactUriQuery, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Uploads an attachment. * * @param {NodeJS.ReadableStream} contentStream - Content to upload * @param {string} fileName - The name of the file * @param {string} uploadType - Attachment upload type: Simple or Chunked * @param {string} areaPath - Target project Area Path */ createAttachment(customHeaders, contentStream, fileName, uploadType, areaPath) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = {}; let queryValues = { fileName: fileName, uploadType: uploadType, areaPath: areaPath, }; customHeaders = customHeaders || {}; customHeaders["Content-Type"] = "application/octet-stream"; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "e07b5fa4-1499-494d-a496-64b860fd64ff", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); options.additionalHeaders = customHeaders; let res; res = yield this.rest.uploadStream("POST", url, contentStream, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Downloads an attachment. * * @param {string} id - Attachment ID * @param {string} fileName - Name of the file */ getAttachmentContent(id, fileName) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { id: id }; let queryValues = { fileName: fileName, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "e07b5fa4-1499-494d-a496-64b860fd64ff", routeValues, queryValues); let url = verData.requestUrl; let apiVersion = verData.apiVersion; let accept = this.createAcceptHeader("application/octet-stream", apiVersion); resolve((yield this.http.get(url, { "Accept": accept })).message); } catch (err) { reject(err); } })); }); } /** * Downloads an attachment. * * @param {string} id - Attachment ID * @param {string} fileName - Name of the file */ getAttachmentZip(id, fileName) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { id: id }; let queryValues = { fileName: fileName, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "e07b5fa4-1499-494d-a496-64b860fd64ff", routeValues, queryValues); let url = verData.requestUrl; let apiVersion = verData.apiVersion; let accept = this.createAcceptHeader("application/zip", apiVersion); resolve((yield this.http.get(url, { "Accept": accept })).message); } catch (err) { reject(err); } })); }); } /** * Gets root classification nodes under the project. * * @param {string} project - Project ID or project name * @param {number} depth - Depth of children to fetch. */ getRootNodes(project, depth) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project }; let queryValues = { '$depth': depth, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a70579d1-f53a-48ee-a5be-7be8659023b9", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.WorkItemClassificationNode, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Create new or update an existing classification node. * * @param {WorkItemTrackingInterfaces.WorkItemClassificationNode} postedNode - Node to create or update. * @param {string} project - Project ID or project name * @param {WorkItemTrackingInterfaces.TreeStructureGroup} structureGroup - Structure group of the classification node, area or iteration. * @param {string} path - Path of the classification node. */ createOrUpdateClassificationNode(postedNode, project, structureGroup, path) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, structureGroup: structureGroup, path: path }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "5a172953-1b41-49d3-840a-33f79c3ce89f", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, postedNode, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.WorkItemClassificationNode, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Delete an existing classification node. * * @param {string} project - Project ID or project name * @param {WorkItemTrackingInterfaces.TreeStructureGroup} structureGroup - Structure group of the classification node, area or iteration. * @param {string} path - Path of the classification node. * @param {number} reclassifyId - Id of the target classification node for reclassification. */ deleteClassificationNode(project, structureGroup, path, reclassifyId) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, structureGroup: structureGroup, path: path }; let queryValues = { '$reclassifyId': reclassifyId, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "5a172953-1b41-49d3-840a-33f79c3ce89f", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.del(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets the classification node for a given node path. * * @param {string} project - Project ID or project name * @param {WorkItemTrackingInterfaces.TreeStructureGroup} structureGroup - Structure group of the classification node, area or iteration. * @param {string} path - Path of the classification node. * @param {number} depth - Depth of children to fetch. */ getClassificationNode(project, structureGroup, path, depth) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, structureGroup: structureGroup, path: path }; let queryValues = { '$depth': depth, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "5a172953-1b41-49d3-840a-33f79c3ce89f", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.WorkItemClassificationNode, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Update an existing classification node. * * @param {WorkItemTrackingInterfaces.WorkItemClassificationNode} postedNode - Node to create or update. * @param {string} project - Project ID or project name * @param {WorkItemTrackingInterfaces.TreeStructureGroup} structureGroup - Structure group of the classification node, area or iteration. * @param {string} path - Path of the classification node. */ updateClassificationNode(postedNode, project, structureGroup, path) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, structureGroup: structureGroup, path: path }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "5a172953-1b41-49d3-840a-33f79c3ce89f", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.update(url, postedNode, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.WorkItemClassificationNode, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets a comment for a work item at the specified revision. * * @param {number} id - Work item id * @param {number} revision - Revision for which the comment need to be fetched */ getComment(id, revision) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { id: id, revision: revision }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "19335ae7-22f7-4308-93d8-261f9384b7cf", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.WorkItemComment, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets the specified number of comments for a work item from the specified revision. * * @param {number} id - Work item id * @param {number} fromRevision - Revision from which comments are to be fetched * @param {number} top - The number of comments to return * @param {WorkItemTrackingInterfaces.CommentSortOrder} order - Ascending or descending by revision id */ getComments(id, fromRevision, top, order) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { id: id }; let queryValues = { fromRevision: fromRevision, '$top': top, order: order, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "19335ae7-22f7-4308-93d8-261f9384b7cf", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.WorkItemComments, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Deletes the field. * * @param {string} fieldNameOrRefName - Field simple name or reference name * @param {string} project - Project ID or project name */ deleteField(fieldNameOrRefName, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, fieldNameOrRefName: fieldNameOrRefName }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.del(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets information on a specific field. * * @param {string} fieldNameOrRefName - Field simple name or reference name * @param {string} project - Project ID or project name */ getField(fieldNameOrRefName, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, fieldNameOrRefName: fieldNameOrRefName }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.WorkItemField, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Returns information for all fields. * * @param {string} project - Project ID or project name * @param {WorkItemTrackingInterfaces.GetFieldsExpand} expand - Use ExtensionFields to include extension fields, otherwise exclude them. Unless the feature flag for this parameter is enabled, extension fields are always included. */ getFields(project, expand) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project }; let queryValues = { '$expand': expand, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.WorkItemField, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Updates the field. * * @param {WorkItemTrackingInterfaces.WorkItemField} workItemField - New field definition * @param {string} fieldNameOrRefName - Field simple name or reference name * @param {string} project - Project ID or project name */ updateField(workItemField, fieldNameOrRefName, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, fieldNameOrRefName: fieldNameOrRefName }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.update(url, workItemField, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Creates a query, or moves a query. * * @param {WorkItemTrackingInterfaces.QueryHierarchyItem} postedQuery - The query to create. * @param {string} project - Project ID or project name * @param {string} query - The parent path for the query to create. */ createQuery(postedQuery, project, query) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, query: query }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a67d190c-c41f-424b-814d-0e906f659301", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, postedQuery, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.QueryHierarchyItem, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Delete a query or a folder * * @param {string} project - Project ID or project name * @param {string} query - ID or path of the query or folder to delete. */ deleteQuery(project, query) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, query: query }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a67d190c-c41f-424b-814d-0e906f659301", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.del(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets the root queries and their children * * @param {string} project - Project ID or project name * @param {WorkItemTrackingInterfaces.QueryExpand} expand - Include the query string (wiql), clauses, query result columns, and sort options in the results. * @param {number} depth - In the folder of queries, return child queries and folders to this depth. * @param {boolean} includeDeleted - Include deleted queries and folders */ getQueries(project, expand, depth, includeDeleted) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project }; let queryValues = { '$expand': expand, '$depth': depth, '$includeDeleted': includeDeleted, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a67d190c-c41f-424b-814d-0e906f659301", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.QueryHierarchyItem, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Retrieves an individual query and its children * * @param {string} project - Project ID or project name * @param {string} query * @param {WorkItemTrackingInterfaces.QueryExpand} expand - Include the query string (wiql), clauses, query result columns, and sort options in the results. * @param {number} depth - In the folder of queries, return child queries and folders to this depth. * @param {boolean} includeDeleted - Include deleted queries and folders */ getQuery(project, query, expand, depth, includeDeleted) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, query: query }; let queryValues = { '$expand': expand, '$depth': depth, '$includeDeleted': includeDeleted, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a67d190c-c41f-424b-814d-0e906f659301", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.QueryHierarchyItem, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Searches all queries the user has access to in the current project * * @param {string} project - Project ID or project name * @param {string} filter - The text to filter the queries with. * @param {number} top - The number of queries to return (Default is 50 and maximum is 200). * @param {WorkItemTrackingInterfaces.QueryExpand} expand * @param {boolean} includeDeleted - Include deleted queries and folders */ searchQueries(project, filter, top, expand, includeDeleted) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project }; let queryValues = { '$filter': filter, '$top': top, '$expand': expand, '$includeDeleted': includeDeleted, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a67d190c-c41f-424b-814d-0e906f659301", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.QueryHierarchyItemsResult, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Update a query or a folder. This allows you to update, rename and move queries and folders. * * @param {WorkItemTrackingInterfaces.QueryHierarchyItem} queryUpdate - The query to update. * @param {string} project - Project ID or project name * @param {string} query - The path for the query to update. * @param {boolean} undeleteDescendants - Undelete the children of this folder. */ updateQuery(queryUpdate, project, query, undeleteDescendants) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, query: query }; let queryValues = { '$undeleteDescendants': undeleteDescendants, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a67d190c-c41f-424b-814d-0e906f659301", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.update(url, queryUpdate, options); let ret = this.formatResponse(res.result, WorkItemTrackingInterfaces.TypeInfo.QueryHierarchyItem, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Destroys the specified work item permanently from the Recycle Bin. This action can not be undone. * * @param {number} id - ID of the work item to be destroyed permanently * @param {string} project - Project ID or project name */ destroyWorkItem(id, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, id: id }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "b70d8d39-926c-465e-b927-b1bf0e5ca0e0", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.del(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets a deleted work item from Recycle Bin. * * @param {number} id - ID of the work item to be returned * @param {string} project - Project ID or project name */ getDeletedWorkItem(id, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, id: id }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "b70d8d39-926c-465e-b927-b1bf0e5ca0e0", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets a list of the IDs and the URLs of the deleted the work items in the Recycle Bin. * * @param {string} project - Project ID or project name */ getDeletedWorkItemReferences(project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "b70d8d39-926c-465e-b927-b1bf0e5ca0e0", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, null, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets the work items from the recycle bin, whose IDs have been specified in the parameters * * @param {number[]} ids - Comma separated list of IDs of the deleted work items to be returned * @param {string} project - Project ID or project name */ getDeletedWorkItems(ids, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project }; let queryValues = { ids: ids && ids.join(","), }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "b70d8d39-926c-465e-b927-b1bf0e5ca0e0", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, null, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Restores the deleted work item from Recycle Bin. * * @param {WorkItemTrackingInterfaces.WorkItemDeleteUpdate} payload - Paylod with instructions to update the IsDeleted flag to false * @param {number} id - ID of the work item to be restored * @param {string} project - Project ID or project name */ restoreWorkItem(payload, id, project) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { project: project, id: id }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "b70d8d39-926c-465e-b927-b1bf0e5ca0e0", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.update(url, payload, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Returns a fully hydrated work item for the requested revision * * @param {number} id * @param {number} revisionNumber * @param {WorkItemTrackingInterfaces.WorkItemExpand} expand */ getRevision(id, revisionNumber, expand) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { id: id, revisionNumber: revisionNumber }; let queryValues = { '$expand': expand, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a00c85a5-80fa-4565-99c3-bcd2181434bb", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Returns the list of fully hydrated work item revisions, paged. * * @param {number} id * @param {number} top * @param {number} skip * @param {WorkItemTrackingInterfaces.WorkItemExpand} expand */ getRevisions(id, top, skip, expand) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = { id: id }; let queryValues = { '$top': top, '$skip': skip, '$expand': expand, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "a00c85a5-80fa-4565-99c3-bcd2181434bb", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, null, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Validates the fields values. * * @param {WorkItemTrackingInterfaces.FieldsToEvaluate} ruleEngineInput */ evaluateRulesOnField(ruleEngineInput) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let routeValues = {}; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.2", "wit", "1a3a1536-dca6-4509-b9c3-dd9bb2981506", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, ruleEngineInput, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Creates a template * * @param {WorkItemTrackingInterfaces.WorkItemTemplate} template - Template contents * @param {TfsCoreInterfaces.TeamContext} teamContext - The team context for the operation */ createTemplate(template, teamContext) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let project = teamContext.projectId || teamContext.project; let team = teamContext.teamId || teamContext.team; let routeValues = { project: project, team: team }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "6a90345f-a676-4969-afce-8e163e1d5642", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.create(url, template, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Gets template * * @param {TfsCoreInterfaces.TeamContext} teamContext - The team context for the operation * @param {string} workitemtypename - Optional, When specified returns templates for given Work item type. */ getTemplates(teamContext, workitemtypename) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let project = teamContext.projectId || teamContext.project; let team = teamContext.teamId || teamContext.team; let routeValues = { project: project, team: team }; let queryValues = { workitemtypename: workitemtypename, }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "6a90345f-a676-4969-afce-8e163e1d5642", routeValues, queryValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.get(url, options); let ret = this.formatResponse(res.result, null, true); resolve(ret); } catch (err) { reject(err); } })); }); } /** * Deletes the template with given id * * @param {TfsCoreInterfaces.TeamContext} teamContext - The team context for the operation * @param {string} templateId - Template id */ deleteTemplate(teamContext, templateId) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let project = teamContext.projectId || teamContext.project; let team = teamContext.teamId || teamContext.team; let routeValues = { project: project, team: team, templateId: templateId }; try { let verData = yield this.vsoClient.getVersioningData("4.1-preview.1", "wit", "fb10264a-8836-48a0-8033-1b0ccd2748d5", routeValues); let url = verData.requestUrl; let options = this.createRequestOptions('application/json', verData.apiVersion); let res; res = yield this.rest.del(url, options); let ret