@gitkraken/provider-apis 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GetReposInput, GitLabel, GitMergeStrategy, GitPullRequest, GitRepository, GitTreeItem, NumberedPageInput, SetAccountInput, SetLabelInput, SetMilestoneInput, SetPullRequestInput } from '../../types/exportedTypes/gitProvider';
1
+ import { Account, AddInlineCommentInput, CursorPageInput, DeleteCommentInput, EditCommentInput, EnterpriseOptions, GetMergeBaseInput, GetRepoErrorData, GetRepoInput, GetReposInput, GitComment, GitLabel, GitMergeStrategy, GitPullRequest, GitPullRequestReview, GitRepository, GitTreeItem, NumberedPageInput, ResolveReviewThreadInput, SetAccountInput, SetLabelInput, SetMilestoneInput, SetPullRequestInput } from '../../types/exportedTypes/gitProvider';
2
2
  import { GitLabGetIssueInput, PullRequestAssociation } from '../../types/exportedTypes/gitlab';
3
3
  import { Issue, SetIssueInput } from '../../types/exportedTypes/issueProvider';
4
4
  import { GitProvider } from '../gitProvider';
@@ -307,4 +307,137 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
307
307
  hasNextPage: boolean;
308
308
  };
309
309
  }>;
310
+ /**
311
+ * Returns a single merge request by repo and IID, normalized to the {@link GitPullRequest} shape.
312
+ * Returns `{ data: null }` if the merge request (or repo) is not found (404). Network/5xx errors are thrown.
313
+ */
314
+ getPullRequestForRepo(input: {
315
+ repo: GetRepoInput;
316
+ number: number;
317
+ }, options?: EnterpriseOptions): Promise<{
318
+ data: GitPullRequest | null;
319
+ }>;
320
+ /**
321
+ * Returns the raw contents of a file at the given ref as a {@link Blob}.
322
+ * Matches the {@link GitHub.getFileContents} contract — call `.text()` for text files; binary files are preserved.
323
+ */
324
+ getFileContents(input: {
325
+ repo: GetRepoInput;
326
+ path: string;
327
+ ref: string;
328
+ }, options?: EnterpriseOptions): Promise<{
329
+ data: Blob;
330
+ }>;
331
+ /**
332
+ * Returns the top-level notes on a merge request — i.e. comments not attached to a diff line.
333
+ * System notes (state changes, label updates, etc.) and inline diff notes are excluded.
334
+ * Inline notes are surfaced via {@link GitLab.getReviewsForPullRequest} instead.
335
+ *
336
+ * GitLab REST uses `page` / `per_page` for pagination, so the {@link CursorPageInput.cursor} is a base64-encoded
337
+ * `{ page, perPage }` object. An empty/undefined cursor starts at page 1 with `per_page = MAX_PAGE_SIZE`.
338
+ */
339
+ getCommentsForPullRequest(input: {
340
+ repo: GetRepoInput;
341
+ pullRequestNumber: number;
342
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
343
+ data: GitComment[];
344
+ pageInfo: {
345
+ endCursor: string | null;
346
+ hasNextPage: boolean;
347
+ };
348
+ }>;
349
+ /**
350
+ * Synthesizes a {@link GitPullRequestReview} array from GitLab approvals and diff discussions.
351
+ *
352
+ * GitLab does not natively model "reviews" the way GitHub does, so we emit:
353
+ * - one review per approver (body `''`, no review comments), and
354
+ * - one review per diff discussion (author/body from the first note; review comments mapped from all
355
+ * notes in the discussion, replies become {@link GitComment}s on the first review comment).
356
+ *
357
+ * Top-level (non-diff) notes are NOT included here; they are returned by {@link GitLab.getCommentsForPullRequest}.
358
+ */
359
+ getReviewsForPullRequest(input: {
360
+ repo: GetRepoInput;
361
+ pullRequestId: number;
362
+ }, options?: EnterpriseOptions): Promise<{
363
+ data: GitPullRequestReview[];
364
+ }>;
365
+ /**
366
+ * Returns the merge request's changes as a single unified diff string, matching the
367
+ * {@link AzureDevOps.getPullRequestDiff} contract so the PR viewer can render GitLab MRs the same way.
368
+ *
369
+ * Pages through GitLab's REST `/merge_requests/:iid/diffs` endpoint (per-file diff entries) and assembles a
370
+ * git-style unified diff by prepending the appropriate `diff --git`, mode, rename, and `---`/`+++` headers to
371
+ * each entry's `diff` payload.
372
+ *
373
+ * Binary or otherwise empty diffs are emitted as a header-only stanza (no `---`/`+++` lines) so the resulting
374
+ * string remains a valid concatenation of git diff records.
375
+ */
376
+ getPullRequestDiff(input: {
377
+ repo: GetRepoInput;
378
+ pullRequestId: number;
379
+ }, options?: EnterpriseOptions): Promise<string>;
380
+ /**
381
+ * Returns the merge base SHA of two refs, matching the {@link GitHub.getMergeBase} contract.
382
+ * Uses GitLab's REST `/repository/merge_base` endpoint, which accepts two refs and returns the commit object
383
+ * for their merge base. Throws if no merge base exists between the two refs.
384
+ */
385
+ getMergeBase(input: GetMergeBaseInput, options?: EnterpriseOptions): Promise<{
386
+ data: string;
387
+ }>;
388
+ private fetchAllMergeRequestDiscussions;
389
+ private fetchAllPagedGitLabREST;
390
+ addCommentToPullRequest(input: {
391
+ pullRequest: SetPullRequestInput;
392
+ comment: string;
393
+ }, options?: EnterpriseOptions): Promise<void>;
394
+ /**
395
+ * Adds an inline (diff) comment to a merge request. When `threadId` is set the note is appended
396
+ * to that discussion; otherwise a new discussion is created, which requires the MR's `diff_refs`
397
+ * and so costs an extra `GET /merge_requests/:iid`. Returns the new note's composite ID.
398
+ */
399
+ addInlineCommentToPullRequest(input: AddInlineCommentInput, options?: EnterpriseOptions): Promise<string | undefined>;
400
+ private getNoteUrl;
401
+ private deleteNote;
402
+ deleteComment(input: DeleteCommentInput, options?: EnterpriseOptions): Promise<void>;
403
+ deleteInlineComment(input: DeleteCommentInput, options?: EnterpriseOptions): Promise<void>;
404
+ private editNote;
405
+ editComment(input: EditCommentInput, options?: EnterpriseOptions): Promise<void>;
406
+ editInlineComment(input: EditCommentInput, options?: EnterpriseOptions): Promise<void>;
407
+ resolveReviewThread(input: ResolveReviewThreadInput, options?: EnterpriseOptions): Promise<void>;
408
+ unresolveReviewThread(input: ResolveReviewThreadInput, options?: EnterpriseOptions): Promise<void>;
409
+ private setReviewThreadResolved;
410
+ /**
411
+ * Approves the merge request and, if a comment is provided, posts it as a top-level note.
412
+ *
413
+ * The approval is issued first so that a subsequent failure to post the note does not leave the MR in an
414
+ * inconsistent "approved but no rationale posted" rollback state. If the note POST fails the approval stays
415
+ * in place and the error is thrown to the caller.
416
+ */
417
+ approvePullRequest(input: {
418
+ pullRequest: SetPullRequestInput;
419
+ comment?: string;
420
+ }, options?: EnterpriseOptions): Promise<void>;
421
+ /**
422
+ * Posts a top-level note on a merge request. For GitLab this is the same endpoint and payload as
423
+ * {@link GitLab.addCommentToPullRequest}; exposed under the GitHub-parity name so callers can treat
424
+ * approve / request-changes / comment as three uniform review actions.
425
+ */
426
+ commentOnPullRequest(input: {
427
+ pullRequest: SetPullRequestInput;
428
+ comment: string;
429
+ }, options?: EnterpriseOptions): Promise<void>;
430
+ /**
431
+ * Marks the merge request as "Changes requested" by the caller and posts the comment as a note.
432
+ *
433
+ * Prefers GitLab's native `mergeRequestRequestChanges` GraphQL mutation (Premium/Ultimate, GA 17.2+).
434
+ * When the mutation isn't in the schema, falls back to clearing any standing approval from the caller
435
+ * so the MR isn't left "Approved" alongside the "Request changes" intent.
436
+ */
437
+ requestPullRequestChanges(input: {
438
+ pullRequest: SetPullRequestInput;
439
+ comment: string;
440
+ }, options?: EnterpriseOptions): Promise<void>;
441
+ private tryRequestChangesMutation;
442
+ private postMergeRequestNote;
310
443
  }
@@ -316,6 +316,17 @@ export interface EditCommentInput {
316
316
  }
317
317
  export interface ResolveReviewThreadInput {
318
318
  threadId: string;
319
+ /**
320
+ * Required for GitLab — the project that owns the merge request. GitLab's REST endpoint for
321
+ * resolving/unresolving discussions is scoped to a project + merge request iid, and the
322
+ * discussion ID alone is not sufficient. GitHub and Azure DevOps ignore this field.
323
+ */
324
+ repo?: GetRepoInput;
325
+ /**
326
+ * Required for GitLab — the merge request iid (the per-project number). Paired with `repo` to
327
+ * locate the discussion. GitHub and Azure DevOps ignore this field.
328
+ */
329
+ pullRequestNumber?: number;
319
330
  }
320
331
  export interface CursorPageInput {
321
332
  cursor?: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/provider-apis",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "An SDK around different third-party APIs that accepts and returns data in a common format.",
5
5
  "author": "Axosoft, LLC dba GitKraken",
6
6
  "license": "SEE LICENSE IN LICENSE",