@gitkraken/provider-apis 0.51.0 → 0.53.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.
@@ -182,6 +182,7 @@ export declare class AzureDevOps extends EnterpriseProvider implements GitProvid
182
182
  includeRemoteInfo?: boolean;
183
183
  } & GetReposInput, options?: EnterpriseOptions): Promise<{
184
184
  data: GitPullRequest[];
185
+ metadata: import("../../types/exportedTypes/types").CollectionMetadata;
185
186
  }>;
186
187
  private getPullRequestsForProjectBase;
187
188
  getPullRequestsForProject(input: {
@@ -215,6 +216,7 @@ export declare class AzureDevOps extends EnterpriseProvider implements GitProvid
215
216
  includeRemoteInfo?: boolean;
216
217
  }, options?: EnterpriseOptions): Promise<{
217
218
  data: GitPullRequest[];
219
+ metadata: import("../../types/exportedTypes/types").CollectionMetadata;
218
220
  }>;
219
221
  getAzurePullRequestLastMergeStatus(input: {
220
222
  repo: GetRepoInput;
@@ -1,6 +1,6 @@
1
1
  import { RefreshTokenResponse } from '../../types/exportedTypes/bitbucket';
2
2
  import { Account, CursorPageInput, GetRepoErrorData, GetRepoInput, GetReposInput, GitMergeStrategy, GitPullRequest, GitPullRequestState, GitRepository, GitRepositoryPermissions, NumberedPageInput, Options, SetAccountInput, SetPullRequestInput } from '../../types/exportedTypes/gitProvider';
3
- import { NumberedPageInfo } from '../../types/exportedTypes/types';
3
+ import { NumberedPageInfo, Result } from '../../types/exportedTypes/types';
4
4
  import { BitbucketRepositoryRole } from '../../types/internalTypes/bitbucket';
5
5
  import { GitProvider } from '../gitProvider';
6
6
  import { Provider } from '../provider';
@@ -159,6 +159,19 @@ export declare class Bitbucket extends Provider implements GitProvider {
159
159
  pageInfo: NumberedPageInfo;
160
160
  data: GitPullRequest[];
161
161
  }>;
162
+ /**
163
+ * Bitbucket Cloud exposes no native workspace-level "PRs where this user is a reviewer" endpoint.
164
+ * This helper provides a workspace-scoped call surface by fanning out the existing repo-scoped
165
+ * reviewer query across either the provided repo subset or every accessible repo in the workspace.
166
+ */
167
+ getPullRequestsForReviewerAndWorkspace(input: {
168
+ reviewerId: string;
169
+ workspaceSlug: string;
170
+ repos?: GetRepoInput[];
171
+ states?: GitPullRequestState[];
172
+ query?: string;
173
+ pageSize?: number;
174
+ }, options?: Options): Promise<Result<GitPullRequest[]>>;
162
175
  private getPullRequestsForRepoBase;
163
176
  getPullRequestsForRepo(input: {
164
177
  repo: GetRepoInput;
@@ -180,6 +193,7 @@ export declare class Bitbucket extends Provider implements GitProvider {
180
193
  pageSize?: number;
181
194
  } & GetReposInput, options?: Options): Promise<{
182
195
  data: GitPullRequest[];
196
+ metadata: import("../../types/exportedTypes/types").CollectionMetadata;
183
197
  }>;
184
198
  getAccountsForWorkspace(input: {
185
199
  workspace: string;
@@ -72,6 +72,7 @@ export declare class BitbucketServer extends EnterpriseProvider implements GitPr
72
72
  pageSize?: number;
73
73
  } & GetReposInput, options?: EnterpriseOptions): Promise<{
74
74
  data: GitPullRequest[];
75
+ metadata: import("../../types/exportedTypes/types").CollectionMetadata;
75
76
  }>;
76
77
  getPullRequestsForCurrentUser(input: {
77
78
  reviewerLogin?: string;
@@ -1,7 +1,7 @@
1
1
  import { Account, AddInlineCommentInput, CursorPageInput, DeleteCommentInput, EditCommentInput, EnterpriseOptions, GetMergeBaseInput, GetPullRequestDescriptionInput, GetRepoErrorData, GetRepoInput, GetReposInput, GitComment, GitLabel, GitMergeStrategy, GitPullRequest, GitPullRequestReview, GitPullRequestState, GitRepository, GitTreeItem, NumberedPageInput, PullRequestDescription, ResolveReviewThreadInput, SetAccountInput, SetLabelInput, SetMilestoneInput, SetPullRequestDescriptionInput, SetPullRequestInput } from '../../types/exportedTypes/gitProvider';
2
2
  import { GitLabGetIssueInput, PullRequestAssociation } from '../../types/exportedTypes/gitlab';
3
- import { GitIssueState, Issue, SetIssueInput } from '../../types/exportedTypes/issueProvider';
4
- import { NumberedPageInfo, Result } from '../../types/exportedTypes/types';
3
+ import { GetIssuesForCurrentUserInput, GitIssueState, Issue, SetIssueInput } from '../../types/exportedTypes/issueProvider';
4
+ import { NumberedPageInfo, PagedResult, Result } from '../../types/exportedTypes/types';
5
5
  import { GitProvider } from '../gitProvider';
6
6
  import { IssueProvider } from '../issueProvider';
7
7
  import { EnterpriseProvider } from '../provider';
@@ -273,6 +273,18 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
273
273
  };
274
274
  data: Issue[];
275
275
  }>;
276
+ /**
277
+ * Account-wide "my issues" read via REST `GET /issues` (GitLab's GraphQL API has no top-level, cross-project
278
+ * issue field, so this is the only account-wide issue endpoint). Open issues only (`state=opened`).
279
+ *
280
+ * `scope` controls breadth: `assigned_to_me` returns issues assigned to the token's user (GitLab scopes to the
281
+ * current user server-side, no username needed); `all` returns every issue visible to the user and is combined
282
+ * with `assigneeUsername` to scope to a specific assignee, or left unfiltered for the "all assignees" broaden.
283
+ * Without `scope`, GitLab defaults to `created_by_me`, which is too narrow for a "my issues" read.
284
+ *
285
+ * Numbered pagination (`page`/`per_page` + the `x-next-page` header); one page per call — follow `pageInfo`.
286
+ */
287
+ getIssuesForCurrentUser(input?: GetIssuesForCurrentUserInput, options?: EnterpriseOptions): Promise<PagedResult<Issue>>;
276
288
  private setIssueState;
277
289
  closeIssue(input: {
278
290
  issue: SetIssueInput;
@@ -1,8 +1,9 @@
1
1
  import { GetRepoInput, Options, SetAccountInput, SetLabelInput, SetMilestoneInput } from '../types/exportedTypes/gitProvider';
2
- import { GetIssueInput, GetIssuesForReposInput, Issue, SetIssueInput, SetStatusInput } from '../types/exportedTypes/issueProvider';
2
+ import { GetIssueInput, GetIssuesForCurrentUserInput, GetIssuesForReposInput, Issue, SetIssueInput, SetStatusInput } from '../types/exportedTypes/issueProvider';
3
3
  import { PagedResult, Result } from '../types/exportedTypes/types';
4
4
  export interface IssueProvider {
5
5
  getIssue?(input: GetIssueInput, options: Options): Promise<Result<Issue>>;
6
+ getIssuesForCurrentUser?(input: GetIssuesForCurrentUserInput, options: Options): Promise<PagedResult<Issue>>;
6
7
  getIssuesForRepo?(input: {
7
8
  repo: GetRepoInput;
8
9
  }, options: Options): Promise<PagedResult<Issue>>;
@@ -29,6 +29,7 @@ export declare class Jira extends Provider implements IssueProvider {
29
29
  hasNextPage: boolean;
30
30
  endCursor: string;
31
31
  };
32
+ metadata: import("../../types/exportedTypes/types").CollectionMetadata;
32
33
  data: {
33
34
  id: string;
34
35
  key: string;
@@ -47,6 +48,7 @@ export declare class Jira extends Provider implements IssueProvider {
47
48
  hasNextPage: boolean;
48
49
  endCursor: string;
49
50
  };
51
+ metadata: import("../../types/exportedTypes/types").CollectionMetadata;
50
52
  data: {
51
53
  id: string;
52
54
  name: string;
@@ -56,6 +56,7 @@ export declare class Trello extends Provider implements IssueProvider {
56
56
  }>;
57
57
  }, options?: EnterpriseOptions): Promise<{
58
58
  data: Issue[];
59
+ metadata: import("../../types/exportedTypes/types").CollectionMetadata;
59
60
  }>;
60
61
  private updateIssue;
61
62
  setIssueStatus(input: {
@@ -1,4 +1,4 @@
1
- import { Account, GetReposInput, GitLabel, GitMilestone } from './gitProvider';
1
+ import { Account, CursorPageInput, GetReposInput, GitLabel, GitMilestone, NumberedPageInput } from './gitProvider';
2
2
  export declare enum GitIssueState {
3
3
  Open = "OPEN",
4
4
  Closed = "CLOSED"
@@ -13,6 +13,10 @@ export interface GetIssueInput {
13
13
  export type GetIssuesForReposInput = GetReposInput | {
14
14
  repoIds: (string | number)[];
15
15
  };
16
+ export type GetIssuesForCurrentUserInput = CursorPageInput | ({
17
+ scope?: 'assigned_to_me' | 'all';
18
+ assigneeUsername?: string;
19
+ } & NumberedPageInput);
16
20
  export interface IssueTransition {
17
21
  id: string;
18
22
  name: string;
@@ -88,12 +88,50 @@ export interface NumberedPageInfo {
88
88
  */
89
89
  totalCount?: number | null;
90
90
  }
91
+ export type CollectionCompleteness = 'complete' | 'partial' | 'unknown';
92
+ export type CollectionScopeFailureKind = 'authentication' | 'rate-limit' | 'not-found' | 'network' | 'provider' | 'unknown';
93
+ export interface CollectionScope {
94
+ providerId?: string;
95
+ resourceId?: string;
96
+ projectId?: string;
97
+ repositoryId?: string;
98
+ }
99
+ export interface CollectionScopeFailure {
100
+ scope?: CollectionScope;
101
+ kind: CollectionScopeFailureKind;
102
+ message?: string;
103
+ }
104
+ /**
105
+ * Additional facts about a collection result that are independent from provider-native pagination.
106
+ *
107
+ * `pageInfo` remains the only source of cursor/numbered-page continuation. For paged results,
108
+ * `completeness` describes whether the returned page is known to fully cover the requested scope for
109
+ * that call; it does not imply that the entire collection has been exhausted.
110
+ */
111
+ export interface CollectionMetadata {
112
+ /**
113
+ * Whether the SDK knows the returned collection fully covers the requested scope.
114
+ *
115
+ * - `complete`: no known omissions for the requested scope.
116
+ * - `partial`: the SDK knows items were omitted (for example due to a provider cap, a dropped
117
+ * sub-scope, or another explicit provider signal).
118
+ * - `unknown`: the upstream API does not expose enough information to assert completeness.
119
+ */
120
+ completeness: CollectionCompleteness;
121
+ /**
122
+ * Per-scope failures captured while still returning successful data from other scopes.
123
+ * These are structured provider facts only; callers decide how to warn, retry, or recover.
124
+ */
125
+ failures?: CollectionScopeFailure[];
126
+ }
91
127
  export type Result<T> = {
92
128
  data: T;
129
+ metadata?: CollectionMetadata;
93
130
  };
94
131
  export type PagedResult<T> = {
95
132
  pageInfo: CursorPageInfo | NumberedPageInfo;
96
133
  data: T[];
134
+ metadata?: CollectionMetadata;
97
135
  };
98
136
  export type FullFieldMap<T> = Record<keyof T, boolean>;
99
137
  export type FieldMap<T> = Partial<FullFieldMap<T>>;
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { GitPullRequest, GitPullRequestState } from './types/exportedTypes/gitProvider';
2
- import { CursorPageInfo, FieldMap, NumberedPageInfo } from './types/exportedTypes/types';
1
+ import { GetRepoInput, GitPullRequest, GitPullRequestState } from './types/exportedTypes/gitProvider';
2
+ import { CollectionCompleteness, CollectionMetadata, CollectionScope, CollectionScopeFailure, CollectionScopeFailureKind, CursorPageInfo, FieldMap, NumberedPageInfo } from './types/exportedTypes/types';
3
3
  export declare const getRequestHeaders: (token?: string, basicAuth?: boolean) => Record<string, string>;
4
4
  export declare const toFieldMap: <T, K extends keyof T = keyof T>(fields?: K[] | undefined) => Partial<import("./types/exportedTypes/types").FullFieldMap<T>> | undefined;
5
5
  /**
@@ -27,6 +27,54 @@ export declare const resolvePageSize: (pageSize: number | null | undefined, { fa
27
27
  max?: number | undefined;
28
28
  }) => number;
29
29
  export declare const filterPullRequestsByStates: (pullRequests: GitPullRequest[], states?: GitPullRequestState[]) => GitPullRequest[];
30
+ export declare const getErrorStatusCode: (error: unknown) => number | undefined;
31
+ export declare const getCollectionFailureKind: (error: unknown) => CollectionScopeFailureKind;
32
+ export declare const createCollectionFailure: (scope: CollectionScopeFailure['scope'], error: unknown) => CollectionScopeFailure;
33
+ export declare const createCollectionMetadata: (completeness: CollectionCompleteness, failures?: CollectionScopeFailure[]) => CollectionMetadata;
34
+ /**
35
+ * Combines two completeness signals into the more degraded of the two. A multi-scope fan-out is only
36
+ * as complete as its least-complete scope, so `partial` (a known omission) outranks `unknown` (the
37
+ * provider can't assert completeness), which outranks `complete`.
38
+ */
39
+ export declare const mergeCompleteness: (a: CollectionCompleteness, b: CollectionCompleteness) => CollectionCompleteness;
40
+ /**
41
+ * Stable scope identifier for a repo fan-out failure: the provider repository id when known, else a
42
+ * `namespace/name` fallback. Returns `undefined` when no repo is in scope (for example an Azure
43
+ * project fan-out with no repo filter).
44
+ */
45
+ export declare const getRepoScopeId: (repo: GetRepoInput | undefined) => string | undefined;
46
+ export interface CollectScopeSuccess<S, R> {
47
+ scope: S;
48
+ result: R;
49
+ }
50
+ export interface CollectAcrossScopesResult<S, R> {
51
+ successes: CollectScopeSuccess<S, Exclude<R, undefined>>[];
52
+ metadata: CollectionMetadata;
53
+ }
54
+ /**
55
+ * Runs `run` over every requested `scope` in parallel and aggregates the outcomes into common
56
+ * collection metadata, without throwing when individual scopes fail.
57
+ *
58
+ * - A scope whose `run` rejects is recorded as a per-scope failure (built from `failureScope`) and
59
+ * degrades completeness to `partial`.
60
+ * - A scope whose `run` resolves to `undefined` is skipped entirely: no data, no failure, and no
61
+ * effect on completeness (used when a scope is filtered out before any request is made).
62
+ * - A scope that resolves to a value contributes its `completeness` signal (defaulting to `complete`)
63
+ * and is returned in `successes` for the caller to shape into its own data type.
64
+ *
65
+ * An empty `scopes` list yields `complete` metadata with no failures.
66
+ *
67
+ * By default every scope runs concurrently (`Promise.all`). Pass `concurrency` to cap the number of
68
+ * in-flight `run` calls via `runInParallelBatches`, which avoids thundering-herd rate limiting when a
69
+ * caller fans out over a large scope list (a workspace's repos, projects, or resources). Scope order
70
+ * in `successes` is preserved either way. A `concurrency` that isn't a positive integer throws.
71
+ */
72
+ export declare function collectAcrossScopes<S, R>(scopes: S[], { run, failureScope, completeness, concurrency, }: {
73
+ run: (scope: S) => Promise<R | undefined>;
74
+ failureScope: (scope: S) => CollectionScope;
75
+ completeness?: (result: Exclude<R, undefined>) => CollectionCompleteness;
76
+ concurrency?: number;
77
+ }): Promise<CollectAcrossScopesResult<S, R>>;
30
78
  export declare function getSettledValue<T>(promise: PromiseSettledResult<Awaited<T | undefined>>): T | undefined;
31
79
  export declare function getSettledValue<T>(promise: PromiseSettledResult<Awaited<T | undefined>> | undefined, defaultValue: NonNullable<T>): NonNullable<T>;
32
80
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/provider-apis",
3
- "version": "0.51.0",
3
+ "version": "0.53.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",