@gitkraken/provider-apis 0.50.0 → 0.52.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;
@@ -180,6 +180,7 @@ export declare class Bitbucket extends Provider implements GitProvider {
180
180
  pageSize?: number;
181
181
  } & GetReposInput, options?: Options): Promise<{
182
182
  data: GitPullRequest[];
183
+ metadata: import("../../types/exportedTypes/types").CollectionMetadata;
183
184
  }>;
184
185
  getAccountsForWorkspace(input: {
185
186
  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;
@@ -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: {
@@ -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,48 @@ 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
+ export declare function collectAcrossScopes<S, R>(scopes: S[], { run, failureScope, completeness, }: {
68
+ run: (scope: S) => Promise<R | undefined>;
69
+ failureScope: (scope: S) => CollectionScope;
70
+ completeness?: (result: Exclude<R, undefined>) => CollectionCompleteness;
71
+ }): Promise<CollectAcrossScopesResult<S, R>>;
30
72
  export declare function getSettledValue<T>(promise: PromiseSettledResult<Awaited<T | undefined>>): T | undefined;
31
73
  export declare function getSettledValue<T>(promise: PromiseSettledResult<Awaited<T | undefined>> | undefined, defaultValue: NonNullable<T>): NonNullable<T>;
32
74
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/provider-apis",
3
- "version": "0.50.0",
3
+ "version": "0.52.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",