UNPKG

37.4 kBJavaScriptView Raw
1"use strict";
2/*
3 * ---------------------------------------------------------
4 * Copyright(C) Microsoft Corporation. All rights reserved.
5 * ---------------------------------------------------------
6 *
7 * ---------------------------------------------------------
8 * Generated file, DO NOT EDIT
9 * ---------------------------------------------------------
10 */
11var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13 return new (P || (P = Promise))(function (resolve, reject) {
14 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17 step((generator = generator.apply(thisArg, _arguments || [])).next());
18 });
19};
20Object.defineProperty(exports, "__esModule", { value: true });
21exports.WikiApi = void 0;
22const basem = require("./ClientApiBases");
23const Comments_Contracts = require("./interfaces/CommentsInterfaces");
24const WikiInterfaces = require("./interfaces/WikiInterfaces");
25class WikiApi extends basem.ClientApiBase {
26 constructor(baseUrl, handlers, options) {
27 super(baseUrl, handlers, 'node-Wiki-api', options);
28 }
29 /**
30 * Uploads an attachment on a comment on a wiki page.
31 *
32 * @param {NodeJS.ReadableStream} contentStream - Content to upload
33 * @param {string} project - Project ID or project name
34 * @param {string} wikiIdentifier - Wiki ID or wiki name.
35 * @param {number} pageId - Wiki page ID.
36 */
37 createCommentAttachment(customHeaders, contentStream, project, wikiIdentifier, pageId) {
38 return __awaiter(this, void 0, void 0, function* () {
39 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
40 let routeValues = {
41 project: project,
42 wikiIdentifier: wikiIdentifier,
43 pageId: pageId
44 };
45 customHeaders = customHeaders || {};
46 customHeaders["Content-Type"] = "application/octet-stream";
47 try {
48 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "5100d976-363d-42e7-a19d-4171ecb44782", routeValues);
49 let url = verData.requestUrl;
50 let options = this.createRequestOptions('application/json', verData.apiVersion);
51 options.additionalHeaders = customHeaders;
52 let res;
53 res = yield this.rest.uploadStream("POST", url, contentStream, options);
54 let ret = this.formatResponse(res.result, Comments_Contracts.TypeInfo.CommentAttachment, false);
55 resolve(ret);
56 }
57 catch (err) {
58 reject(err);
59 }
60 }));
61 });
62 }
63 /**
64 * Downloads an attachment on a comment on a wiki page.
65 *
66 * @param {string} project - Project ID or project name
67 * @param {string} wikiIdentifier - Wiki ID or wiki name.
68 * @param {number} pageId - Wiki page ID.
69 * @param {string} attachmentId - Attachment ID.
70 */
71 getAttachmentContent(project, wikiIdentifier, pageId, attachmentId) {
72 return __awaiter(this, void 0, void 0, function* () {
73 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
74 let routeValues = {
75 project: project,
76 wikiIdentifier: wikiIdentifier,
77 pageId: pageId,
78 attachmentId: attachmentId
79 };
80 try {
81 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "5100d976-363d-42e7-a19d-4171ecb44782", routeValues);
82 let url = verData.requestUrl;
83 let apiVersion = verData.apiVersion;
84 let accept = this.createAcceptHeader("application/octet-stream", apiVersion);
85 resolve((yield this.http.get(url, { "Accept": accept })).message);
86 }
87 catch (err) {
88 reject(err);
89 }
90 }));
91 });
92 }
93 /**
94 * Add a reaction on a wiki page comment.
95 *
96 * @param {string} project - Project ID or project name
97 * @param {string} wikiIdentifier - Wiki ID or wiki name
98 * @param {number} pageId - Wiki page ID
99 * @param {number} commentId - ID of the associated comment
100 * @param {Comments_Contracts.CommentReactionType} type - Type of the reaction being added
101 */
102 addCommentReaction(project, wikiIdentifier, pageId, commentId, type) {
103 return __awaiter(this, void 0, void 0, function* () {
104 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
105 let routeValues = {
106 project: project,
107 wikiIdentifier: wikiIdentifier,
108 pageId: pageId,
109 commentId: commentId,
110 type: type
111 };
112 try {
113 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "7a5bc693-aab7-4d48-8f34-36f373022063", routeValues);
114 let url = verData.requestUrl;
115 let options = this.createRequestOptions('application/json', verData.apiVersion);
116 let res;
117 res = yield this.rest.replace(url, null, options);
118 let ret = this.formatResponse(res.result, Comments_Contracts.TypeInfo.CommentReaction, false);
119 resolve(ret);
120 }
121 catch (err) {
122 reject(err);
123 }
124 }));
125 });
126 }
127 /**
128 * Delete a reaction on a wiki page comment.
129 *
130 * @param {string} project - Project ID or project name
131 * @param {string} wikiIdentifier - Wiki ID or name
132 * @param {number} pageId - Wiki page ID
133 * @param {number} commentId - ID of the associated comment
134 * @param {Comments_Contracts.CommentReactionType} type - Type of the reaction being deleted
135 */
136 deleteCommentReaction(project, wikiIdentifier, pageId, commentId, type) {
137 return __awaiter(this, void 0, void 0, function* () {
138 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
139 let routeValues = {
140 project: project,
141 wikiIdentifier: wikiIdentifier,
142 pageId: pageId,
143 commentId: commentId,
144 type: type
145 };
146 try {
147 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "7a5bc693-aab7-4d48-8f34-36f373022063", routeValues);
148 let url = verData.requestUrl;
149 let options = this.createRequestOptions('application/json', verData.apiVersion);
150 let res;
151 res = yield this.rest.del(url, options);
152 let ret = this.formatResponse(res.result, Comments_Contracts.TypeInfo.CommentReaction, false);
153 resolve(ret);
154 }
155 catch (err) {
156 reject(err);
157 }
158 }));
159 });
160 }
161 /**
162 * Gets a list of users who have reacted for the given wiki comment with a given reaction type. Supports paging, with a default page size of 100 users at a time.
163 *
164 * @param {string} project - Project ID or project name
165 * @param {string} wikiIdentifier - Wiki ID or wiki name.
166 * @param {number} pageId - Wiki page ID.
167 * @param {number} commentId - ID of the associated comment
168 * @param {Comments_Contracts.CommentReactionType} type - Type of the reaction for which the engaged users are being requested
169 * @param {number} top - Number of enagaged users to be returned in a given page. Optional, defaults to 100
170 * @param {number} skip - Number of engaged users to be skipped to page the next set of engaged users, defaults to 0
171 */
172 getEngagedUsers(project, wikiIdentifier, pageId, commentId, type, top, skip) {
173 return __awaiter(this, void 0, void 0, function* () {
174 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
175 let routeValues = {
176 project: project,
177 wikiIdentifier: wikiIdentifier,
178 pageId: pageId,
179 commentId: commentId,
180 type: type
181 };
182 let queryValues = {
183 '$top': top,
184 '$skip': skip,
185 };
186 try {
187 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "598a5268-41a7-4162-b7dc-344131e4d1fa", routeValues, queryValues);
188 let url = verData.requestUrl;
189 let options = this.createRequestOptions('application/json', verData.apiVersion);
190 let res;
191 res = yield this.rest.get(url, options);
192 let ret = this.formatResponse(res.result, null, true);
193 resolve(ret);
194 }
195 catch (err) {
196 reject(err);
197 }
198 }));
199 });
200 }
201 /**
202 * Add a comment on a wiki page.
203 *
204 * @param {Comments_Contracts.CommentCreateParameters} request - Comment create request.
205 * @param {string} project - Project ID or project name
206 * @param {string} wikiIdentifier - Wiki ID or wiki name.
207 * @param {number} pageId - Wiki page ID.
208 */
209 addComment(request, project, wikiIdentifier, pageId) {
210 return __awaiter(this, void 0, void 0, function* () {
211 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
212 let routeValues = {
213 project: project,
214 wikiIdentifier: wikiIdentifier,
215 pageId: pageId
216 };
217 try {
218 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "9b394e93-7db5-46cb-9c26-09a36aa5c895", routeValues);
219 let url = verData.requestUrl;
220 let options = this.createRequestOptions('application/json', verData.apiVersion);
221 let res;
222 res = yield this.rest.create(url, request, options);
223 let ret = this.formatResponse(res.result, Comments_Contracts.TypeInfo.Comment, false);
224 resolve(ret);
225 }
226 catch (err) {
227 reject(err);
228 }
229 }));
230 });
231 }
232 /**
233 * Delete a comment on a wiki page.
234 *
235 * @param {string} project - Project ID or project name
236 * @param {string} wikiIdentifier - Wiki ID or name.
237 * @param {number} pageId - Wiki page ID.
238 * @param {number} id - Comment ID.
239 */
240 deleteComment(project, wikiIdentifier, pageId, id) {
241 return __awaiter(this, void 0, void 0, function* () {
242 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
243 let routeValues = {
244 project: project,
245 wikiIdentifier: wikiIdentifier,
246 pageId: pageId,
247 id: id
248 };
249 try {
250 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "9b394e93-7db5-46cb-9c26-09a36aa5c895", routeValues);
251 let url = verData.requestUrl;
252 let options = this.createRequestOptions('application/json', verData.apiVersion);
253 let res;
254 res = yield this.rest.del(url, options);
255 let ret = this.formatResponse(res.result, null, false);
256 resolve(ret);
257 }
258 catch (err) {
259 reject(err);
260 }
261 }));
262 });
263 }
264 /**
265 * Returns a comment associated with the Wiki Page.
266 *
267 * @param {string} project - Project ID or project name
268 * @param {string} wikiIdentifier - Wiki ID or wiki name.
269 * @param {number} pageId - Wiki page ID.
270 * @param {number} id - ID of the comment to return.
271 * @param {boolean} excludeDeleted - Specify if the deleted comment should be skipped.
272 * @param {Comments_Contracts.CommentExpandOptions} expand - Specifies the additional data retrieval options for comments.
273 */
274 getComment(project, wikiIdentifier, pageId, id, excludeDeleted, expand) {
275 return __awaiter(this, void 0, void 0, function* () {
276 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
277 let routeValues = {
278 project: project,
279 wikiIdentifier: wikiIdentifier,
280 pageId: pageId,
281 id: id
282 };
283 let queryValues = {
284 excludeDeleted: excludeDeleted,
285 '$expand': expand,
286 };
287 try {
288 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "9b394e93-7db5-46cb-9c26-09a36aa5c895", routeValues, queryValues);
289 let url = verData.requestUrl;
290 let options = this.createRequestOptions('application/json', verData.apiVersion);
291 let res;
292 res = yield this.rest.get(url, options);
293 let ret = this.formatResponse(res.result, Comments_Contracts.TypeInfo.Comment, false);
294 resolve(ret);
295 }
296 catch (err) {
297 reject(err);
298 }
299 }));
300 });
301 }
302 /**
303 * Returns a pageable list of comments.
304 *
305 * @param {string} project - Project ID or project name
306 * @param {string} wikiIdentifier - Wiki ID or wiki name.
307 * @param {number} pageId - Wiki page ID.
308 * @param {number} top - Max number of comments to return.
309 * @param {string} continuationToken - Used to query for the next page of comments.
310 * @param {boolean} excludeDeleted - Specify if the deleted comments should be skipped.
311 * @param {Comments_Contracts.CommentExpandOptions} expand - Specifies the additional data retrieval options for comments.
312 * @param {Comments_Contracts.CommentSortOrder} order - Order in which the comments should be returned.
313 * @param {number} parentId - CommentId of the parent comment.
314 */
315 listComments(project, wikiIdentifier, pageId, top, continuationToken, excludeDeleted, expand, order, parentId) {
316 return __awaiter(this, void 0, void 0, function* () {
317 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
318 let routeValues = {
319 project: project,
320 wikiIdentifier: wikiIdentifier,
321 pageId: pageId
322 };
323 let queryValues = {
324 '$top': top,
325 continuationToken: continuationToken,
326 excludeDeleted: excludeDeleted,
327 '$expand': expand,
328 order: order,
329 parentId: parentId,
330 };
331 try {
332 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "9b394e93-7db5-46cb-9c26-09a36aa5c895", routeValues, queryValues);
333 let url = verData.requestUrl;
334 let options = this.createRequestOptions('application/json', verData.apiVersion);
335 let res;
336 res = yield this.rest.get(url, options);
337 let ret = this.formatResponse(res.result, Comments_Contracts.TypeInfo.CommentList, false);
338 resolve(ret);
339 }
340 catch (err) {
341 reject(err);
342 }
343 }));
344 });
345 }
346 /**
347 * Update a comment on a wiki page.
348 *
349 * @param {Comments_Contracts.CommentUpdateParameters} comment - Comment update request.
350 * @param {string} project - Project ID or project name
351 * @param {string} wikiIdentifier - Wiki ID or wiki name.
352 * @param {number} pageId - Wiki page ID.
353 * @param {number} id - Comment ID.
354 */
355 updateComment(comment, project, wikiIdentifier, pageId, id) {
356 return __awaiter(this, void 0, void 0, function* () {
357 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
358 let routeValues = {
359 project: project,
360 wikiIdentifier: wikiIdentifier,
361 pageId: pageId,
362 id: id
363 };
364 try {
365 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "9b394e93-7db5-46cb-9c26-09a36aa5c895", routeValues);
366 let url = verData.requestUrl;
367 let options = this.createRequestOptions('application/json', verData.apiVersion);
368 let res;
369 res = yield this.rest.update(url, comment, options);
370 let ret = this.formatResponse(res.result, Comments_Contracts.TypeInfo.Comment, false);
371 resolve(ret);
372 }
373 catch (err) {
374 reject(err);
375 }
376 }));
377 });
378 }
379 /**
380 * Gets metadata or content of the wiki page for the provided path. Content negotiation is done based on the `Accept` header sent in the request.
381 *
382 * @param {string} project - Project ID or project name
383 * @param {string} wikiIdentifier - Wiki ID or wiki name.
384 * @param {string} path - Wiki page path.
385 * @param {GitInterfaces.VersionControlRecursionType} recursionLevel - Recursion level for subpages retrieval. Defaults to `None` (Optional).
386 * @param {GitInterfaces.GitVersionDescriptor} versionDescriptor - GitVersionDescriptor for the page. Defaults to the default branch (Optional).
387 * @param {boolean} includeContent - True to include the content of the page in the response for Json content type. Defaults to false (Optional)
388 */
389 getPageText(project, wikiIdentifier, path, recursionLevel, versionDescriptor, includeContent) {
390 return __awaiter(this, void 0, void 0, function* () {
391 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
392 let routeValues = {
393 project: project,
394 wikiIdentifier: wikiIdentifier
395 };
396 let queryValues = {
397 path: path,
398 recursionLevel: recursionLevel,
399 versionDescriptor: versionDescriptor,
400 includeContent: includeContent,
401 };
402 try {
403 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "25d3fbc7-fe3d-46cb-b5a5-0b6f79caf27b", routeValues, queryValues);
404 let url = verData.requestUrl;
405 let apiVersion = verData.apiVersion;
406 let accept = this.createAcceptHeader("text/plain", apiVersion);
407 resolve((yield this.http.get(url, { "Accept": accept })).message);
408 }
409 catch (err) {
410 reject(err);
411 }
412 }));
413 });
414 }
415 /**
416 * Gets metadata or content of the wiki page for the provided path. Content negotiation is done based on the `Accept` header sent in the request.
417 *
418 * @param {string} project - Project ID or project name
419 * @param {string} wikiIdentifier - Wiki ID or wiki name.
420 * @param {string} path - Wiki page path.
421 * @param {GitInterfaces.VersionControlRecursionType} recursionLevel - Recursion level for subpages retrieval. Defaults to `None` (Optional).
422 * @param {GitInterfaces.GitVersionDescriptor} versionDescriptor - GitVersionDescriptor for the page. Defaults to the default branch (Optional).
423 * @param {boolean} includeContent - True to include the content of the page in the response for Json content type. Defaults to false (Optional)
424 */
425 getPageZip(project, wikiIdentifier, path, recursionLevel, versionDescriptor, includeContent) {
426 return __awaiter(this, void 0, void 0, function* () {
427 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
428 let routeValues = {
429 project: project,
430 wikiIdentifier: wikiIdentifier
431 };
432 let queryValues = {
433 path: path,
434 recursionLevel: recursionLevel,
435 versionDescriptor: versionDescriptor,
436 includeContent: includeContent,
437 };
438 try {
439 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "25d3fbc7-fe3d-46cb-b5a5-0b6f79caf27b", routeValues, queryValues);
440 let url = verData.requestUrl;
441 let apiVersion = verData.apiVersion;
442 let accept = this.createAcceptHeader("application/zip", apiVersion);
443 resolve((yield this.http.get(url, { "Accept": accept })).message);
444 }
445 catch (err) {
446 reject(err);
447 }
448 }));
449 });
450 }
451 /**
452 * Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request.
453 *
454 * @param {string} project - Project ID or project name
455 * @param {string} wikiIdentifier - Wiki ID or wiki name..
456 * @param {number} id - Wiki page ID.
457 * @param {GitInterfaces.VersionControlRecursionType} recursionLevel - Recursion level for subpages retrieval. Defaults to `None` (Optional).
458 * @param {boolean} includeContent - True to include the content of the page in the response for Json content type. Defaults to false (Optional)
459 */
460 getPageByIdText(project, wikiIdentifier, id, recursionLevel, includeContent) {
461 return __awaiter(this, void 0, void 0, function* () {
462 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
463 let routeValues = {
464 project: project,
465 wikiIdentifier: wikiIdentifier,
466 id: id
467 };
468 let queryValues = {
469 recursionLevel: recursionLevel,
470 includeContent: includeContent,
471 };
472 try {
473 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "ceddcf75-1068-452d-8b13-2d4d76e1f970", routeValues, queryValues);
474 let url = verData.requestUrl;
475 let apiVersion = verData.apiVersion;
476 let accept = this.createAcceptHeader("text/plain", apiVersion);
477 resolve((yield this.http.get(url, { "Accept": accept })).message);
478 }
479 catch (err) {
480 reject(err);
481 }
482 }));
483 });
484 }
485 /**
486 * Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request.
487 *
488 * @param {string} project - Project ID or project name
489 * @param {string} wikiIdentifier - Wiki ID or wiki name..
490 * @param {number} id - Wiki page ID.
491 * @param {GitInterfaces.VersionControlRecursionType} recursionLevel - Recursion level for subpages retrieval. Defaults to `None` (Optional).
492 * @param {boolean} includeContent - True to include the content of the page in the response for Json content type. Defaults to false (Optional)
493 */
494 getPageByIdZip(project, wikiIdentifier, id, recursionLevel, includeContent) {
495 return __awaiter(this, void 0, void 0, function* () {
496 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
497 let routeValues = {
498 project: project,
499 wikiIdentifier: wikiIdentifier,
500 id: id
501 };
502 let queryValues = {
503 recursionLevel: recursionLevel,
504 includeContent: includeContent,
505 };
506 try {
507 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "ceddcf75-1068-452d-8b13-2d4d76e1f970", routeValues, queryValues);
508 let url = verData.requestUrl;
509 let apiVersion = verData.apiVersion;
510 let accept = this.createAcceptHeader("application/zip", apiVersion);
511 resolve((yield this.http.get(url, { "Accept": accept })).message);
512 }
513 catch (err) {
514 reject(err);
515 }
516 }));
517 });
518 }
519 /**
520 * Returns pageable list of Wiki Pages
521 *
522 * @param {WikiInterfaces.WikiPagesBatchRequest} pagesBatchRequest - Wiki batch page request.
523 * @param {string} project - Project ID or project name
524 * @param {string} wikiIdentifier - Wiki ID or wiki name.
525 * @param {GitInterfaces.GitVersionDescriptor} versionDescriptor - GitVersionDescriptor for the page. (Optional in case of ProjectWiki).
526 */
527 getPagesBatch(pagesBatchRequest, project, wikiIdentifier, versionDescriptor) {
528 return __awaiter(this, void 0, void 0, function* () {
529 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
530 let routeValues = {
531 project: project,
532 wikiIdentifier: wikiIdentifier
533 };
534 let queryValues = {
535 versionDescriptor: versionDescriptor,
536 };
537 try {
538 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "71323c46-2592-4398-8771-ced73dd87207", routeValues, queryValues);
539 let url = verData.requestUrl;
540 let options = this.createRequestOptions('application/json', verData.apiVersion);
541 let res;
542 res = yield this.rest.create(url, pagesBatchRequest, options);
543 let ret = this.formatResponse(res.result, WikiInterfaces.TypeInfo.WikiPageDetail, true);
544 resolve(ret);
545 }
546 catch (err) {
547 reject(err);
548 }
549 }));
550 });
551 }
552 /**
553 * Returns page detail corresponding to Page ID.
554 *
555 * @param {string} project - Project ID or project name
556 * @param {string} wikiIdentifier - Wiki ID or wiki name.
557 * @param {number} pageId - Wiki page ID.
558 * @param {number} pageViewsForDays - last N days from the current day for which page views is to be returned. It's inclusive of current day.
559 */
560 getPageData(project, wikiIdentifier, pageId, pageViewsForDays) {
561 return __awaiter(this, void 0, void 0, function* () {
562 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
563 let routeValues = {
564 project: project,
565 wikiIdentifier: wikiIdentifier,
566 pageId: pageId
567 };
568 let queryValues = {
569 pageViewsForDays: pageViewsForDays,
570 };
571 try {
572 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "81c4e0fe-7663-4d62-ad46-6ab78459f274", routeValues, queryValues);
573 let url = verData.requestUrl;
574 let options = this.createRequestOptions('application/json', verData.apiVersion);
575 let res;
576 res = yield this.rest.get(url, options);
577 let ret = this.formatResponse(res.result, WikiInterfaces.TypeInfo.WikiPageDetail, false);
578 resolve(ret);
579 }
580 catch (err) {
581 reject(err);
582 }
583 }));
584 });
585 }
586 /**
587 * Creates a new page view stats resource or updates an existing page view stats resource.
588 *
589 * @param {string} project - Project ID or project name
590 * @param {string} wikiIdentifier - Wiki ID or wiki name.
591 * @param {GitInterfaces.GitVersionDescriptor} wikiVersion - Wiki version.
592 * @param {string} path - Wiki page path.
593 * @param {string} oldPath - Old page path. This is optional and required to rename path in existing page view stats.
594 */
595 createOrUpdatePageViewStats(project, wikiIdentifier, wikiVersion, path, oldPath) {
596 return __awaiter(this, void 0, void 0, function* () {
597 if (wikiVersion == null) {
598 throw new TypeError('wikiVersion can not be null or undefined');
599 }
600 if (path == null) {
601 throw new TypeError('path can not be null or undefined');
602 }
603 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
604 let routeValues = {
605 project: project,
606 wikiIdentifier: wikiIdentifier
607 };
608 let queryValues = {
609 wikiVersion: wikiVersion,
610 path: path,
611 oldPath: oldPath,
612 };
613 try {
614 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "wiki", "1087b746-5d15-41b9-bea6-14e325e7f880", routeValues, queryValues);
615 let url = verData.requestUrl;
616 let options = this.createRequestOptions('application/json', verData.apiVersion);
617 let res;
618 res = yield this.rest.create(url, null, options);
619 let ret = this.formatResponse(res.result, WikiInterfaces.TypeInfo.WikiPageViewStats, false);
620 resolve(ret);
621 }
622 catch (err) {
623 reject(err);
624 }
625 }));
626 });
627 }
628 /**
629 * Creates the wiki resource.
630 *
631 * @param {WikiInterfaces.WikiCreateParametersV2} wikiCreateParams - Parameters for the wiki creation.
632 * @param {string} project - Project ID or project name
633 */
634 createWiki(wikiCreateParams, project) {
635 return __awaiter(this, void 0, void 0, function* () {
636 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
637 let routeValues = {
638 project: project
639 };
640 try {
641 let verData = yield this.vsoClient.getVersioningData("7.2-preview.2", "wiki", "288d122c-dbd4-451d-aa5f-7dbbba070728", routeValues);
642 let url = verData.requestUrl;
643 let options = this.createRequestOptions('application/json', verData.apiVersion);
644 let res;
645 res = yield this.rest.create(url, wikiCreateParams, options);
646 let ret = this.formatResponse(res.result, WikiInterfaces.TypeInfo.WikiV2, false);
647 resolve(ret);
648 }
649 catch (err) {
650 reject(err);
651 }
652 }));
653 });
654 }
655 /**
656 * Deletes the wiki corresponding to the wiki ID or wiki name provided.
657 *
658 * @param {string} wikiIdentifier - Wiki ID or wiki name.
659 * @param {string} project - Project ID or project name
660 */
661 deleteWiki(wikiIdentifier, project) {
662 return __awaiter(this, void 0, void 0, function* () {
663 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
664 let routeValues = {
665 project: project,
666 wikiIdentifier: wikiIdentifier
667 };
668 try {
669 let verData = yield this.vsoClient.getVersioningData("7.2-preview.2", "wiki", "288d122c-dbd4-451d-aa5f-7dbbba070728", routeValues);
670 let url = verData.requestUrl;
671 let options = this.createRequestOptions('application/json', verData.apiVersion);
672 let res;
673 res = yield this.rest.del(url, options);
674 let ret = this.formatResponse(res.result, WikiInterfaces.TypeInfo.WikiV2, false);
675 resolve(ret);
676 }
677 catch (err) {
678 reject(err);
679 }
680 }));
681 });
682 }
683 /**
684 * Gets all wikis in a project or collection.
685 *
686 * @param {string} project - Project ID or project name
687 */
688 getAllWikis(project) {
689 return __awaiter(this, void 0, void 0, function* () {
690 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
691 let routeValues = {
692 project: project
693 };
694 try {
695 let verData = yield this.vsoClient.getVersioningData("7.2-preview.2", "wiki", "288d122c-dbd4-451d-aa5f-7dbbba070728", routeValues);
696 let url = verData.requestUrl;
697 let options = this.createRequestOptions('application/json', verData.apiVersion);
698 let res;
699 res = yield this.rest.get(url, options);
700 let ret = this.formatResponse(res.result, WikiInterfaces.TypeInfo.WikiV2, true);
701 resolve(ret);
702 }
703 catch (err) {
704 reject(err);
705 }
706 }));
707 });
708 }
709 /**
710 * Gets the wiki corresponding to the wiki ID or wiki name provided.
711 *
712 * @param {string} wikiIdentifier - Wiki ID or wiki name.
713 * @param {string} project - Project ID or project name
714 */
715 getWiki(wikiIdentifier, project) {
716 return __awaiter(this, void 0, void 0, function* () {
717 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
718 let routeValues = {
719 project: project,
720 wikiIdentifier: wikiIdentifier
721 };
722 try {
723 let verData = yield this.vsoClient.getVersioningData("7.2-preview.2", "wiki", "288d122c-dbd4-451d-aa5f-7dbbba070728", routeValues);
724 let url = verData.requestUrl;
725 let options = this.createRequestOptions('application/json', verData.apiVersion);
726 let res;
727 res = yield this.rest.get(url, options);
728 let ret = this.formatResponse(res.result, WikiInterfaces.TypeInfo.WikiV2, false);
729 resolve(ret);
730 }
731 catch (err) {
732 reject(err);
733 }
734 }));
735 });
736 }
737 /**
738 * Updates the wiki corresponding to the wiki ID or wiki name provided using the update parameters.
739 *
740 * @param {WikiInterfaces.WikiUpdateParameters} updateParameters - Update parameters.
741 * @param {string} wikiIdentifier - Wiki ID or wiki name.
742 * @param {string} project - Project ID or project name
743 */
744 updateWiki(updateParameters, wikiIdentifier, project) {
745 return __awaiter(this, void 0, void 0, function* () {
746 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
747 let routeValues = {
748 project: project,
749 wikiIdentifier: wikiIdentifier
750 };
751 try {
752 let verData = yield this.vsoClient.getVersioningData("7.2-preview.2", "wiki", "288d122c-dbd4-451d-aa5f-7dbbba070728", routeValues);
753 let url = verData.requestUrl;
754 let options = this.createRequestOptions('application/json', verData.apiVersion);
755 let res;
756 res = yield this.rest.update(url, updateParameters, options);
757 let ret = this.formatResponse(res.result, WikiInterfaces.TypeInfo.WikiV2, false);
758 resolve(ret);
759 }
760 catch (err) {
761 reject(err);
762 }
763 }));
764 });
765 }
766}
767exports.WikiApi = WikiApi;
768WikiApi.RESOURCE_AREA_ID = "bf7d82a0-8aa5-4613-94ef-6172a5ea01f3";