@gitkraken/core-gitlens 0.54.0 → 0.55.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.
- package/CHANGELOG.md +9 -1
- package/dist/git/models/pullRequest.d.ts +14 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +3 -1
- package/dist/git/utils/pullRequest.utils.js +9 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/github.d.ts +2 -0
- package/dist/plus/git-github/api/github.js +16 -6
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestSearchQuery.d.ts +1 -0
- package/dist/plus/git-github/api/pullRequestSearchQuery.js +29 -5
- package/dist/plus/git-github/api/pullRequestSearchQuery.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +3 -0
- package/dist/plus/integrations/fieldPresence.js +7 -1
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +2 -2
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +7 -2
- package/dist/plus/integrations/models/publicIntegration.d.ts +1 -0
- package/dist/plus/integrations/models/pullRequestReads.d.ts +2 -0
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/github.js +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/metadata.js +6 -3
- package/dist/plus/integrations/providers/metadata.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/plus/integrations/reads/filters.js +13 -1
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +3 -3
- package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.d.ts +3 -3
- package/dist/plus/integrations/reads/searchPullRequests.js +4 -3
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/sweeps.js +20 -6
- package/dist/plus/integrations/reads/sweeps.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +1 -0
- package/dist/plus/integrations/reads/warnings.js +7 -2
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +7 -0
- package/dist/plus/integrations/results.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +33 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.js","names":[],"sources":["../../../../plus/integrations/src/results.ts"],"sourcesContent":["import { isUnsupportedSortError } from '@gitkraken/provider-apis';\nimport { AuthenticationError, RequestNotFoundError, RequestRateLimitError } from '@gitlens/git/errors.js';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { IssueSearchCriteria, IssueShape, IssueSorting } from '@gitlens/git/models/issue.js';\nimport type {\n\tPullRequestCheckLog,\n\tPullRequestSearchCriteria,\n\tPullRequestShape,\n\tPullRequestSorting,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { PullRequestActivityItem } from '@gitlens/git/models/pullRequestActivity.js';\nimport type { IntegrationIds } from './constants.js';\nimport { isProviderUnreachableError } from './errors.js';\nimport type { ProviderRepositoriesInput } from './manager.js';\nimport { UnexpectedResponseError } from './providers/providerErrors.js';\n\nexport interface ConnectionStateChangeEvent {\n\tkey: string;\n\treason: 'connected' | 'disconnected';\n}\n\n/**\n * A per-provider, per-connection warning surfaced alongside (partial) read results. Consumers use\n * these to drive auth recovery, retry, or truncation messaging without the read itself throwing.\n *\n * `kind` is the programmatic discriminant (a rate-limit is retryable, a 404 is not, an unsupported capability\n * never succeeds on retry, an auth failure needs re-connection unless {@link ProviderWarning.scope} confines\n * it); `isAuth` is retained as a convenience mirror of `kind === 'auth'`.\n *\n * `'unsupported'`: the provider — or this integration of it — lacks the capability the request asked for: a\n * surface (issues on Bitbucket, pull requests on an issue tracker, a batch read, org/repo discovery,\n * current-account lookup, project-scoped or account-wide issue reads), or a filter, sort, state, search\n * criterion or option combination it cannot express. Retrying the same request never succeeds; a different\n * provider, scope or request may. NOT unsupported (these stay `'other'`): malformed or contradictory caller\n * input the caller fixes in the request itself (a duplicate batch key, invalid target numbers, an empty owner,\n * an unusable scope), incompleteness or omission warnings, and unclassified errors.\n *\n * `'unreadable-items'`: the provider returned items this read could not read (a Jira issue whose fields the SDK cannot\n * parse), so it left them out and read everything else in the warning's {@link ProviderWarning.scope}. It still fails\n * the read (`fetchFailed`), since those items are missing, but retrying returns the same gap. On the reads that publish\n * it (an issue tracker's project reads) it never hides a read that was cut short: a cut always comes with a warning of\n * another kind. {@link ProviderWarning.unreadableItems} names the items left out.\n */\nexport type ProviderWarningKind =\n\t| 'auth'\n\t| 'rate-limit'\n\t| 'not-found'\n\t| 'no-connection'\n\t| 'unsupported'\n\t| 'unreadable-items'\n\t| 'other';\n\n/** The items an `'unreadable-items'` warning left out: see {@link ProviderWarning.unreadableItems}. */\nexport interface ProviderWarningUnreadableItems {\n\t/**\n\t * The provider's identifiers of the items left out (a Jira issue's key), without duplicates, in reported order. Each\n\t * one is an item the provider reported as skipped, so an identifier present is one that was left out, and one absent\n\t * was read when {@link complete}.\n\t *\n\t * Both hold only for the spelling the provider returned, which is also how a published issue's id spells its key: `keys`\n\t * doesn't answer a lookup by another spelling, such as a different case or the key an issue had before it moved. A\n\t * consumer comparing a key from elsewhere (one parsed from a branch name, say) must normalize the case of both sides,\n\t * and can't take an issue under a key it once had as read.\n\t */\n\tkeys: string[];\n\t/**\n\t * Whether {@link keys} names every item left out. `false` when an item left out had no key to report, when the\n\t * provider's report of them was malformed (no list of keys, or more than keys in it), or when it said items were left\n\t * out and named none, so an identifier absent from `keys` may still be one of them.\n\t */\n\tcomplete: boolean;\n}\n\n/**\n * Why a read that SUCCEEDED still withheld results:\n * - `provider-limit`: the provider refuses to serve past a cap it enforces (GitHub search's 1,000-result\n * ceiling, Trello's `cards_limit`), so the excess is unreachable through that query.\n * - `recovery-budget`: the internal partitioned recovery stopped spending upstream requests before it ran\n * out of partitions to visit.\n * - `pagination-incomplete`: pages were left unread — a sub-scope of a multi-scope read that was not drained,\n * a drain that stopped at its own page backstop, or a provider that advertised another page and gave no way\n * to reach it. These have DIFFERENT remedies, so the kind alone does not say whether more can be fetched;\n * read {@link ProviderWarningOmission.recovery} for that.\n *\n * Mirrors the vocabulary the SDK reports. Declared here rather than imported so this module stays free of\n * `@gitkraken/provider-apis` types (see the export block in `index.ts`); `collectionMetadata.ts` holds the\n * compile-time link, so an SDK bump that adds a kind fails the build at that boundary.\n */\nexport type ProviderWarningOmissionKind = 'provider-limit' | 'recovery-budget' | 'pagination-incomplete';\n\n/**\n * How a consumer can recover omitted results. `page-budget` reruns with a larger budget; `narrow-scope`\n * requests a smaller server-side scope; `none` promises neither. Switch on the exact value because only\n * `page-budget` is a fetch-more action.\n */\nexport type ProviderWarningOmissionRecovery = 'none' | 'page-budget' | 'narrow-scope';\n\n/**\n * The part of a provider a warning is confined to: one resource (organization, workspace, site), project or\n * repository. All fields optional; see {@link ProviderWarning.scope} for when one is forwarded.\n */\nexport interface ProviderWarningScope {\n\t/**\n\t * The resource as the read addressed it: its id on most reads, its name on the few that address it by name\n\t * (Azure DevOps' repo-scoped reads, Bitbucket's workspace reads). Match it against both\n\t * `ProviderOrganization.id` and `name`, and a project's `orgId` where it has one.\n\t */\n\tresourceId?: string;\n\t/**\n\t * The project as the read addressed it. For a Jira project read, the key, on Jira Cloud and Jira Data Center alike\n\t * (the project's `name` in `listProjects`).\n\t */\n\tprojectId?: string;\n\trepositoryId?: string;\n}\n\n/**\n * The selector of an issue-tracker project read that matched nothing: see {@link ProviderWarning.selector}. `kind`\n * names which one missed, and `value` is that selector exactly as the caller passed it. `linearProject` is one of a\n * Linear read's `linearProjects`, an id the workspace's Projects no longer list.\n */\nexport interface ProviderWarningSelector {\n\tkind: 'org' | 'project' | 'linearProject';\n\tvalue: string;\n}\n\n/**\n * Why a provider request failed, when the failure itself says so:\n * - `unreachable`: a transport failure or server-side error prevented the provider from answering. The connection\n * still exists; this accompanies `kind: 'other'`, never an authentication warning.\n * - `oauth-app-not-allowed`: the organization does not let third-party OAuth apps in. On Azure DevOps this is the\n * organization policy \"Third-party application access via OAuth\", off by default for new organizations. An\n * organization admin enables it, or the user connects with a personal access token instead, which the policy\n * does not govern.\n * - `access-denied`: the account has no access to that organization or project (not a member, or lacking the\n * permission). Someone who administers it has to grant access.\n * - `conditional-access`: a Microsoft Entra Conditional Access policy blocked the request (Azure DevOps\n * `VS403463`). Its admin has to exempt the request, e.g. by location or device.\n * - `unexpected-response`: the provider answered, but not with data in the shape the read expects (a gateway's JSON\n * error on a 2xx, an empty object, `null`), so the read could not use it. Accompanies `kind: 'other'`, like\n * `unreachable`; a retry may succeed once the provider, or whatever answered in front of it, answers properly. A\n * page served instead of data keeps its own message, without this cause.\n *\n * None of these is healed by reconnecting, which is the point of naming them.\n */\nexport type ProviderWarningCauseReason =\n\t| 'oauth-app-not-allowed'\n\t| 'access-denied'\n\t| 'conditional-access'\n\t| 'unreachable'\n\t| 'unexpected-response';\n\n/** See {@link ProviderWarning.cause}. */\nexport interface ProviderWarningCause {\n\treason: ProviderWarningCauseReason;\n\t/** The provider's own error code, when it reports one (Azure DevOps `TF400813`, `VS403463`). */\n\tcode?: string;\n\t/** Where the setting behind the refusal is changed, when this layer can address it. */\n\tremedyUrl?: string;\n}\n\n/** Which repository / project / resource an omission is attributed to. All fields optional; a scope may name none. */\nexport interface ProviderWarningOmissionScope extends ProviderWarningScope {\n\tproviderId?: string;\n}\n\nexport interface ProviderWarningOmission {\n\tkind: ProviderWarningOmissionKind;\n\t/**\n\t * Whether anything would fetch the missing items, and what. Gate a \"load more\" affordance on this rather\n\t * than on `kind` — see {@link ProviderWarningOmissionRecovery}.\n\t */\n\trecovery: ProviderWarningOmissionRecovery;\n\t/**\n\t * The cap the provider enforces, when it reports one. NOT a result count for every kind: on\n\t * `recovery-budget` this is a REQUEST budget and must not be shown to a user as a number of results.\n\t */\n\tlimit?: number;\n\t/** Total matches the provider reported, when it reports one. Only GitHub's search cap does today. */\n\ttotalCount?: number;\n\t/**\n\t * The order the reachable window was selected under, as `field:direction`, when the omission is a result\n\t * ceiling.\n\t *\n\t * Present so a consumer can word its own \"N matched, showing the first M\" without assuming WHICH M: the\n\t * provider serves the top M under this key, so the sentence is only true if it names it. Absent for every\n\t * omission that isn't a ceiling, where no window was selected by an order.\n\t *\n\t * A union of both vocabularies rather than the issue one alone: `PullRequestSorting` happens to be a subset\n\t * today, so narrowing this to {@link IssueSorting} would still compile while describing only half the reads\n\t * that set it — and would break the day the PR search gains a key the issue search has no name for.\n\t */\n\tsort?: IssueSorting | PullRequestSorting;\n\t/** Which repository / project / resource was affected, when one is attributed. */\n\tscope?: ProviderWarningOmissionScope;\n}\n\nexport interface ProviderWarning {\n\tproviderId: IntegrationIds;\n\t/** Disambiguates connections on self-managed hosts (where one provider id spans multiple domains). */\n\tdomain?: string;\n\t/** The specific token/connection the read was pinned to, when a `connectionId` was supplied. */\n\tconnectionId?: string;\n\tmessage: string;\n\tkind: ProviderWarningKind;\n\t/** Convenience mirror of `kind === 'auth'`, scoped or not; read {@link scope} before prompting to reconnect. */\n\tisAuth: boolean;\n\t/**\n\t * Present when the failure was recorded against one sub-scope of the read (an organization, project or\n\t * repository) rather than against the connection. A scoped `auth` failure is that one scope refusing this\n\t * credential, e.g. an Azure DevOps organization that disallows third-party OAuth apps, one in another Entra\n\t * tenant, or a Conditional Access policy. Reconnecting cannot fix those, so this warning alone is no reason\n\t * to prompt for it.\n\t *\n\t * `kind` and `isAuth` are unaffected: a scoped 401 is still an authentication failure, and this field says\n\t * how far it reaches. It names at least one of its IDs, and is never set on an omission (which carries its\n\t * own {@link ProviderWarningOmission.scope}) or on a warning derived from a caught exception (see\n\t * {@link toProviderWarning}), even when that call targeted a single organization. The exception is a batch\n\t * read's refused target, which names its scope: the Azure DevOps organization and project, the repository on\n\t * other git hosts, or the tracker's resource.\n\t *\n\t * Its ABSENCE means account-wide or unattributed, so existing handling stays correct without it.\n\t *\n\t * A scoped `auth` failure also means the credential itself was accepted. A dead token can come back as nothing\n\t * but scoped refusals wherever a read reaches its scopes without an uncached request to the connection first:\n\t * discovery served from a per-token cache (Azure DevOps, Bitbucket, Jira Cloud) or an SDK fan-out across the\n\t * requested repositories (Bitbucket Data Center). So when a read's only auth failures are scoped, those providers\n\t * confirm the credential with one uncached check first, and a refused credential fails the whole read with an\n\t * unscoped `auth` warning. A batch read checks it only when every target was refused, since a target that\n\t * answered already proved it. A refusal the provider attributes to the credential itself, like Bitbucket's or Jira\n\t * Cloud's for a token missing the OAuth scopes a read needs, which a reconnect fixes, is published unscoped too,\n\t * once for the connection, while the scopes that answered keep their results.\n\t *\n\t * So the promise holds for a read that carries no unscoped `auth` warning of its own; one that does already asks\n\t * for a reconnect, and its other scoped refusals are not checked. Two exceptions stay scoped even then. A check\n\t * that could not complete or was denied (a network error, a throttle, a `403`, Bitbucket Data Center refusing a\n\t * credential it authenticated, or a Bitbucket Data Center project access token, whose user the check cannot\n\t * find) proves nothing, so the warnings are published unconfirmed, with no {@link cause}, and the next read\n\t * checks again. And a credential confirmed within the last minute is not probed again, so a revocation can take\n\t * up to a minute to surface.\n\t */\n\tscope?: ProviderWarningScope;\n\t/**\n\t * Why the provider request failed, when the failure itself says so: see {@link ProviderWarningCauseReason}. Switch on\n\t * `reason` to recommend a fix instead of a reconnect; `message` then carries the same explanation as prose.\n\t *\n\t * `unreachable` accompanies a transport or server failure with `kind: 'other'`, and `unexpected-response` a response\n\t * the read could not use, also with `kind: 'other'`. Credential refusal causes are set only on a scoped `auth`\n\t * warning whose credential was confirmed first (see {@link scope}), because the\n\t * refusals they name are indistinguishable from a dead credential until then: Azure DevOps answers a\n\t * third-party OAuth app its organization disallows exactly as it answers an expired token. Only Azure DevOps\n\t * reports one today. Its absence proves nothing about the cause.\n\t */\n\tcause?: ProviderWarningCause;\n\t/**\n\t * Present when this warning describes results the read could not return even though the request itself\n\t * SUCCEEDED — a provider-enforced cap, an exhausted recovery budget, a page budget, or a sub-scope the read\n\t * did not drain.\n\t *\n\t * Its presence is the signal: an omission is not a failure. Message it as incompleteness rather than as a\n\t * failed read, and do NOT derive that from `message`, which is English prose and subject to rewording.\n\t * `kind` stays `'other'` for these, so the failure discriminant keeps meaning exactly what it meant before\n\t * this field existed.\n\t *\n\t * Whether anything would fetch the rest is a SEPARATE question — read {@link ProviderWarningOmission.recovery},\n\t * not `kind`, and never assume a retry of the same request returns more.\n\t *\n\t * `limit` / `totalCount` / `scope` are forwarded only when they are reported; most omissions carry none of\n\t * the three, so render correctly without them — and see {@link ProviderWarningOmission.limit} before\n\t * showing that figure as a result count.\n\t *\n\t * Its ABSENCE proves nothing. It is never set on a warning derived from a caught exception (see\n\t * {@link toProviderWarning}) or from a structured scope failure — those are failures, and the field would\n\t * be a lie there. But it is also absent whenever incompleteness was reported without naming what was left\n\t * out, so treat a bare `kind: 'other'` warning as unclassified rather than as a proven failure.\n\t */\n\tomission?: ProviderWarningOmission;\n\t/**\n\t * Present exactly when {@link kind} is `'unreadable-items'`: which items the read left out because it could not read\n\t * them. A consumer deciding whether an identifier is absent from the provider, rather than merely unread, must find\n\t * it in no warning's `keys` and see `complete` on every one.\n\t */\n\tunreadableItems?: ProviderWarningUnreadableItems;\n\t/**\n\t * Present when an issue-tracker project read's `org` or `project` selector matched nothing the connection\n\t * discovered: the selection was removed, renamed, or is no longer visible to this connection. `kind` is\n\t * `'not-found'`, the page is empty and not `fetchFailed`, and it carries no cursor, since a retry finds the same.\n\t * A `linearProject` miss is diagnostic: the requested Project ids still filter the read, preserving issues in\n\t * other selected Projects. It therefore does not force an empty page or remove its continuation.\n\t *\n\t * Set only when discovery was complete. A read whose discovery failed or was truncated cannot tell a missing\n\t * selection from one it did not reach, so it keeps reporting that failure instead, without this field. A miss is\n\t * confirmed against the connection's lists as the provider holds them now, read without the cache, since a cached\n\t * one predates what was created since. A cached project list can still name a project deleted since: the tracker\n\t * refuses it (Jira's \"does not exist for the field 'project'\"), it reads as empty, and the refusal drops that list,\n\t * so the next read reports the miss. Jira Data Center's refusal counts only when it names the user it\n\t * authenticated: it answers a rejected token the same way, as the anonymous user. The miss waits on an account\n\t * lookup on a resource those lists name, which confirms the\n\t * connection's credential, and a failed lookup is reported as the read's failure instead; an account that lists no\n\t * resource at all has none to look up, and is judged on its lists alone.\n\t *\n\t * It is the discriminant: a `not-found` without it is a request that failed with a 404, 410 or 422.\n\t */\n\tselector?: ProviderWarningSelector;\n\t/**\n\t * The keys of the batch targets this warning concerns: the target a per-target failure was refused or failed\n\t * for, or every target of an integration call that failed as a whole. So a caller that sends several callers'\n\t * targets in one call can hand a failure only to the targets it belongs to.\n\t *\n\t * Its ABSENCE means the whole call. It is absent on every read that is not a batch read, and on a batch read's\n\t * refusal of the whole call before any target is read (a duplicate key, an invalid target, an unknown etag\n\t * include, no resolvable connection, the wrong surface), which concerns every target alike.\n\t *\n\t * It is not part of a warning's identity: two warnings that differ only here are one warning, for the union of\n\t * their targets (see {@link appendDedupedWarning}).\n\t */\n\ttargetKeys?: string[];\n}\n\nexport interface ProviderPageInfo {\n\t/**\n\t * The 1-based POSITION of the returned page. One convention across every paged read, page-number and\n\t * cursor paging alike, so a `getNextPageParam`-style consumer can key off it uniformly:\n\t * - the page number the provider itself reported, when it reports one (authoritative);\n\t * - else the position the caller addressed: the page encoded in a threaded page cursor, or the `page`\n\t * supplied alongside an opaque cursor (1 when the caller supplied no `page`);\n\t * - else, for a read that can be advanced by page number, the requested `page` — the provider either\n\t * honored it or the internal drain reached it (see the paging contract on `IntegrationManager`);\n\t * - else 1: a cursor-only read with no cursor threaded back ignores a requested page number and answers\n\t * with its first page, so echoing the request would mislabel page 1 as page N.\n\t *\n\t * A page past the provider's terminal cursor still reports the requested `page` with empty `items` — an\n\t * empty page N, never page N-1 relabeled.\n\t *\n\t * Continue a cursor-paged read from `cursor`, NOT from `currentPage + 1`: a cursor-only host can't be\n\t * addressed by number, so this is a position label and not always a resumable request parameter.\n\t */\n\tcurrentPage: number;\n\t/**\n\t * The page size IN EFFECT, which is not always the one requested — it is whichever of these the read can\n\t * actually vouch for:\n\t * - the size the provider reported for the page it served (numbered-page hosts), else\n\t * - the `itemsPerPage` that was applied to the request (repo-scoped reads, which forward it), else\n\t * - `items.length`, for a read that takes no page size at all: the account-wide PR/issue reads, `listRepos`\n\t * (cursor-only), and `listIssueTrackerIssuesPage`, whose `itemsPerPage` counts PROJECTS rather than issues.\n\t *\n\t * So it is a description of the page, not an echo of the request: don't derive a total from\n\t * `currentPage * itemsPerPage`, and don't read `items.length < itemsPerPage` as \"last page\" — `hasMore` /\n\t * `cursor` are the only continuation signals.\n\t */\n\titemsPerPage: number;\n\t/**\n\t * A COMPLETENESS assertion, not a mode flag: `true` only when a sweep drained every page of every target\n\t * without truncating or failing (`!truncated && !fetchFailed`). Set exclusively by `sweepPullRequests` /\n\t * `sweepClosedPullRequests` and absent on every paged read, so `allPages !== true` does NOT by itself mean\n\t * \"this was a single page\".\n\t *\n\t * This is the signal to gate on before caching a sweep as authoritative: unlike `truncated` it is `false`\n\t * for BOTH kinds of incompleteness, so it can't be misread as a benign cap.\n\t */\n\tallPages?: boolean;\n\t/**\n\t * True when the read stopped before it could confirm it had everything. Deliberately does NOT distinguish\n\t * WHY, and a consumer must not assume it means a provider ceiling — a sweep sets it from three different\n\t * origins:\n\t * - a provider-side ceiling or per-scope backstop propagated from below (e.g. GitHub Search's 1000-result\n\t * cap): the missing items are NOT reachable, so this really is \"complete to the provider's limit\";\n\t * - the sweep's OWN `maxPages` cap (default 100) with a usable cursor still in hand: the missing items ARE\n\t * reachable and were simply not fetched — raise `maxPages` to get them;\n\t * - the provider reporting another page but handing back no usable cursor: not reachable.\n\t *\n\t * Only the second is recoverable, and a sweep exposes no continuation cursor, so treating a truncated sweep\n\t * as a complete set silently drops reachable data in that case. Prefer `allPages` for the cache decision.\n\t */\n\ttruncated?: boolean;\n}\n\nexport interface ProviderResult<T> {\n\titems: T[];\n\twarnings: ProviderWarning[];\n\t/**\n\t * True when `items` is incomplete — distinguishes a failed or truncated flat read from a genuinely empty\n\t * result. Paged results additionally use `page.truncated` when a completed page could not confirm it\n\t * drained everything.\n\t */\n\tfetchFailed?: boolean;\n}\n\nexport interface ProviderPagedResult<T> extends ProviderResult<T> {\n\t/**\n\t * True when a request failed. Unlike `fetchFailed`, a collection read successfully that only left some of its items\n\t * unreadable doesn't set it; those items are named by their own warnings.\n\t */\n\trequestFailed?: boolean;\n\t/** True when the provider advertised continuation without a usable cursor or page position, or repeated one. */\n\tunexpectedGap?: boolean;\n\tpage: ProviderPageInfo;\n\thasMore: boolean;\n\t/**\n\t * Opaque cursor for cursor-based paging (GraphQL, per-repo/per-project cursors, etc.). For hosts that\n\t * require the previous page's cursor, consumers should pass this value back to the next `cursor` option.\n\t * A retry-only cursor may remain when `hasMore` is false: `hasMore` means automatic forward progress,\n\t * while explicitly reusing such a cursor retries failed work without creating an infinite paging loop.\n\t */\n\tcursor?: string;\n}\n\n/**\n * One sweep target, named the way {@link ProviderSweepTargetEvent} names it, so a consumer can join the two.\n * `domain` is the resolved self-managed host (always `undefined` for a cloud provider).\n */\nexport interface ProviderSweepTargetRef {\n\tproviderId: IntegrationIds;\n\tconnectionId: string | undefined;\n\tdomain: string | undefined;\n}\n\n/**\n * A sweep may carry several targets of one provider (one per connection), so the provider arrays below can't say\n * which connection failed: `failedTargets` and `incompleteTargets` are the authoritative attribution, and\n * `failedProviderIds`/`incompleteProviderIds` summarize them. With one target per provider the two agree exactly.\n */\nexport interface ProviderSweepResult<T> extends ProviderResult<T> {\n\tpage: ProviderPageInfo;\n\thasMore: boolean;\n\t/**\n\t * Providers whose top-level read failed before returning any usable page, for EVERY attributed target of the\n\t * provider. A provider with a failed target and a surviving sibling is in `incompleteProviderIds` instead.\n\t * Partial per-scope failures stay represented by `warnings` + `fetchFailed` and are intentionally excluded.\n\t */\n\tfailedProviderIds: IntegrationIds[];\n\t/**\n\t * Providers whose read started successfully but could not produce an authoritative complete slice (for\n\t * example, a later page failed, collection metadata reported a partial scope, or a paging backstop was hit),\n\t * or that have a failed target beside one that returned something.\n\t * Kept separate from\n\t * `failedProviderIds` so consumers can accept healthy sibling providers while preserving an older snapshot\n\t * for a provider whose returned slice has a gap.\n\t */\n\tincompleteProviderIds: IntegrationIds[];\n\t/** Targets whose top-level read failed before returning any usable page. A skipped target is in neither list. */\n\tfailedTargets: ProviderSweepTargetRef[];\n\t/** Targets that returned a slice with a gap: a later page failed, or pages remain unread. Never also in `failedTargets`. */\n\tincompleteTargets: ProviderSweepTargetRef[];\n}\n\nexport interface ProviderBroadenResult<T> extends ProviderPagedResult<T> {\n\tbroadenedProviderIds: IntegrationIds[];\n\t/** Providers for which no requested org produced a usable issue result. */\n\tfailedProviderIds: IntegrationIds[];\n\t/** Providers with both a usable org result and at least one failed or truncated org slice. */\n\tincompleteProviderIds: IntegrationIds[];\n\tfanOutCount: number;\n}\n\nexport type RepositoryResolutionStatus =\n\t| 'resolved'\n\t| 'not-found'\n\t| 'unauthorized'\n\t| 'unsupported-provider'\n\t| 'invalid-remote-url'\n\t| 'host-mismatch'\n\t| 'undetermined';\n\nexport interface RepositoryIdentity {\n\tproviderId: IntegrationIds;\n\tdomain: string;\n\t/**\n\t * The provider's canonical owner/namespace (follows renames), falling back to where it was read when omitted. On\n\t * GitLab it is the whole group path (`group/subgroup`), not the remote path's first segment.\n\t */\n\towner: string;\n\t/** The provider's canonical repo name (follows renames), falling back to where it was read when omitted. */\n\tname: string;\n\tproject?: string;\n\t/** The original input remote URL, so the caller can key the resolution back to the remote it asked about. */\n\tremoteUrl: string;\n\t/**\n\t * True when the provider's canonical owner/name differ from what the input remote URL carried — i.e. the\n\t * repo was renamed/moved host-side and the local remote is stale. Owner and name are compared as one path, because\n\t * the remote and the provider split a GitLab nested group differently. Case-insensitive, mirroring gkcli's\n\t * `EqualFold` compare so hosts that echo the input casing (e.g. Bitbucket Server/Azure) aren't flagged. On Azure\n\t * DevOps it compares the repository name and its {@link project} too, against the collection and project the\n\t * repository was read at: an Azure DevOps Server remote's path may be read as another collection and project than\n\t * the remote parser read, which is no rename. GitLab's lookup doesn't follow a renamed or moved path, so a stale\n\t * GitLab remote resolves as `not-found` rather than as `renamed`.\n\t */\n\trenamed: boolean;\n\t/**\n\t * Whether the provider says this repository is a fork: `true` for a fork (including one it reports only by naming\n\t * its {@link parent}), `false` for a repository it reports as not one, `undefined` when it didn't say. Only\n\t * `false` is proof of \"not a fork\" — a missing {@link parent} is not.\n\t */\n\tisFork?: boolean;\n\t/**\n\t * The repository this one was forked from, named as the provider names it and living on the same host\n\t * ({@link providerId} and {@link domain}), so on GitLab `owner` is the whole group path (`group/subgroup`).\n\t * `project` is set only on Azure DevOps, where a repository lives in a project of its organization. Present only\n\t * when the provider reports a fork and names its parent; absent means \"not a fork\" or \"the provider didn't say\",\n\t * which {@link isFork} tells apart. This is the immediate parent, not the root of the fork network: a pull request\n\t * from a branch of this repository usually targets this repository or its parent, but GitHub and Azure DevOps let\n\t * it target any repository in the network, so a fork of a fork can open one against the root.\n\t */\n\tparent?: { owner: string; name: string; project?: string };\n}\n\nexport interface RepositoryResolution {\n\tstatus: RepositoryResolutionStatus;\n\tidentity?: RepositoryIdentity;\n\twarning?: ProviderWarning;\n}\n\nexport interface ResolveRepositoryResult {\n\tresolution: RepositoryResolution;\n}\n\nconst maxProviderWarningMessageLength = 500;\n\n/** A caught error's message as a warning can carry it: an HTML page becomes its status, and prose is capped. */\nexport function providerWarningMessage(ex: unknown): string {\n\tconst raw = (ex instanceof Error ? ex.message : String(ex)).trim();\n\tconst carrier = ex as { status?: unknown; response?: { status?: unknown } } | null | undefined;\n\tconst status =\n\t\ttypeof carrier?.status === 'number'\n\t\t\t? carrier.status\n\t\t\t: typeof carrier?.response?.status === 'number'\n\t\t\t\t? carrier.response.status\n\t\t\t\t: undefined;\n\n\t// Gateways commonly answer API requests with a complete HTML error page. That payload is neither actionable\n\t// nor suitable for a warning DTO consumed by UIs and logs; preserve the status without leaking the document.\n\tif (/<(?:!doctype\\s+html|html|head|body)\\b/i.test(raw)) {\n\t\treturn status != null ? `Provider request failed with status ${status}.` : 'Provider request failed.';\n\t}\n\n\tif (!raw) {\n\t\treturn status != null ? `Provider request failed with status ${status}.` : 'Provider request failed.';\n\t}\n\treturn raw.length > maxProviderWarningMessageLength\n\t\t? `${raw.slice(0, maxProviderWarningMessageLength - 3)}...`\n\t\t: raw;\n}\n\n/**\n * Normalized org/workspace/group shape returned by the provider facade.\n * `name` is the provider identifier to pass to follow-up reads (a Jira project's key), while `org` is an optional\n * display label of the parent. Where that label can't address the parent, `orgId` is the parent's stable id to pass\n * as `org` instead (a Jira site's id, or a Data Center instance's domain).\n *\n * Jira site rows (`listOrgs`) are the exception: their `name` is the site's label, and a Jira read selects a site only\n * by its `id` (or a project row's `orgId`).\n */\nexport interface ProviderOrganization {\n\tid: string;\n\tproviderId: IntegrationIds;\n\tname: string;\n\torg?: string;\n\torgId?: string;\n\turl: string;\n}\n\n/**\n * A Linear Project (Linear's own `Project` entity, which can span several teams), as `listLinearProjects` lists it.\n * Distinct from the teams `listProjects` publishes for Linear: pass its `id` to `listIssueTrackerIssuesPage`'s\n * `linearProjects` to narrow an issue read to it.\n */\nexport interface ProviderLinearProjectShape {\n\tid: string;\n\tproviderId: IntegrationIds;\n\tname: string;\n\t/** Linear's project state, as Linear names it (e.g. `planned`, `started`, `paused`, `completed`, `canceled`). */\n\tstate: string;\n\turl: string;\n}\n\n/** Normalized repository shape returned by the provider facade. */\nexport interface ProviderRepositoryShape {\n\tid: string;\n\tnamespace: string;\n\tname: string;\n\t/** Azure DevOps project; `undefined` for hosts without a project layer. */\n\tproject?: string;\n\t/** Web (browser) URL, when the provider exposes it. */\n\turl?: string;\n\t/** HTTPS clone URL, when available. */\n\tcloneUrlHttps?: string;\n\t/** SSH clone URL, when available. */\n\tcloneUrlSsh?: string;\n\t/** Default branch name, when the provider reports it. */\n\tdefaultBranch?: string;\n}\n\n/**\n * Classifies a caught provider exception into a neutral {@link ProviderWarning}. Ordering matters:\n * `instanceof` is checked most-specific-first so a rate-limit isn't mislabeled as a generic error and\n * a 404 isn't mislabeled as auth.\n */\nexport function toProviderWarning(\n\tproviderId: IntegrationIds,\n\tdomain: string | undefined,\n\tconnectionId: string | undefined,\n\tex: unknown,\n): ProviderWarning {\n\tlet kind: ProviderWarning['kind'];\n\tif (ex instanceof AuthenticationError) {\n\t\tkind = 'auth';\n\t} else if (ex instanceof RequestRateLimitError) {\n\t\tkind = 'rate-limit';\n\t} else if (ex instanceof RequestNotFoundError) {\n\t\tkind = 'not-found';\n\t} else if (isUnsupportedSortError(ex)) {\n\t\tkind = 'unsupported';\n\t} else {\n\t\tkind = 'other';\n\t}\n\n\tconst cause = kind === 'other' ? getRequestFailureCause(ex) : undefined;\n\treturn {\n\t\tproviderId: providerId,\n\t\tdomain: domain,\n\t\tconnectionId: connectionId,\n\t\tmessage: providerWarningMessage(ex),\n\t\tkind: kind,\n\t\tisAuth: kind === 'auth',\n\t\t...(cause != null ? { cause: cause } : {}),\n\t};\n}\n\n/**\n * The cause a failed request's error names by itself, one that isn't the credential's (`unexpected-response` or\n * `unreachable`), for a failure classified as no more specific than that.\n */\nexport function getRequestFailureCause(ex: unknown): ProviderWarningCause | undefined {\n\tif (UnexpectedResponseError.is(ex)) return { reason: 'unexpected-response' };\n\tif (isProviderUnreachableError(ex)) return { reason: 'unreachable' };\n\treturn undefined;\n}\n\n/**\n * A scope's identity, as the stable string that keys it.\n *\n * The single definition of what \"the same scope\" means, shared by the failure and omission dedup keys in\n * `providerPaging.ts` and by {@link providerWarningKey} below, so a scope gaining a field is one edit rather\n * than three. `providerId` is included: the same repository ID under two providers is two scopes.\n *\n * The parameter is structural rather than the SDK's `CollectionScope` so this module keeps naming no\n * `@gitkraken/provider-apis` types (see the export block in `index.ts`) while still serving its SDK-facing\n * callers, which pass that type in unchanged.\n */\nexport function collectionScopeKey(scope: ProviderWarningOmissionScope | undefined): string {\n\treturn [scope?.providerId ?? '', scope?.resourceId ?? '', scope?.projectId ?? '', scope?.repositoryId ?? ''].join(\n\t\t' ',\n\t);\n}\n\n/**\n * The omission's contribution to a warning's identity — empty when there is none, so a warning without an\n * omission keeps deduping exactly as it did before the field existed.\n *\n * Two omissions of different kinds do produce different `message` values today, so message alone would still\n * separate them. That is incidental: the premise of `omission` is that consumers must not depend on prose\n * carrying the distinguishing fact, and this key must not either.\n */\nfunction providerWarningOmissionKey(omission: ProviderWarningOmission | undefined): string {\n\tif (omission == null) return '';\n\n\treturn [\n\t\tomission.kind,\n\t\tomission.recovery,\n\t\tomission.limit ?? '',\n\t\tomission.totalCount ?? '',\n\t\tcollectionScopeKey(omission.scope),\n\t].join(' ');\n}\n\n/**\n * Strips the omission from every warning in `warnings` when the read as a whole failed.\n *\n * An omission asserts the request SUCCEEDED, and a drain only learns it failed AFTER it may have emitted one:\n * an early page can report its own truncation and then a later page can die. Deciding per warning, at the\n * moment each is built, cannot see that future — so the aggregate is reconciled once, here, where\n * `fetchFailed` is final. Call it at the point a read returns its `fetchFailed`.\n *\n * Re-dedupes as it goes: the omission is part of a warning's identity, so two warnings that differed only\n * there become identical once it is gone, and the array's contract is that no two entries are equal.\n *\n * Mutates in place: the warning array is the one being returned, and callers accumulate into it across pages.\n */\nexport function reconcileOmissionsWithFailure(warnings: ProviderWarning[], fetchFailed: boolean): void {\n\tif (!fetchFailed || !warnings.some(w => w.omission != null)) return;\n\n\tconst reconciled: ProviderWarning[] = [];\n\tfor (const warning of warnings) {\n\t\tif (warning.omission == null) {\n\t\t\tappendDedupedWarning(reconciled, warning);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst { omission: _omission, ...rest } = warning;\n\t\tappendDedupedWarning(reconciled, rest);\n\t}\n\n\twarnings.splice(0, warnings.length, ...reconciled);\n}\n\n/**\n * A stable key for deduplicating warnings accumulated across drained pages / fan-out scopes.\n *\n * The scope and the cause are keyed for the reason the omission is (see {@link providerWarningOmissionKey}): today's\n * failure messages happen to spell them out, but two failures that differ in either must stay two warnings even if\n * they don't.\n *\n * `message` stays LAST. It is the only free-form segment — provider prose, spaces and all — so anything\n * appended after it could be impersonated by a message that happens to end in the same text.\n */\nfunction providerWarningKey(warning: ProviderWarning): string {\n\treturn [\n\t\twarning.providerId,\n\t\twarning.connectionId ?? '',\n\t\twarning.domain ?? '',\n\t\twarning.kind,\n\t\tcollectionScopeKey(warning.scope),\n\t\twarning.cause?.reason ?? '',\n\t\tproviderWarningOmissionKey(warning.omission),\n\t\twarning.selector != null ? JSON.stringify([warning.selector.kind, warning.selector.value]) : '',\n\t\twarning.message,\n\t].join(' ');\n}\n\n/**\n * Appends `warning` to `into` only when an equal warning (by provider/connection/domain/kind/message, plus the\n * structured scope, cause, omission and selector when present) is absent. An equal warning already there merges its\n * {@link ProviderWarning.targetKeys} with the new one's instead: the union of both, or none when either concerns\n * the whole call. Its {@link ProviderWarning.unreadableItems} merge too (see {@link mergeUnreadableItems}): two reads\n * can report the same text for different items. The existing warning is replaced, never mutated, since it may be\n * shared.\n */\nexport function appendDedupedWarning(into: ProviderWarning[], warning: ProviderWarning): void {\n\tconst key = providerWarningKey(warning);\n\tconst index = into.findIndex(existing => providerWarningKey(existing) === key);\n\tif (index === -1) {\n\t\tinto.push(warning);\n\t\treturn;\n\t}\n\n\tconst existing = into[index];\n\tconst targetKeys = mergeTargetKeys(existing.targetKeys, warning.targetKeys);\n\tconst unreadableItems =\n\t\texisting.unreadableItems != null && warning.unreadableItems != null\n\t\t\t? mergeUnreadableItems(existing.unreadableItems, warning.unreadableItems)\n\t\t\t: (existing.unreadableItems ?? warning.unreadableItems);\n\tif (targetKeys === existing.targetKeys && unreadableItems === existing.unreadableItems) return;\n\n\tconst { targetKeys: _, ...rest } = existing;\n\tinto[index] = {\n\t\t...rest,\n\t\t...(targetKeys != null ? { targetKeys: targetKeys } : {}),\n\t\t...(unreadableItems != null ? { unreadableItems: unreadableItems } : {}),\n\t};\n}\n\n/** The union of two warnings' target keys, or none when either concerns the whole call. `existing` when unchanged. */\nfunction mergeTargetKeys(existing: string[] | undefined, next: string[] | undefined): string[] | undefined {\n\t// Either concerns the whole call.\n\tif (existing == null || next == null) return undefined;\n\n\tconst added = next.filter(k => !existing.includes(k));\n\tif (!added.length) return existing;\n\n\treturn [...existing, ...new Set(added)];\n}\n\n/**\n * The items two reports of unreadable items left out together: the union of their keys, complete only when both are.\n * `existing` when `next` adds nothing to it.\n */\nexport function mergeUnreadableItems(\n\texisting: ProviderWarningUnreadableItems,\n\tnext: ProviderWarningUnreadableItems,\n): ProviderWarningUnreadableItems {\n\tconst known = new Set(existing.keys);\n\tconst added = next.keys.filter(k => !known.has(k));\n\tconst complete = existing.complete && next.complete;\n\tif (!added.length && complete === existing.complete) return existing;\n\n\treturn { keys: [...existing.keys, ...new Set(added)], complete: complete };\n}\n\n// The count, batch, branch and current-account reads' input and result shapes. They live here rather than beside their\n// reads (`reads/*`) so the public facade can export them without its declarations reaching the reads' internal context.\n\n/**\n * One scope to count.\n *\n * `key` is caller-owned and echoed back verbatim, so a batch result needs no positional matching by the consumer.\n * It never reaches the provider query — the aliases in the upstream document are generated — so it can be any\n * string the caller finds meaningful.\n */\nexport interface IssueCountScope {\n\tkey: string;\n\t/** Repositories to count over. Combines with `org`, exactly as in `searchIssuesPage`. */\n\trepos?: ProviderRepositoriesInput;\n\torg?: string;\n\t/**\n\t * Same criteria model as `searchIssuesPage`, validated against the same capability table.\n\t *\n\t * `criteria.sort` does not affect the count — a total is invariant under ordering — but it is still VALIDATED,\n\t * and an unsupported key refuses this scope exactly as it would refuse the read. That is the point of the\n\t * count: it previews the constraints the read will apply, so one that accepted what the read refuses would\n\t * promise a fetch that can't happen, which is worse than no preview at all.\n\t */\n\tcriteria?: IssueSearchCriteria;\n}\n\n/** The count for one {@link IssueCountScope}, echoed back under the caller's own `key`. */\nexport interface IssueCountResult {\n\tkey: string;\n\t/**\n\t * Total matches the provider reports. `undefined` when the provider didn't report one for this scope — NEVER\n\t * zero, which is a real answer. Render the difference: an unreported count means \"unknown\", and showing it as\n\t * 0 would tell the user this filter matches nothing.\n\t */\n\tcount?: number;\n\t/**\n\t * True when `count` exceeds the provider's own result ceiling, so a full read CANNOT return everything no\n\t * matter how it is paged. This is the signal to warn before starting an expensive fetch.\n\t */\n\texceedsProviderLimit: boolean;\n\t/** The ceiling itself, when the provider declares one. */\n\tproviderLimit?: number;\n}\n\n/**\n * One scope to count pull requests over — the PR twin of {@link IssueCountScope}.\n *\n * `key` is caller-owned and echoed back verbatim, never reaching the provider query (the aliases are generated), so\n * it can be any string the caller finds meaningful.\n */\nexport interface PullRequestCountScope {\n\tkey: string;\n\t/** Repositories to count over. Combines with `org`, exactly as in `searchPullRequestsPage`. */\n\trepos?: ProviderRepositoriesInput;\n\torg?: string;\n\t/**\n\t * Same criteria model as `searchPullRequestsPage`, validated against the same capability table — so a count\n\t * refuses exactly what the read would, and never previews a fetch that can't happen.\n\t */\n\tcriteria?: PullRequestSearchCriteria;\n}\n\n/** The count for one {@link PullRequestCountScope}, echoed back under the caller's own `key`. */\nexport interface PullRequestCountResult {\n\tkey: string;\n\t/**\n\t * Total matches the provider reports. `undefined` when the provider didn't report one for this scope — NEVER\n\t * zero, which is a real answer.\n\t *\n\t * For a multi-state scope, GitHub/GHE report the LARGEST of their per-state counts (the same total\n\t * `searchPullRequestsPage` surfaces, since each state is its own capped search), not their sum. Bitbucket Data\n\t * Center has no ceiling to stay under, so it reports the exact union — the number of rows the search returns —\n\t * and so does Azure DevOps Server, which reads every state in one drain.\n\t */\n\tcount?: number;\n\t/**\n\t * True when `count` is a FLOOR rather than the total: the provider has no count query (Bitbucket Data Center),\n\t * so it counts by reading within a budget, and this scope had more than the budget read. Render it as \"N+\", and\n\t * treat the scope as at least that expensive. Absent means `count` is exact — the provider's own total, or for a\n\t * provider that counts by reading, every match it read.\n\t */\n\tlowerBound?: boolean;\n\t/**\n\t * True when `count` exceeds the provider's own per-search result ceiling, so a full read CANNOT return\n\t * everything no matter how it is paged. This is the signal to warn before starting an expensive fetch.\n\t */\n\texceedsProviderLimit: boolean;\n\t/** The ceiling itself, when the provider declares one. */\n\tproviderLimit?: number;\n}\n\n/** One issue to resolve, echoed back under the caller's own `key`. Which form a call takes depends on its provider. */\nexport type IssueBatchTarget =\n\t/**\n\t * A git host's issue, by repository coordinate. GitHub/GHE, GitLab (and self-managed) and Azure DevOps (and\n\t * Server); Bitbucket and Bitbucket Data Center have no issues and refuse.\n\t */\n\t| {\n\t\t\tkey: string;\n\t\t\t/** GitHub owner, GitLab namespace path (may be nested), or Azure DevOps organization (or collection). */\n\t\t\towner: string;\n\t\t\t/**\n\t\t\t * Repository name. Required, but ignored on Azure DevOps, whose work items belong to the project rather\n\t\t\t * than to a repository; there it only names the project of a project-less Azure DevOps Server path read\n\t\t\t * behind a virtual directory (`{vdir}/{collection}/_git/{repo}` as owner `{vdir}`, project `{collection}`).\n\t\t\t */\n\t\t\trepo: string;\n\t\t\t/** Issue number, GitLab issue iid, or Azure DevOps work item id. */\n\t\t\tnumber: number;\n\t\t\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\t\t\tproject?: string;\n\t\t\t/** The {@link IssueBatchResult.etag} of the copy the caller holds; see {@link IssueBatchResult}. */\n\t\t\tetag?: string;\n\t }\n\t/**\n\t * An issue tracker's issue, by its own identifier (e.g. `ABC-123`) within a resource. Jira (Cloud and Data\n\t * Center) and Linear. For Jira Data Center `resourceId` is the host — the instance's single resource, as\n\t * `listOrgs` reports it — and `resourceUrl` is not needed, since the browser link is built from the\n\t * connection's own base URL; Jira Cloud requires it.\n\t */\n\t| {\n\t\t\tkey: string;\n\t\t\tresourceId: string;\n\t\t\tresourceUrl?: string;\n\t\t\tidentifier: string;\n\t\t\t/**\n\t\t\t * The {@link IssueBatchResult.etag} of the copy the caller holds. Checked cheaply on Jira Cloud and Linear;\n\t\t\t * every other tracker accepts it but reads the issue in full.\n\t\t\t */\n\t\t\tetag?: string;\n\t };\n\n/**\n * The answer for one {@link IssueBatchTarget}, in one of four states:\n * - `{ key, issue, etag }` — read in full. Every fully read row carries an `etag`, whether or not the caller sent\n * one, so a caller can seed its etags from the reads it already makes.\n * - `{ key, unchanged: true, etag }` — the cheap check proved the caller's copy current, and nothing else was\n * fetched. Only for a target that sent an `etag`, on a host with a cheap check.\n * - `{ key }` — PROVEN ABSENT.\n * - no row, with `fetchFailed` and a warning — the read could not check. Never treat that as absent.\n */\nexport interface IssueBatchResult {\n\tkey: string;\n\t/**\n\t * The resolved issue, or `undefined` when it PROVABLY does not exist (or is not visible to this connection) —\n\t * or when it is `unchanged`.\n\t *\n\t * Absent is an answer here, unlike every paged read on this facade: a target that FAILED — its own request\n\t * outright, or just its own alias within an otherwise-answering GitHub chunk (e.g. an org enforcing SAML SSO\n\t * the token isn't authorized for) — is not returned at all and sets `fetchFailed`, so a caller can tell\n\t * \"proven absent\" from \"unknown\" and cache the first without ever caching the second.\n\t */\n\tissue?: IssueShape;\n\t/**\n\t * Opaque: compare for equality only, never parse. Computed by core from the issue's change state — its state and\n\t * update time, plus each input the call's `etagIncludes` listed — and NOT the provider's HTTP ETag. Send it back\n\t * as the target's `etag`. An etag from another scheme or another `etagIncludes` set simply compares unequal and\n\t * costs a full read, never a false `unchanged`. A host can add a reaction without moving the update time, so\n\t * unless `'reactions'` is listed, an `unchanged` copy's `thumbsUpCount` may be stale.\n\t */\n\tetag?: string;\n\t/** The caller's copy is current (its `etag` matched); `issue` is absent because nothing was read. */\n\tunchanged?: true;\n}\n\n/** One pull request to resolve, identified by coordinate and echoed back under the caller's own `key`. */\nexport interface PullRequestBatchTarget {\n\t/** Caller-owned identifier, echoed on the result so no positional matching is needed. Must be unique. */\n\tkey: string;\n\t/**\n\t * GitHub owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or\n\t * Azure DevOps organization.\n\t */\n\towner: string;\n\t/** Repository name or slug. */\n\trepo: string;\n\t/** Pull request number, GitLab merge request iid, or Azure DevOps pull request id. */\n\tnumber: number;\n\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\tproject?: string;\n\t/**\n\t * The {@link PullRequestBatchResult.etag} of the copy the caller holds. When the host can check it cheaply and\n\t * it still matches, the pull request isn't read again and comes back `unchanged`.\n\t */\n\tetag?: string;\n}\n\n/**\n * The answer for one {@link PullRequestBatchTarget}, in one of four states:\n * - `{ key, pullRequest, etag }` — read in full, whatever its state. Every fully read row carries an `etag`,\n * whether or not the caller sent one, so a caller can seed its etags from the reads it already makes.\n * - `{ key, unchanged: true, etag }` — the cheap check proved the caller's copy current, and nothing else was\n * fetched. Only for a target that sent an `etag`, on a host with a cheap check.\n * - `{ key }` — PROVEN ABSENT: it does not exist, or is not visible to this connection.\n * - no row, with `fetchFailed` and a warning — the read could not check. Never treat that as absent.\n */\nexport interface PullRequestBatchResult {\n\tkey: string;\n\t/**\n\t * The resolved pull request, whatever its state, or `undefined` when it PROVABLY does not exist (or is not\n\t * visible to this connection) — or when it is `unchanged`. A target whose read FAILED is not returned at\n\t * all and sets `fetchFailed`.\n\t */\n\tpullRequest?: PullRequestShape;\n\t/**\n\t * Opaque: compare for equality only, never parse. Computed by core from the pull request's change state — its\n\t * state, draft flag, update time and head commit (on Azure DevOps, also a revision of the fields it changes without\n\t * an update time), plus each input the call's `etagIncludes` listed — and NOT the provider's HTTP ETag. Send it\n\t * back as {@link PullRequestBatchTarget.etag}. An etag from another scheme or another `etagIncludes` set simply\n\t * compares unequal and costs a full read, never a false `unchanged` — and so does one from a read that selected\n\t * merge-queue data (see {@link IntegrationManager.getPullRequestsBatch}'s `mergeQueue`), or check runs\n\t * (`checkRuns`), when the other didn't.\n\t * Reactions are never an input: a host can add one without moving the update time, so an `unchanged` copy's\n\t * `thumbsUpCount` may be stale.\n\t */\n\tetag?: string;\n\t/** The caller's copy is current (its `etag` matched); `pullRequest` is absent because nothing was read. */\n\tunchanged?: true;\n}\n\n/** One branch whose pull requests to find, echoed back under the caller's own `key`. */\nexport interface PullRequestBranchTarget {\n\t/** Caller-owned identifier, echoed on the result so no positional matching is needed. Must be unique. */\n\tkey: string;\n\t/**\n\t * The repository the pull requests are OPENED AGAINST (their base), as in `PullRequestBatchTarget`: GitHub\n\t * owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or Azure\n\t * DevOps organization.\n\t */\n\towner: string;\n\t/** Repository name or slug. */\n\trepo: string;\n\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\tproject?: string;\n\t/** The head branch's short name, without `refs/heads/`. */\n\tbranch: string;\n\t/**\n\t * Owner (GitHub user or org, GitLab namespace, Bitbucket workspace) of the repository the branch lives in, when\n\t * it's a fork. Omitted, or equal to `owner` (ignoring case), means the branch lives in the base repository itself,\n\t * so a caller can pass the owner of whichever remote the branch was pushed to. On GitLab this is the whole\n\t * namespace path, as `owner` is, so a remote's first-slash split can't be passed for either.\n\t *\n\t * A different owner is refused on Bitbucket Data Center and Azure DevOps, where a fork can't be found by its\n\t * owner.\n\t */\n\theadOwner?: string;\n}\n\n/** The answer for one {@link PullRequestBranchTarget}. */\nexport interface PullRequestBranchResult {\n\tkey: string;\n\t/**\n\t * Every pull request whose head is this branch, in ANY state — open, closed and merged — most recently updated\n\t * first, up to a per-target cap. An empty array is a PROVEN \"none\" unless `truncated` is set. A target whose\n\t * read failed is not returned at all.\n\t */\n\tpullRequests: PullRequestShape[];\n\t/**\n\t * Set when a pull request that wasn't returned could still match: more matched than the cap, or the host held\n\t * more pull requests of this branch name than it returned and couldn't rule them out. GitHub/GHE rule them out\n\t * with a second request filtered by head owner, so there it means more than the cap truly match. That request\n\t * can't see a pull request from a since-deleted fork, so on GitHub/GHE such a pull request outside the first\n\t * request's page can be missing even when this is not set.\n\t */\n\ttruncated?: boolean;\n}\n\n/** The answer for one SHA of {@link IntegrationManager.getPullRequestsForCommits}'s input. */\nexport interface PullRequestForCommitResult {\n\t/** The SHA as the caller passed it (trimmed), echoed so no positional matching is needed. */\n\tsha: string;\n\t/**\n\t * The pull request the commit belongs to, or `undefined` when the host ANSWERED that it has none (or when the SHA\n\t * is the working tree's all-zero one, which is never sent): a resolved \"none\" a caller can cache. A SHA whose read\n\t * FAILED is not returned at all and sets `fetchFailed`.\n\t *\n\t * When a commit belongs to several, the one the single-commit lookup returns, which each host picks its own way —\n\t * see {@link IntegrationManager.getPullRequestsForCommits}.\n\t */\n\tpullRequest?: PullRequestShape;\n}\n\n/** One check whose log to read, echoed back under the caller's own `key`. */\nexport interface PullRequestCheckLogTarget {\n\t/** Caller-owned identifier, echoed on the result. Must be unique. */\n\tkey: string;\n\towner: string;\n\trepo: string;\n\t/** A `PullRequestCheckRun.id` from a batch pull request read, as it came. */\n\tcheckRunId: string;\n}\n\n/** The answer for one {@link PullRequestCheckLogTarget}: exactly one of `log` and `unavailable` is set. */\nexport type PullRequestCheckLogResult = PullRequestCheckLog & { readonly key: string };\n\n/** One pull request whose activity to read, echoed back under the caller's own `key`. */\nexport interface PullRequestActivityTarget {\n\t/** Caller-owned identifier, echoed on the result. Must be unique. */\n\tkey: string;\n\towner: string;\n\trepo: string;\n\tnumber: number;\n\t/** The {@link PullRequestActivityResult.cursor} of this pull request's last read. Omit it, or send `''`, for a first read. */\n\tcursor?: string;\n}\n\n/** The answer for one {@link PullRequestActivityTarget}. */\nexport interface PullRequestActivityResult {\n\tkey: string;\n\t/** New activity after the target's cursor, in GitHub's timeline order. A review's inline comments follow the review. */\n\titems: readonly PullRequestActivityItem[];\n\t/** Opaque: send it back as the target's `cursor` on the next read. */\n\tcursor: string;\n\t/** More items follow this page; read again with `cursor`. */\n\thasMore: boolean;\n\t/** The pull request (or its repository) does not exist or is not visible to this connection. */\n\tnotFound?: true;\n}\n\n/**\n * \"Who am I on this provider / connection\" — {@link IntegrationBase.getCurrentAccount}'s own answer, exposed on\n * the manager so a caller can ask for it directly instead of waiting for some other read to warm it as a side\n * effect.\n */\nexport interface CurrentAccountResult {\n\t/** The signed-in account, when the provider answered. */\n\taccount?: Account;\n\twarnings: ProviderWarning[];\n\t/**\n\t * Set whenever `account` is absent. Unlike a list/batch read, this one has no benign empty answer — \"who am\n\t * I\" is either resolved or it couldn't be told, never a legitimately empty result — so `account` is never\n\t * missing without a warning explaining why.\n\t */\n\tfetchFailed?: boolean;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"results.js","names":[],"sources":["../../../../plus/integrations/src/results.ts"],"sourcesContent":["import { isUnsupportedSortError } from '@gitkraken/provider-apis';\nimport { AuthenticationError, RequestNotFoundError, RequestRateLimitError } from '@gitlens/git/errors.js';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { IssueSearchCriteria, IssueShape, IssueSorting } from '@gitlens/git/models/issue.js';\nimport type {\n\tPullRequestCheckLog,\n\tPullRequestSearchCriteria,\n\tPullRequestShape,\n\tPullRequestSorting,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { PullRequestActivityItem } from '@gitlens/git/models/pullRequestActivity.js';\nimport type { IntegrationIds } from './constants.js';\nimport { isProviderUnreachableError } from './errors.js';\nimport type { ProviderRepositoriesInput } from './manager.js';\nimport { UnexpectedResponseError } from './providers/providerErrors.js';\n\nexport interface ConnectionStateChangeEvent {\n\tkey: string;\n\treason: 'connected' | 'disconnected';\n}\n\n/**\n * A per-provider, per-connection warning surfaced alongside (partial) read results. Consumers use\n * these to drive auth recovery, retry, or truncation messaging without the read itself throwing.\n *\n * `kind` is the programmatic discriminant (a rate-limit is retryable, a 404 is not, an unsupported capability\n * never succeeds on retry, an auth failure needs re-connection unless {@link ProviderWarning.scope} confines\n * it); `isAuth` is retained as a convenience mirror of `kind === 'auth'`.\n *\n * `'unsupported'`: the provider — or this integration of it — lacks the capability the request asked for: a\n * surface (issues on Bitbucket, pull requests on an issue tracker, a batch read, org/repo discovery,\n * current-account lookup, project-scoped or account-wide issue reads), or a filter, sort, state, search\n * criterion or option combination it cannot express. Retrying the same request never succeeds; a different\n * provider, scope or request may. NOT unsupported (these stay `'other'`): malformed or contradictory caller\n * input the caller fixes in the request itself (a duplicate batch key, invalid target numbers, an empty owner,\n * an unusable scope), incompleteness or omission warnings, and unclassified errors.\n *\n * `'unreadable-items'`: the provider returned items this read could not read (a Jira issue whose fields the SDK cannot\n * parse), so it left them out and read everything else in the warning's {@link ProviderWarning.scope}. It still fails\n * the read (`fetchFailed`), since those items are missing, but retrying returns the same gap. On the reads that publish\n * it (an issue tracker's project reads) it never hides a read that was cut short: a cut always comes with a warning of\n * another kind. {@link ProviderWarning.unreadableItems} names the items left out.\n */\nexport type ProviderWarningKind =\n\t| 'auth'\n\t| 'rate-limit'\n\t| 'not-found'\n\t| 'no-connection'\n\t| 'unsupported'\n\t| 'unreadable-items'\n\t| 'other';\n\n/** The items an `'unreadable-items'` warning left out: see {@link ProviderWarning.unreadableItems}. */\nexport interface ProviderWarningUnreadableItems {\n\t/**\n\t * The provider's identifiers of the items left out (a Jira issue's key), without duplicates, in reported order. Each\n\t * one is an item the provider reported as skipped, so an identifier present is one that was left out, and one absent\n\t * was read when {@link complete}.\n\t *\n\t * Both hold only for the spelling the provider returned, which is also how a published issue's id spells its key: `keys`\n\t * doesn't answer a lookup by another spelling, such as a different case or the key an issue had before it moved. A\n\t * consumer comparing a key from elsewhere (one parsed from a branch name, say) must normalize the case of both sides,\n\t * and can't take an issue under a key it once had as read.\n\t */\n\tkeys: string[];\n\t/**\n\t * Whether {@link keys} names every item left out. `false` when an item left out had no key to report, when the\n\t * provider's report of them was malformed (no list of keys, or more than keys in it), or when it said items were left\n\t * out and named none, so an identifier absent from `keys` may still be one of them.\n\t */\n\tcomplete: boolean;\n}\n\n/**\n * Why a read that SUCCEEDED still withheld results:\n * - `provider-limit`: the provider refuses to serve past a cap it enforces (GitHub search's 1,000-result\n * ceiling, Trello's `cards_limit`), so the excess is unreachable through that query.\n * - `recovery-budget`: the internal partitioned recovery stopped spending upstream requests before it ran\n * out of partitions to visit.\n * - `pagination-incomplete`: pages were left unread — a sub-scope of a multi-scope read that was not drained,\n * a drain that stopped at its own page backstop, or a provider that advertised another page and gave no way\n * to reach it. These have DIFFERENT remedies, so the kind alone does not say whether more can be fetched;\n * read {@link ProviderWarningOmission.recovery} for that.\n *\n * Mirrors the vocabulary the SDK reports. Declared here rather than imported so this module stays free of\n * `@gitkraken/provider-apis` types (see the export block in `index.ts`); `collectionMetadata.ts` holds the\n * compile-time link, so an SDK bump that adds a kind fails the build at that boundary.\n */\nexport type ProviderWarningOmissionKind = 'provider-limit' | 'recovery-budget' | 'pagination-incomplete';\n\n/**\n * How a consumer can recover omitted results. `page-budget` reruns with a larger budget; `narrow-scope`\n * requests a smaller server-side scope; `none` promises neither. Switch on the exact value because only\n * `page-budget` is a fetch-more action.\n */\nexport type ProviderWarningOmissionRecovery = 'none' | 'page-budget' | 'narrow-scope';\n\n/**\n * The part of a provider a warning is confined to: one resource (organization, workspace, site), project or\n * repository. All fields optional; see {@link ProviderWarning.scope} for when one is forwarded.\n */\nexport interface ProviderWarningScope {\n\t/**\n\t * The resource as the read addressed it: its id on most reads, its name on the few that address it by name\n\t * (Azure DevOps' repo-scoped reads, Bitbucket's workspace reads). Match it against both\n\t * `ProviderOrganization.id` and `name`, and a project's `orgId` where it has one.\n\t */\n\tresourceId?: string;\n\t/**\n\t * The project as the read addressed it. For a Jira project read, the key, on Jira Cloud and Jira Data Center alike\n\t * (the project's `name` in `listProjects`).\n\t */\n\tprojectId?: string;\n\trepositoryId?: string;\n}\n\n/**\n * The selector of an issue-tracker project read that matched nothing: see {@link ProviderWarning.selector}. `kind`\n * names which one missed, and `value` is that selector exactly as the caller passed it. `linearProject` is one of a\n * Linear read's `linearProjects`, an id the workspace's Projects no longer list.\n */\nexport interface ProviderWarningSelector {\n\tkind: 'org' | 'project' | 'linearProject';\n\tvalue: string;\n}\n\n/**\n * Why a provider request failed, when the failure itself says so:\n * - `unreachable`: a transport failure or server-side error prevented the provider from answering. The connection\n * still exists; this accompanies `kind: 'other'`, never an authentication warning.\n * - `oauth-app-not-allowed`: the organization does not let third-party OAuth apps in. On Azure DevOps this is the\n * organization policy \"Third-party application access via OAuth\", off by default for new organizations. An\n * organization admin enables it, or the user connects with a personal access token instead, which the policy\n * does not govern.\n * - `access-denied`: the account has no access to that organization or project (not a member, or lacking the\n * permission). Someone who administers it has to grant access.\n * - `conditional-access`: a Microsoft Entra Conditional Access policy blocked the request (Azure DevOps\n * `VS403463`). Its admin has to exempt the request, e.g. by location or device.\n * - `unexpected-response`: the provider answered, but not with data in the shape the read expects (a gateway's JSON\n * error on a 2xx, an empty object, `null`), so the read could not use it. Accompanies `kind: 'other'`, like\n * `unreachable`; a retry may succeed once the provider, or whatever answered in front of it, answers properly. A\n * page served instead of data keeps its own message, without this cause.\n *\n * None of these is healed by reconnecting, which is the point of naming them.\n */\nexport type ProviderWarningCauseReason =\n\t| 'oauth-app-not-allowed'\n\t| 'access-denied'\n\t| 'conditional-access'\n\t| 'unreachable'\n\t| 'unexpected-response';\n\n/** See {@link ProviderWarning.cause}. */\nexport interface ProviderWarningCause {\n\treason: ProviderWarningCauseReason;\n\t/** The provider's own error code, when it reports one (Azure DevOps `TF400813`, `VS403463`). */\n\tcode?: string;\n\t/** Where the setting behind the refusal is changed, when this layer can address it. */\n\tremedyUrl?: string;\n}\n\n/** Which repository / project / resource an omission is attributed to. All fields optional; a scope may name none. */\nexport interface ProviderWarningOmissionScope extends ProviderWarningScope {\n\tproviderId?: string;\n}\n\nexport interface ProviderWarningOmission {\n\tkind: ProviderWarningOmissionKind;\n\t/**\n\t * Whether anything would fetch the missing items, and what. Gate a \"load more\" affordance on this rather\n\t * than on `kind` — see {@link ProviderWarningOmissionRecovery}.\n\t */\n\trecovery: ProviderWarningOmissionRecovery;\n\t/**\n\t * The cap the provider enforces, when it reports one. NOT a result count for every kind: on\n\t * `recovery-budget` this is a REQUEST budget and must not be shown to a user as a number of results.\n\t */\n\tlimit?: number;\n\t/** Total matches the provider reported, when it reports one. Only GitHub's search cap does today. */\n\ttotalCount?: number;\n\t/**\n\t * The order the reachable window was selected under, as `field:direction`, when the omission is a result\n\t * ceiling.\n\t *\n\t * Present so a consumer can word its own \"N matched, showing the first M\" without assuming WHICH M: the\n\t * provider serves the top M under this key, so the sentence is only true if it names it. Absent for every\n\t * omission that isn't a ceiling, where no window was selected by an order.\n\t *\n\t * A union of both vocabularies rather than the issue one alone: `PullRequestSorting` happens to be a subset\n\t * today, so narrowing this to {@link IssueSorting} would still compile while describing only half the reads\n\t * that set it — and would break the day the PR search gains a key the issue search has no name for.\n\t */\n\tsort?: IssueSorting | PullRequestSorting;\n\t/** Which repository / project / resource was affected, when one is attributed. */\n\tscope?: ProviderWarningOmissionScope;\n}\n\nexport interface ProviderWarning {\n\tproviderId: IntegrationIds;\n\t/** Disambiguates connections on self-managed hosts (where one provider id spans multiple domains). */\n\tdomain?: string;\n\t/** The specific token/connection the read was pinned to, when a `connectionId` was supplied. */\n\tconnectionId?: string;\n\tmessage: string;\n\tkind: ProviderWarningKind;\n\t/** Convenience mirror of `kind === 'auth'`, scoped or not; read {@link scope} before prompting to reconnect. */\n\tisAuth: boolean;\n\t/**\n\t * Present when the failure was recorded against one sub-scope of the read (an organization, project or\n\t * repository) rather than against the connection. A scoped `auth` failure is that one scope refusing this\n\t * credential, e.g. an Azure DevOps organization that disallows third-party OAuth apps, one in another Entra\n\t * tenant, or a Conditional Access policy. Reconnecting cannot fix those, so this warning alone is no reason\n\t * to prompt for it.\n\t *\n\t * `kind` and `isAuth` are unaffected: a scoped 401 is still an authentication failure, and this field says\n\t * how far it reaches. It names at least one of its IDs, and is never set on an omission (which carries its\n\t * own {@link ProviderWarningOmission.scope}) or on a warning derived from a caught exception (see\n\t * {@link toProviderWarning}), even when that call targeted a single organization. The exception is a batch\n\t * read's refused target, which names its scope: the Azure DevOps organization and project, the repository on\n\t * other git hosts, or the tracker's resource.\n\t *\n\t * Its ABSENCE means account-wide or unattributed, so existing handling stays correct without it.\n\t *\n\t * A scoped `auth` failure also means the credential itself was accepted. A dead token can come back as nothing\n\t * but scoped refusals wherever a read reaches its scopes without an uncached request to the connection first:\n\t * discovery served from a per-token cache (Azure DevOps, Bitbucket, Jira Cloud) or an SDK fan-out across the\n\t * requested repositories (Bitbucket Data Center). So when a read's only auth failures are scoped, those providers\n\t * confirm the credential with one uncached check first, and a refused credential fails the whole read with an\n\t * unscoped `auth` warning. A batch read checks it only when every target was refused, since a target that\n\t * answered already proved it. A refusal the provider attributes to the credential itself, like Bitbucket's or Jira\n\t * Cloud's for a token missing the OAuth scopes a read needs, which a reconnect fixes, is published unscoped too,\n\t * once for the connection, while the scopes that answered keep their results.\n\t *\n\t * So the promise holds for a read that carries no unscoped `auth` warning of its own; one that does already asks\n\t * for a reconnect, and its other scoped refusals are not checked. Two exceptions stay scoped even then. A check\n\t * that could not complete or was denied (a network error, a throttle, a `403`, Bitbucket Data Center refusing a\n\t * credential it authenticated, or a Bitbucket Data Center project access token, whose user the check cannot\n\t * find) proves nothing, so the warnings are published unconfirmed, with no {@link cause}, and the next read\n\t * checks again. And a credential confirmed within the last minute is not probed again, so a revocation can take\n\t * up to a minute to surface.\n\t */\n\tscope?: ProviderWarningScope;\n\t/**\n\t * Why the provider request failed, when the failure itself says so: see {@link ProviderWarningCauseReason}. Switch on\n\t * `reason` to recommend a fix instead of a reconnect; `message` then carries the same explanation as prose.\n\t *\n\t * `unreachable` accompanies a transport or server failure with `kind: 'other'`, and `unexpected-response` a response\n\t * the read could not use, also with `kind: 'other'`. Credential refusal causes are set only on a scoped `auth`\n\t * warning whose credential was confirmed first (see {@link scope}), because the\n\t * refusals they name are indistinguishable from a dead credential until then: Azure DevOps answers a\n\t * third-party OAuth app its organization disallows exactly as it answers an expired token. Only Azure DevOps\n\t * reports one today. Its absence proves nothing about the cause.\n\t */\n\tcause?: ProviderWarningCause;\n\t/**\n\t * Present when this warning describes results the read could not return even though the request itself\n\t * SUCCEEDED — a provider-enforced cap, an exhausted recovery budget, a page budget, or a sub-scope the read\n\t * did not drain.\n\t *\n\t * Its presence is the signal: an omission is not a failure. Message it as incompleteness rather than as a\n\t * failed read, and do NOT derive that from `message`, which is English prose and subject to rewording.\n\t * `kind` stays `'other'` for these, so the failure discriminant keeps meaning exactly what it meant before\n\t * this field existed.\n\t *\n\t * Whether anything would fetch the rest is a SEPARATE question — read {@link ProviderWarningOmission.recovery},\n\t * not `kind`, and never assume a retry of the same request returns more.\n\t *\n\t * `limit` / `totalCount` / `scope` are forwarded only when they are reported; most omissions carry none of\n\t * the three, so render correctly without them — and see {@link ProviderWarningOmission.limit} before\n\t * showing that figure as a result count.\n\t *\n\t * Its ABSENCE proves nothing. It is never set on a warning derived from a caught exception (see\n\t * {@link toProviderWarning}) or from a structured scope failure — those are failures, and the field would\n\t * be a lie there. But it is also absent whenever incompleteness was reported without naming what was left\n\t * out, so treat a bare `kind: 'other'` warning as unclassified rather than as a proven failure.\n\t */\n\tomission?: ProviderWarningOmission;\n\t/**\n\t * Present exactly when {@link kind} is `'unreadable-items'`: which items the read left out because it could not read\n\t * them. A consumer deciding whether an identifier is absent from the provider, rather than merely unread, must find\n\t * it in no warning's `keys` and see `complete` on every one.\n\t */\n\tunreadableItems?: ProviderWarningUnreadableItems;\n\t/**\n\t * Present when an issue-tracker project read's `org` or `project` selector matched nothing the connection\n\t * discovered: the selection was removed, renamed, or is no longer visible to this connection. `kind` is\n\t * `'not-found'`, the page is empty and not `fetchFailed`, and it carries no cursor, since a retry finds the same.\n\t * A `linearProject` miss is diagnostic: the requested Project ids still filter the read, preserving issues in\n\t * other selected Projects. It therefore does not force an empty page or remove its continuation.\n\t *\n\t * Set only when discovery was complete. A read whose discovery failed or was truncated cannot tell a missing\n\t * selection from one it did not reach, so it keeps reporting that failure instead, without this field. A miss is\n\t * confirmed against the connection's lists as the provider holds them now, read without the cache, since a cached\n\t * one predates what was created since. A cached project list can still name a project deleted since: the tracker\n\t * refuses it (Jira's \"does not exist for the field 'project'\"), it reads as empty, and the refusal drops that list,\n\t * so the next read reports the miss. Jira Data Center's refusal counts only when it names the user it\n\t * authenticated: it answers a rejected token the same way, as the anonymous user. The miss waits on an account\n\t * lookup on a resource those lists name, which confirms the\n\t * connection's credential, and a failed lookup is reported as the read's failure instead; an account that lists no\n\t * resource at all has none to look up, and is judged on its lists alone.\n\t *\n\t * It is the discriminant: a `not-found` without it is a request that failed with a 404, 410 or 422.\n\t */\n\tselector?: ProviderWarningSelector;\n\t/**\n\t * The keys of the batch targets this warning concerns: the target a per-target failure was refused or failed\n\t * for, or every target of an integration call that failed as a whole. So a caller that sends several callers'\n\t * targets in one call can hand a failure only to the targets it belongs to.\n\t *\n\t * Its ABSENCE means the whole call. It is absent on every read that is not a batch read, and on a batch read's\n\t * refusal of the whole call before any target is read (a duplicate key, an invalid target, an unknown etag\n\t * include, no resolvable connection, the wrong surface), which concerns every target alike.\n\t *\n\t * It is not part of a warning's identity: two warnings that differ only here are one warning, for the union of\n\t * their targets (see {@link appendDedupedWarning}).\n\t */\n\ttargetKeys?: string[];\n}\n\nexport interface ProviderPageInfo {\n\t/**\n\t * The 1-based POSITION of the returned page. One convention across every paged read, page-number and\n\t * cursor paging alike, so a `getNextPageParam`-style consumer can key off it uniformly:\n\t * - the page number the provider itself reported, when it reports one (authoritative);\n\t * - else the position the caller addressed: the page encoded in a threaded page cursor, or the `page`\n\t * supplied alongside an opaque cursor (1 when the caller supplied no `page`);\n\t * - else, for a read that can be advanced by page number, the requested `page` — the provider either\n\t * honored it or the internal drain reached it (see the paging contract on `IntegrationManager`);\n\t * - else 1: a cursor-only read with no cursor threaded back ignores a requested page number and answers\n\t * with its first page, so echoing the request would mislabel page 1 as page N.\n\t *\n\t * A page past the provider's terminal cursor still reports the requested `page` with empty `items` — an\n\t * empty page N, never page N-1 relabeled.\n\t *\n\t * Continue a cursor-paged read from `cursor`, NOT from `currentPage + 1`: a cursor-only host can't be\n\t * addressed by number, so this is a position label and not always a resumable request parameter.\n\t */\n\tcurrentPage: number;\n\t/**\n\t * The page size IN EFFECT, which is not always the one requested — it is whichever of these the read can\n\t * actually vouch for:\n\t * - the size the provider reported for the page it served (numbered-page hosts), else\n\t * - the `itemsPerPage` that was applied to the request (repo-scoped reads, which forward it), else\n\t * - `items.length`, for a read that takes no page size at all: the account-wide PR/issue reads, `listRepos`\n\t * (cursor-only), and `listIssueTrackerIssuesPage`, whose `itemsPerPage` counts PROJECTS rather than issues.\n\t *\n\t * So it is a description of the page, not an echo of the request: don't derive a total from\n\t * `currentPage * itemsPerPage`, and don't read `items.length < itemsPerPage` as \"last page\" — `hasMore` /\n\t * `cursor` are the only continuation signals.\n\t */\n\titemsPerPage: number;\n\t/**\n\t * A COMPLETENESS assertion, not a mode flag: `true` only when a sweep drained every page of every target\n\t * without truncating or failing (`!truncated && !fetchFailed`). Set exclusively by `sweepPullRequests` /\n\t * `sweepClosedPullRequests` and absent on every paged read, so `allPages !== true` does NOT by itself mean\n\t * \"this was a single page\".\n\t *\n\t * This is the signal to gate on before caching a sweep as authoritative: unlike `truncated` it is `false`\n\t * for BOTH kinds of incompleteness, so it can't be misread as a benign cap.\n\t */\n\tallPages?: boolean;\n\t/**\n\t * True when the read stopped before it could confirm it had everything. Deliberately does NOT distinguish\n\t * WHY, and a consumer must not assume it means a provider ceiling — a sweep sets it from three different\n\t * origins:\n\t * - a provider-side ceiling or per-scope backstop propagated from below (e.g. GitHub Search's 1000-result\n\t * cap): the missing items are NOT reachable, so this really is \"complete to the provider's limit\";\n\t * - the sweep's OWN `maxPages` cap (default 100) with a usable cursor still in hand: the missing items ARE\n\t * reachable and were simply not fetched — raise `maxPages` to get them;\n\t * - the provider reporting another page but handing back no usable cursor: not reachable.\n\t *\n\t * Only the second is recoverable, and a sweep exposes no continuation cursor, so treating a truncated sweep\n\t * as a complete set silently drops reachable data in that case. Prefer `allPages` for the cache decision.\n\t */\n\ttruncated?: boolean;\n}\n\nexport interface ProviderResult<T> {\n\titems: T[];\n\twarnings: ProviderWarning[];\n\t/**\n\t * True when `items` is incomplete — distinguishes a failed or truncated flat read from a genuinely empty\n\t * result. Paged results additionally use `page.truncated` when a completed page could not confirm it\n\t * drained everything.\n\t */\n\tfetchFailed?: boolean;\n}\n\nexport interface ProviderPagedResult<T> extends ProviderResult<T> {\n\t/**\n\t * True when a request failed. Unlike `fetchFailed`, a collection read successfully that only left some of its items\n\t * unreadable doesn't set it; those items are named by their own warnings.\n\t */\n\trequestFailed?: boolean;\n\t/** True when the provider advertised continuation without a usable cursor or page position, or repeated one. */\n\tunexpectedGap?: boolean;\n\tpage: ProviderPageInfo;\n\thasMore: boolean;\n\t/**\n\t * Opaque cursor for cursor-based paging (GraphQL, per-repo/per-project cursors, etc.). For hosts that\n\t * require the previous page's cursor, consumers should pass this value back to the next `cursor` option.\n\t * A retry-only cursor may remain when `hasMore` is false: `hasMore` means automatic forward progress,\n\t * while explicitly reusing such a cursor retries failed work without creating an infinite paging loop.\n\t */\n\tcursor?: string;\n}\n\n/**\n * One sweep target, named the way {@link ProviderSweepTargetEvent} names it, so a consumer can join the two.\n * `domain` is the resolved self-managed host (always `undefined` for a cloud provider).\n */\nexport interface ProviderSweepTargetRef {\n\tproviderId: IntegrationIds;\n\tconnectionId: string | undefined;\n\tdomain: string | undefined;\n}\n\n/**\n * A sweep may carry several targets of one provider (one per connection), so the provider arrays below can't say\n * which connection failed: `failedTargets` and `incompleteTargets` are the authoritative attribution, and\n * `failedProviderIds`/`incompleteProviderIds` summarize them. With one target per provider the two agree exactly.\n */\nexport interface ProviderSweepResult<T> extends ProviderResult<T> {\n\tpage: ProviderPageInfo;\n\thasMore: boolean;\n\t/**\n\t * Providers whose top-level read failed before returning any usable page, for EVERY attributed target of the\n\t * provider. A provider with a failed target and a surviving sibling is in `incompleteProviderIds` instead.\n\t * Partial per-scope failures stay represented by `warnings` + `fetchFailed` and are intentionally excluded.\n\t */\n\tfailedProviderIds: IntegrationIds[];\n\t/**\n\t * Providers whose read started successfully but could not produce an authoritative complete slice (for\n\t * example, a later page failed, collection metadata reported a partial scope, or a paging backstop was hit),\n\t * or that have a failed target beside one that returned something.\n\t * Kept separate from\n\t * `failedProviderIds` so consumers can accept healthy sibling providers while preserving an older snapshot\n\t * for a provider whose returned slice has a gap.\n\t */\n\tincompleteProviderIds: IntegrationIds[];\n\t/** Targets whose top-level read failed before returning any usable page. A skipped target is in neither list. */\n\tfailedTargets: ProviderSweepTargetRef[];\n\t/** Targets that returned a slice with a gap: a later page failed, or pages remain unread. Never also in `failedTargets`. */\n\tincompleteTargets: ProviderSweepTargetRef[];\n}\n\nexport interface ProviderPullRequestSearchResult extends ProviderPagedResult<PullRequestShape> {\n\t/**\n\t * With `criteria.changedSince`, the open pull requests the same search reports with `states: ['open']` and no\n\t * `changedSince`. Absent when the count wasn't read: verify with a full read.\n\t */\n\topenCount?: number;\n}\n\nexport interface ProviderBroadenResult<T> extends ProviderPagedResult<T> {\n\tbroadenedProviderIds: IntegrationIds[];\n\t/** Providers for which no requested org produced a usable issue result. */\n\tfailedProviderIds: IntegrationIds[];\n\t/** Providers with both a usable org result and at least one failed or truncated org slice. */\n\tincompleteProviderIds: IntegrationIds[];\n\tfanOutCount: number;\n}\n\nexport type RepositoryResolutionStatus =\n\t| 'resolved'\n\t| 'not-found'\n\t| 'unauthorized'\n\t| 'unsupported-provider'\n\t| 'invalid-remote-url'\n\t| 'host-mismatch'\n\t| 'undetermined';\n\nexport interface RepositoryIdentity {\n\tproviderId: IntegrationIds;\n\tdomain: string;\n\t/**\n\t * The provider's canonical owner/namespace (follows renames), falling back to where it was read when omitted. On\n\t * GitLab it is the whole group path (`group/subgroup`), not the remote path's first segment.\n\t */\n\towner: string;\n\t/** The provider's canonical repo name (follows renames), falling back to where it was read when omitted. */\n\tname: string;\n\tproject?: string;\n\t/** The original input remote URL, so the caller can key the resolution back to the remote it asked about. */\n\tremoteUrl: string;\n\t/**\n\t * True when the provider's canonical owner/name differ from what the input remote URL carried — i.e. the\n\t * repo was renamed/moved host-side and the local remote is stale. Owner and name are compared as one path, because\n\t * the remote and the provider split a GitLab nested group differently. Case-insensitive, mirroring gkcli's\n\t * `EqualFold` compare so hosts that echo the input casing (e.g. Bitbucket Server/Azure) aren't flagged. On Azure\n\t * DevOps it compares the repository name and its {@link project} too, against the collection and project the\n\t * repository was read at: an Azure DevOps Server remote's path may be read as another collection and project than\n\t * the remote parser read, which is no rename. GitLab's lookup doesn't follow a renamed or moved path, so a stale\n\t * GitLab remote resolves as `not-found` rather than as `renamed`.\n\t */\n\trenamed: boolean;\n\t/**\n\t * Whether the provider says this repository is a fork: `true` for a fork (including one it reports only by naming\n\t * its {@link parent}), `false` for a repository it reports as not one, `undefined` when it didn't say. Only\n\t * `false` is proof of \"not a fork\" — a missing {@link parent} is not.\n\t */\n\tisFork?: boolean;\n\t/**\n\t * The repository this one was forked from, named as the provider names it and living on the same host\n\t * ({@link providerId} and {@link domain}), so on GitLab `owner` is the whole group path (`group/subgroup`).\n\t * `project` is set only on Azure DevOps, where a repository lives in a project of its organization. Present only\n\t * when the provider reports a fork and names its parent; absent means \"not a fork\" or \"the provider didn't say\",\n\t * which {@link isFork} tells apart. This is the immediate parent, not the root of the fork network: a pull request\n\t * from a branch of this repository usually targets this repository or its parent, but GitHub and Azure DevOps let\n\t * it target any repository in the network, so a fork of a fork can open one against the root.\n\t */\n\tparent?: { owner: string; name: string; project?: string };\n}\n\nexport interface RepositoryResolution {\n\tstatus: RepositoryResolutionStatus;\n\tidentity?: RepositoryIdentity;\n\twarning?: ProviderWarning;\n}\n\nexport interface ResolveRepositoryResult {\n\tresolution: RepositoryResolution;\n}\n\nconst maxProviderWarningMessageLength = 500;\n\n/** A caught error's message as a warning can carry it: an HTML page becomes its status, and prose is capped. */\nexport function providerWarningMessage(ex: unknown): string {\n\tconst raw = (ex instanceof Error ? ex.message : String(ex)).trim();\n\tconst carrier = ex as { status?: unknown; response?: { status?: unknown } } | null | undefined;\n\tconst status =\n\t\ttypeof carrier?.status === 'number'\n\t\t\t? carrier.status\n\t\t\t: typeof carrier?.response?.status === 'number'\n\t\t\t\t? carrier.response.status\n\t\t\t\t: undefined;\n\n\t// Gateways commonly answer API requests with a complete HTML error page. That payload is neither actionable\n\t// nor suitable for a warning DTO consumed by UIs and logs; preserve the status without leaking the document.\n\tif (/<(?:!doctype\\s+html|html|head|body)\\b/i.test(raw)) {\n\t\treturn status != null ? `Provider request failed with status ${status}.` : 'Provider request failed.';\n\t}\n\n\tif (!raw) {\n\t\treturn status != null ? `Provider request failed with status ${status}.` : 'Provider request failed.';\n\t}\n\treturn raw.length > maxProviderWarningMessageLength\n\t\t? `${raw.slice(0, maxProviderWarningMessageLength - 3)}...`\n\t\t: raw;\n}\n\n/**\n * Normalized org/workspace/group shape returned by the provider facade.\n * `name` is the provider identifier to pass to follow-up reads (a Jira project's key), while `org` is an optional\n * display label of the parent. Where that label can't address the parent, `orgId` is the parent's stable id to pass\n * as `org` instead (a Jira site's id, or a Data Center instance's domain).\n *\n * Jira site rows (`listOrgs`) are the exception: their `name` is the site's label, and a Jira read selects a site only\n * by its `id` (or a project row's `orgId`).\n */\nexport interface ProviderOrganization {\n\tid: string;\n\tproviderId: IntegrationIds;\n\tname: string;\n\torg?: string;\n\torgId?: string;\n\turl: string;\n}\n\n/**\n * A Linear Project (Linear's own `Project` entity, which can span several teams), as `listLinearProjects` lists it.\n * Distinct from the teams `listProjects` publishes for Linear: pass its `id` to `listIssueTrackerIssuesPage`'s\n * `linearProjects` to narrow an issue read to it.\n */\nexport interface ProviderLinearProjectShape {\n\tid: string;\n\tproviderId: IntegrationIds;\n\tname: string;\n\t/** Linear's project state, as Linear names it (e.g. `planned`, `started`, `paused`, `completed`, `canceled`). */\n\tstate: string;\n\turl: string;\n}\n\n/** Normalized repository shape returned by the provider facade. */\nexport interface ProviderRepositoryShape {\n\tid: string;\n\tnamespace: string;\n\tname: string;\n\t/** Azure DevOps project; `undefined` for hosts without a project layer. */\n\tproject?: string;\n\t/** Web (browser) URL, when the provider exposes it. */\n\turl?: string;\n\t/** HTTPS clone URL, when available. */\n\tcloneUrlHttps?: string;\n\t/** SSH clone URL, when available. */\n\tcloneUrlSsh?: string;\n\t/** Default branch name, when the provider reports it. */\n\tdefaultBranch?: string;\n}\n\n/**\n * Classifies a caught provider exception into a neutral {@link ProviderWarning}. Ordering matters:\n * `instanceof` is checked most-specific-first so a rate-limit isn't mislabeled as a generic error and\n * a 404 isn't mislabeled as auth.\n */\nexport function toProviderWarning(\n\tproviderId: IntegrationIds,\n\tdomain: string | undefined,\n\tconnectionId: string | undefined,\n\tex: unknown,\n): ProviderWarning {\n\tlet kind: ProviderWarning['kind'];\n\tif (ex instanceof AuthenticationError) {\n\t\tkind = 'auth';\n\t} else if (ex instanceof RequestRateLimitError) {\n\t\tkind = 'rate-limit';\n\t} else if (ex instanceof RequestNotFoundError) {\n\t\tkind = 'not-found';\n\t} else if (isUnsupportedSortError(ex)) {\n\t\tkind = 'unsupported';\n\t} else {\n\t\tkind = 'other';\n\t}\n\n\tconst cause = kind === 'other' ? getRequestFailureCause(ex) : undefined;\n\treturn {\n\t\tproviderId: providerId,\n\t\tdomain: domain,\n\t\tconnectionId: connectionId,\n\t\tmessage: providerWarningMessage(ex),\n\t\tkind: kind,\n\t\tisAuth: kind === 'auth',\n\t\t...(cause != null ? { cause: cause } : {}),\n\t};\n}\n\n/**\n * The cause a failed request's error names by itself, one that isn't the credential's (`unexpected-response` or\n * `unreachable`), for a failure classified as no more specific than that.\n */\nexport function getRequestFailureCause(ex: unknown): ProviderWarningCause | undefined {\n\tif (UnexpectedResponseError.is(ex)) return { reason: 'unexpected-response' };\n\tif (isProviderUnreachableError(ex)) return { reason: 'unreachable' };\n\treturn undefined;\n}\n\n/**\n * A scope's identity, as the stable string that keys it.\n *\n * The single definition of what \"the same scope\" means, shared by the failure and omission dedup keys in\n * `providerPaging.ts` and by {@link providerWarningKey} below, so a scope gaining a field is one edit rather\n * than three. `providerId` is included: the same repository ID under two providers is two scopes.\n *\n * The parameter is structural rather than the SDK's `CollectionScope` so this module keeps naming no\n * `@gitkraken/provider-apis` types (see the export block in `index.ts`) while still serving its SDK-facing\n * callers, which pass that type in unchanged.\n */\nexport function collectionScopeKey(scope: ProviderWarningOmissionScope | undefined): string {\n\treturn [scope?.providerId ?? '', scope?.resourceId ?? '', scope?.projectId ?? '', scope?.repositoryId ?? ''].join(\n\t\t' ',\n\t);\n}\n\n/**\n * The omission's contribution to a warning's identity — empty when there is none, so a warning without an\n * omission keeps deduping exactly as it did before the field existed.\n *\n * Two omissions of different kinds do produce different `message` values today, so message alone would still\n * separate them. That is incidental: the premise of `omission` is that consumers must not depend on prose\n * carrying the distinguishing fact, and this key must not either.\n */\nfunction providerWarningOmissionKey(omission: ProviderWarningOmission | undefined): string {\n\tif (omission == null) return '';\n\n\treturn [\n\t\tomission.kind,\n\t\tomission.recovery,\n\t\tomission.limit ?? '',\n\t\tomission.totalCount ?? '',\n\t\tcollectionScopeKey(omission.scope),\n\t].join(' ');\n}\n\n/**\n * Strips the omission from every warning in `warnings` when the read as a whole failed.\n *\n * An omission asserts the request SUCCEEDED, and a drain only learns it failed AFTER it may have emitted one:\n * an early page can report its own truncation and then a later page can die. Deciding per warning, at the\n * moment each is built, cannot see that future — so the aggregate is reconciled once, here, where\n * `fetchFailed` is final. Call it at the point a read returns its `fetchFailed`.\n *\n * Re-dedupes as it goes: the omission is part of a warning's identity, so two warnings that differed only\n * there become identical once it is gone, and the array's contract is that no two entries are equal.\n *\n * Mutates in place: the warning array is the one being returned, and callers accumulate into it across pages.\n */\nexport function reconcileOmissionsWithFailure(warnings: ProviderWarning[], fetchFailed: boolean): void {\n\tif (!fetchFailed || !warnings.some(w => w.omission != null)) return;\n\n\tconst reconciled: ProviderWarning[] = [];\n\tfor (const warning of warnings) {\n\t\tif (warning.omission == null) {\n\t\t\tappendDedupedWarning(reconciled, warning);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst { omission: _omission, ...rest } = warning;\n\t\tappendDedupedWarning(reconciled, rest);\n\t}\n\n\twarnings.splice(0, warnings.length, ...reconciled);\n}\n\n/**\n * A stable key for deduplicating warnings accumulated across drained pages / fan-out scopes.\n *\n * The scope and the cause are keyed for the reason the omission is (see {@link providerWarningOmissionKey}): today's\n * failure messages happen to spell them out, but two failures that differ in either must stay two warnings even if\n * they don't.\n *\n * `message` stays LAST. It is the only free-form segment — provider prose, spaces and all — so anything\n * appended after it could be impersonated by a message that happens to end in the same text.\n */\nfunction providerWarningKey(warning: ProviderWarning): string {\n\treturn [\n\t\twarning.providerId,\n\t\twarning.connectionId ?? '',\n\t\twarning.domain ?? '',\n\t\twarning.kind,\n\t\tcollectionScopeKey(warning.scope),\n\t\twarning.cause?.reason ?? '',\n\t\tproviderWarningOmissionKey(warning.omission),\n\t\twarning.selector != null ? JSON.stringify([warning.selector.kind, warning.selector.value]) : '',\n\t\twarning.message,\n\t].join(' ');\n}\n\n/**\n * Appends `warning` to `into` only when an equal warning (by provider/connection/domain/kind/message, plus the\n * structured scope, cause, omission and selector when present) is absent. An equal warning already there merges its\n * {@link ProviderWarning.targetKeys} with the new one's instead: the union of both, or none when either concerns\n * the whole call. Its {@link ProviderWarning.unreadableItems} merge too (see {@link mergeUnreadableItems}): two reads\n * can report the same text for different items. The existing warning is replaced, never mutated, since it may be\n * shared.\n */\nexport function appendDedupedWarning(into: ProviderWarning[], warning: ProviderWarning): void {\n\tconst key = providerWarningKey(warning);\n\tconst index = into.findIndex(existing => providerWarningKey(existing) === key);\n\tif (index === -1) {\n\t\tinto.push(warning);\n\t\treturn;\n\t}\n\n\tconst existing = into[index];\n\tconst targetKeys = mergeTargetKeys(existing.targetKeys, warning.targetKeys);\n\tconst unreadableItems =\n\t\texisting.unreadableItems != null && warning.unreadableItems != null\n\t\t\t? mergeUnreadableItems(existing.unreadableItems, warning.unreadableItems)\n\t\t\t: (existing.unreadableItems ?? warning.unreadableItems);\n\tif (targetKeys === existing.targetKeys && unreadableItems === existing.unreadableItems) return;\n\n\tconst { targetKeys: _, ...rest } = existing;\n\tinto[index] = {\n\t\t...rest,\n\t\t...(targetKeys != null ? { targetKeys: targetKeys } : {}),\n\t\t...(unreadableItems != null ? { unreadableItems: unreadableItems } : {}),\n\t};\n}\n\n/** The union of two warnings' target keys, or none when either concerns the whole call. `existing` when unchanged. */\nfunction mergeTargetKeys(existing: string[] | undefined, next: string[] | undefined): string[] | undefined {\n\t// Either concerns the whole call.\n\tif (existing == null || next == null) return undefined;\n\n\tconst added = next.filter(k => !existing.includes(k));\n\tif (!added.length) return existing;\n\n\treturn [...existing, ...new Set(added)];\n}\n\n/**\n * The items two reports of unreadable items left out together: the union of their keys, complete only when both are.\n * `existing` when `next` adds nothing to it.\n */\nexport function mergeUnreadableItems(\n\texisting: ProviderWarningUnreadableItems,\n\tnext: ProviderWarningUnreadableItems,\n): ProviderWarningUnreadableItems {\n\tconst known = new Set(existing.keys);\n\tconst added = next.keys.filter(k => !known.has(k));\n\tconst complete = existing.complete && next.complete;\n\tif (!added.length && complete === existing.complete) return existing;\n\n\treturn { keys: [...existing.keys, ...new Set(added)], complete: complete };\n}\n\n// The count, batch, branch and current-account reads' input and result shapes. They live here rather than beside their\n// reads (`reads/*`) so the public facade can export them without its declarations reaching the reads' internal context.\n\n/**\n * One scope to count.\n *\n * `key` is caller-owned and echoed back verbatim, so a batch result needs no positional matching by the consumer.\n * It never reaches the provider query — the aliases in the upstream document are generated — so it can be any\n * string the caller finds meaningful.\n */\nexport interface IssueCountScope {\n\tkey: string;\n\t/** Repositories to count over. Combines with `org`, exactly as in `searchIssuesPage`. */\n\trepos?: ProviderRepositoriesInput;\n\torg?: string;\n\t/**\n\t * Same criteria model as `searchIssuesPage`, validated against the same capability table.\n\t *\n\t * `criteria.sort` does not affect the count — a total is invariant under ordering — but it is still VALIDATED,\n\t * and an unsupported key refuses this scope exactly as it would refuse the read. That is the point of the\n\t * count: it previews the constraints the read will apply, so one that accepted what the read refuses would\n\t * promise a fetch that can't happen, which is worse than no preview at all.\n\t */\n\tcriteria?: IssueSearchCriteria;\n}\n\n/** The count for one {@link IssueCountScope}, echoed back under the caller's own `key`. */\nexport interface IssueCountResult {\n\tkey: string;\n\t/**\n\t * Total matches the provider reports. `undefined` when the provider didn't report one for this scope — NEVER\n\t * zero, which is a real answer. Render the difference: an unreported count means \"unknown\", and showing it as\n\t * 0 would tell the user this filter matches nothing.\n\t */\n\tcount?: number;\n\t/**\n\t * True when `count` exceeds the provider's own result ceiling, so a full read CANNOT return everything no\n\t * matter how it is paged. This is the signal to warn before starting an expensive fetch.\n\t */\n\texceedsProviderLimit: boolean;\n\t/** The ceiling itself, when the provider declares one. */\n\tproviderLimit?: number;\n}\n\n/**\n * One scope to count pull requests over — the PR twin of {@link IssueCountScope}.\n *\n * `key` is caller-owned and echoed back verbatim, never reaching the provider query (the aliases are generated), so\n * it can be any string the caller finds meaningful.\n */\nexport interface PullRequestCountScope {\n\tkey: string;\n\t/** Repositories to count over. Combines with `org`, exactly as in `searchPullRequestsPage`. */\n\trepos?: ProviderRepositoriesInput;\n\torg?: string;\n\t/**\n\t * Same criteria model as `searchPullRequestsPage`, validated against the same capability table — so a count\n\t * refuses exactly what the read would, and never previews a fetch that can't happen.\n\t */\n\tcriteria?: PullRequestSearchCriteria;\n}\n\n/** The count for one {@link PullRequestCountScope}, echoed back under the caller's own `key`. */\nexport interface PullRequestCountResult {\n\tkey: string;\n\t/**\n\t * Total matches the provider reports. `undefined` when the provider didn't report one for this scope — NEVER\n\t * zero, which is a real answer.\n\t *\n\t * For a multi-state scope, GitHub/GHE report the LARGEST of their per-state counts (the same total\n\t * `searchPullRequestsPage` surfaces, since each state is its own capped search), not their sum. Bitbucket Data\n\t * Center has no ceiling to stay under, so it reports the exact union — the number of rows the search returns —\n\t * and so does Azure DevOps Server, which reads every state in one drain.\n\t */\n\tcount?: number;\n\t/**\n\t * True when `count` is a FLOOR rather than the total: the provider has no count query (Bitbucket Data Center),\n\t * so it counts by reading within a budget, and this scope had more than the budget read. Render it as \"N+\", and\n\t * treat the scope as at least that expensive. Absent means `count` is exact — the provider's own total, or for a\n\t * provider that counts by reading, every match it read.\n\t */\n\tlowerBound?: boolean;\n\t/**\n\t * True when `count` exceeds the provider's own per-search result ceiling, so a full read CANNOT return\n\t * everything no matter how it is paged. This is the signal to warn before starting an expensive fetch.\n\t */\n\texceedsProviderLimit: boolean;\n\t/** The ceiling itself, when the provider declares one. */\n\tproviderLimit?: number;\n}\n\n/** One issue to resolve, echoed back under the caller's own `key`. Which form a call takes depends on its provider. */\nexport type IssueBatchTarget =\n\t/**\n\t * A git host's issue, by repository coordinate. GitHub/GHE, GitLab (and self-managed) and Azure DevOps (and\n\t * Server); Bitbucket and Bitbucket Data Center have no issues and refuse.\n\t */\n\t| {\n\t\t\tkey: string;\n\t\t\t/** GitHub owner, GitLab namespace path (may be nested), or Azure DevOps organization (or collection). */\n\t\t\towner: string;\n\t\t\t/**\n\t\t\t * Repository name. Required, but ignored on Azure DevOps, whose work items belong to the project rather\n\t\t\t * than to a repository; there it only names the project of a project-less Azure DevOps Server path read\n\t\t\t * behind a virtual directory (`{vdir}/{collection}/_git/{repo}` as owner `{vdir}`, project `{collection}`).\n\t\t\t */\n\t\t\trepo: string;\n\t\t\t/** Issue number, GitLab issue iid, or Azure DevOps work item id. */\n\t\t\tnumber: number;\n\t\t\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\t\t\tproject?: string;\n\t\t\t/** The {@link IssueBatchResult.etag} of the copy the caller holds; see {@link IssueBatchResult}. */\n\t\t\tetag?: string;\n\t }\n\t/**\n\t * An issue tracker's issue, by its own identifier (e.g. `ABC-123`) within a resource. Jira (Cloud and Data\n\t * Center) and Linear. For Jira Data Center `resourceId` is the host — the instance's single resource, as\n\t * `listOrgs` reports it — and `resourceUrl` is not needed, since the browser link is built from the\n\t * connection's own base URL; Jira Cloud requires it.\n\t */\n\t| {\n\t\t\tkey: string;\n\t\t\tresourceId: string;\n\t\t\tresourceUrl?: string;\n\t\t\tidentifier: string;\n\t\t\t/**\n\t\t\t * The {@link IssueBatchResult.etag} of the copy the caller holds. Checked cheaply on Jira Cloud and Linear;\n\t\t\t * every other tracker accepts it but reads the issue in full.\n\t\t\t */\n\t\t\tetag?: string;\n\t };\n\n/**\n * The answer for one {@link IssueBatchTarget}, in one of four states:\n * - `{ key, issue, etag }` — read in full. Every fully read row carries an `etag`, whether or not the caller sent\n * one, so a caller can seed its etags from the reads it already makes.\n * - `{ key, unchanged: true, etag }` — the cheap check proved the caller's copy current, and nothing else was\n * fetched. Only for a target that sent an `etag`, on a host with a cheap check.\n * - `{ key }` — PROVEN ABSENT.\n * - no row, with `fetchFailed` and a warning — the read could not check. Never treat that as absent.\n */\nexport interface IssueBatchResult {\n\tkey: string;\n\t/**\n\t * The resolved issue, or `undefined` when it PROVABLY does not exist (or is not visible to this connection) —\n\t * or when it is `unchanged`.\n\t *\n\t * Absent is an answer here, unlike every paged read on this facade: a target that FAILED — its own request\n\t * outright, or just its own alias within an otherwise-answering GitHub chunk (e.g. an org enforcing SAML SSO\n\t * the token isn't authorized for) — is not returned at all and sets `fetchFailed`, so a caller can tell\n\t * \"proven absent\" from \"unknown\" and cache the first without ever caching the second.\n\t */\n\tissue?: IssueShape;\n\t/**\n\t * Opaque: compare for equality only, never parse. Computed by core from the issue's change state — its state and\n\t * update time, plus each input the call's `etagIncludes` listed — and NOT the provider's HTTP ETag. Send it back\n\t * as the target's `etag`. An etag from another scheme or another `etagIncludes` set simply compares unequal and\n\t * costs a full read, never a false `unchanged`. A host can add a reaction without moving the update time, so\n\t * unless `'reactions'` is listed, an `unchanged` copy's `thumbsUpCount` may be stale.\n\t */\n\tetag?: string;\n\t/** The caller's copy is current (its `etag` matched); `issue` is absent because nothing was read. */\n\tunchanged?: true;\n}\n\n/** One pull request to resolve, identified by coordinate and echoed back under the caller's own `key`. */\nexport interface PullRequestBatchTarget {\n\t/** Caller-owned identifier, echoed on the result so no positional matching is needed. Must be unique. */\n\tkey: string;\n\t/**\n\t * GitHub owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or\n\t * Azure DevOps organization.\n\t */\n\towner: string;\n\t/** Repository name or slug. */\n\trepo: string;\n\t/** Pull request number, GitLab merge request iid, or Azure DevOps pull request id. */\n\tnumber: number;\n\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\tproject?: string;\n\t/**\n\t * The {@link PullRequestBatchResult.etag} of the copy the caller holds. When the host can check it cheaply and\n\t * it still matches, the pull request isn't read again and comes back `unchanged`.\n\t */\n\tetag?: string;\n}\n\n/**\n * The answer for one {@link PullRequestBatchTarget}, in one of four states:\n * - `{ key, pullRequest, etag }` — read in full, whatever its state. Every fully read row carries an `etag`,\n * whether or not the caller sent one, so a caller can seed its etags from the reads it already makes.\n * - `{ key, unchanged: true, etag }` — the cheap check proved the caller's copy current, and nothing else was\n * fetched. Only for a target that sent an `etag`, on a host with a cheap check.\n * - `{ key }` — PROVEN ABSENT: it does not exist, or is not visible to this connection.\n * - no row, with `fetchFailed` and a warning — the read could not check. Never treat that as absent.\n */\nexport interface PullRequestBatchResult {\n\tkey: string;\n\t/**\n\t * The resolved pull request, whatever its state, or `undefined` when it PROVABLY does not exist (or is not\n\t * visible to this connection) — or when it is `unchanged`. A target whose read FAILED is not returned at\n\t * all and sets `fetchFailed`.\n\t */\n\tpullRequest?: PullRequestShape;\n\t/**\n\t * Opaque: compare for equality only, never parse. Computed by core from the pull request's change state — its\n\t * state, draft flag, update time and head commit (on Azure DevOps, also a revision of the fields it changes without\n\t * an update time), plus each input the call's `etagIncludes` listed — and NOT the provider's HTTP ETag. Send it\n\t * back as {@link PullRequestBatchTarget.etag}. An etag from another scheme or another `etagIncludes` set simply\n\t * compares unequal and costs a full read, never a false `unchanged` — and so does one from a read that selected\n\t * merge-queue data (see {@link IntegrationManager.getPullRequestsBatch}'s `mergeQueue`), or check runs\n\t * (`checkRuns`), when the other didn't.\n\t * Reactions are never an input: a host can add one without moving the update time, so an `unchanged` copy's\n\t * `thumbsUpCount` may be stale.\n\t */\n\tetag?: string;\n\t/** The caller's copy is current (its `etag` matched); `pullRequest` is absent because nothing was read. */\n\tunchanged?: true;\n}\n\n/** One branch whose pull requests to find, echoed back under the caller's own `key`. */\nexport interface PullRequestBranchTarget {\n\t/** Caller-owned identifier, echoed on the result so no positional matching is needed. Must be unique. */\n\tkey: string;\n\t/**\n\t * The repository the pull requests are OPENED AGAINST (their base), as in `PullRequestBatchTarget`: GitHub\n\t * owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or Azure\n\t * DevOps organization.\n\t */\n\towner: string;\n\t/** Repository name or slug. */\n\trepo: string;\n\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\tproject?: string;\n\t/** The head branch's short name, without `refs/heads/`. */\n\tbranch: string;\n\t/**\n\t * Owner (GitHub user or org, GitLab namespace, Bitbucket workspace) of the repository the branch lives in, when\n\t * it's a fork. Omitted, or equal to `owner` (ignoring case), means the branch lives in the base repository itself,\n\t * so a caller can pass the owner of whichever remote the branch was pushed to. On GitLab this is the whole\n\t * namespace path, as `owner` is, so a remote's first-slash split can't be passed for either.\n\t *\n\t * A different owner is refused on Bitbucket Data Center and Azure DevOps, where a fork can't be found by its\n\t * owner.\n\t */\n\theadOwner?: string;\n}\n\n/** The answer for one {@link PullRequestBranchTarget}. */\nexport interface PullRequestBranchResult {\n\tkey: string;\n\t/**\n\t * Every pull request whose head is this branch, in ANY state — open, closed and merged — most recently updated\n\t * first, up to a per-target cap. An empty array is a PROVEN \"none\" unless `truncated` is set. A target whose\n\t * read failed is not returned at all.\n\t */\n\tpullRequests: PullRequestShape[];\n\t/**\n\t * Set when a pull request that wasn't returned could still match: more matched than the cap, or the host held\n\t * more pull requests of this branch name than it returned and couldn't rule them out. GitHub/GHE rule them out\n\t * with a second request filtered by head owner, so there it means more than the cap truly match. That request\n\t * can't see a pull request from a since-deleted fork, so on GitHub/GHE such a pull request outside the first\n\t * request's page can be missing even when this is not set.\n\t */\n\ttruncated?: boolean;\n}\n\n/** The answer for one SHA of {@link IntegrationManager.getPullRequestsForCommits}'s input. */\nexport interface PullRequestForCommitResult {\n\t/** The SHA as the caller passed it (trimmed), echoed so no positional matching is needed. */\n\tsha: string;\n\t/**\n\t * The pull request the commit belongs to, or `undefined` when the host ANSWERED that it has none (or when the SHA\n\t * is the working tree's all-zero one, which is never sent): a resolved \"none\" a caller can cache. A SHA whose read\n\t * FAILED is not returned at all and sets `fetchFailed`.\n\t *\n\t * When a commit belongs to several, the one the single-commit lookup returns, which each host picks its own way —\n\t * see {@link IntegrationManager.getPullRequestsForCommits}.\n\t */\n\tpullRequest?: PullRequestShape;\n}\n\n/** One check whose log to read, echoed back under the caller's own `key`. */\nexport interface PullRequestCheckLogTarget {\n\t/** Caller-owned identifier, echoed on the result. Must be unique. */\n\tkey: string;\n\towner: string;\n\trepo: string;\n\t/** A `PullRequestCheckRun.id` from a batch pull request read, as it came. */\n\tcheckRunId: string;\n}\n\n/** The answer for one {@link PullRequestCheckLogTarget}: exactly one of `log` and `unavailable` is set. */\nexport type PullRequestCheckLogResult = PullRequestCheckLog & { readonly key: string };\n\n/** One pull request whose activity to read, echoed back under the caller's own `key`. */\nexport interface PullRequestActivityTarget {\n\t/** Caller-owned identifier, echoed on the result. Must be unique. */\n\tkey: string;\n\towner: string;\n\trepo: string;\n\tnumber: number;\n\t/** The {@link PullRequestActivityResult.cursor} of this pull request's last read. Omit it, or send `''`, for a first read. */\n\tcursor?: string;\n}\n\n/** The answer for one {@link PullRequestActivityTarget}. */\nexport interface PullRequestActivityResult {\n\tkey: string;\n\t/** New activity after the target's cursor, in GitHub's timeline order. A review's inline comments follow the review. */\n\titems: readonly PullRequestActivityItem[];\n\t/** Opaque: send it back as the target's `cursor` on the next read. */\n\tcursor: string;\n\t/** More items follow this page; read again with `cursor`. */\n\thasMore: boolean;\n\t/** The pull request (or its repository) does not exist or is not visible to this connection. */\n\tnotFound?: true;\n}\n\n/**\n * \"Who am I on this provider / connection\" — {@link IntegrationBase.getCurrentAccount}'s own answer, exposed on\n * the manager so a caller can ask for it directly instead of waiting for some other read to warm it as a side\n * effect.\n */\nexport interface CurrentAccountResult {\n\t/** The signed-in account, when the provider answered. */\n\taccount?: Account;\n\twarnings: ProviderWarning[];\n\t/**\n\t * Set whenever `account` is absent. Unlike a list/batch read, this one has no benign empty answer — \"who am\n\t * I\" is either resolved or it couldn't be told, never a legitimately empty result — so `account` is never\n\t * missing without a warning explaining why.\n\t */\n\tfetchFailed?: boolean;\n}\n"],"mappings":"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"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getScopedLogger, maybeStartScopedLogger } from "../../logger.scoped.js";
|
|
2
2
|
import { isWindows } from "./platform.js";
|
|
3
3
|
import { join } from "path";
|
|
4
|
-
import { stat } from "fs/promises";
|
|
5
|
-
import * as process from "process";
|
|
6
4
|
import { execFile, spawn } from "child_process";
|
|
7
5
|
import { access, constants } from "fs";
|
|
6
|
+
import { stat } from "fs/promises";
|
|
7
|
+
import * as process from "process";
|
|
8
8
|
//#region ../utils/src/env/node/exec.ts
|
|
9
9
|
var RunError = class extends Error {
|
|
10
10
|
cmd;
|
package/docs/integrations.md
CHANGED
|
@@ -353,6 +353,15 @@ drops them. Each target is judged by its own failure, so one target's rate limit
|
|
|
353
353
|
failed to answer. The cheap check counts toward its connection's failure budget only when the credential is
|
|
354
354
|
refused; any other failure of it is left to the full reads, so a call counts at most twice, once per full read.
|
|
355
355
|
|
|
356
|
+
The sweeps also take `etagIncludes`. With it, each row as complete as a `getPullRequestsBatch` row from the same
|
|
357
|
+
provider (judged by [field presence](#field-presence), with no `checkRuns` and the sweep's own `mergeQueue` selection)
|
|
358
|
+
carries the `etag` that read would compute with the same `etagIncludes`, so the first batch read of a pull request the
|
|
359
|
+
sweep just listed can answer `unchanged`. Only GitHub and GitHub Enterprise rows carry one, since elsewhere a sweep row
|
|
360
|
+
and a batch row come from different converters and their etags would never match. Of those, only an account-wide sweep
|
|
361
|
+
with `includeReviews` is that complete; a repo-scoped row has no reviews or review decision and carries none. An unknown include refuses the target. A
|
|
362
|
+
`getPullRequestsBatch` read with `checkRuns` never matches a sweep's etag (sweeps select no check runs), and a sweep seeds
|
|
363
|
+
only the batch reads with its own `mergeQueue` selection.
|
|
364
|
+
|
|
356
365
|
`getPullRequestsForBranches` answers "which pull requests have this branch as their head" without the user's
|
|
357
366
|
relationship to them, so unlike the sweeps it finds a teammate's pull request from the user's branch. A target names
|
|
358
367
|
the repository the pull requests are opened against, the branch's short name and, for a branch in a fork,
|
|
@@ -1412,6 +1421,28 @@ Pass `cancellation` to abort the read: the request in flight, a retry waiting to
|
|
|
1412
1421
|
page-number walk still has to read. The read then rejects with a `CancellationError` rather than resolving, so a
|
|
1413
1422
|
cancelled read is never mistaken for a failed or an empty one.
|
|
1414
1423
|
|
|
1424
|
+
`criteria.changedSince` (GitHub/GHE only; check `pullRequestSearch.changedSince`) turns the search into a change
|
|
1425
|
+
feed. It takes a UTC timestamp, `YYYY-MM-DDTHH:MM:SSZ`, and returns pull requests in every state updated at or after
|
|
1426
|
+
it (and within `updatedAfter`, when both are set), oldest update first. It requires `states` omitted or `['all']`,
|
|
1427
|
+
`sort` omitted or `'updated:asc'`, and at most one relationship; anything else, or a malformed timestamp, is refused
|
|
1428
|
+
like any unsupported criterion. Every page of the walk also carries `openCount`: the number of open pull requests the
|
|
1429
|
+
same search with `states: ['open']` and no `changedSince` would report as its total. It is absent when the count
|
|
1430
|
+
couldn't be read.
|
|
1431
|
+
|
|
1432
|
+
To keep a list of open pull requests current with it:
|
|
1433
|
+
|
|
1434
|
+
- Advance your cursor to the newest `updatedDate` returned, minus a few minutes. Never use your local clock: the
|
|
1435
|
+
search index lags behind the pull requests it indexes. On a walk of more than one page, advance only to the newest
|
|
1436
|
+
`updatedDate` of the first page: GitHub's search cursors are positions, so a pull request updated mid-walk moves to
|
|
1437
|
+
the end and pushes a row back onto a page already read, and the next pass must read from before it.
|
|
1438
|
+
- Merge the returned rows into what you hold by number, and drop the ones no longer open.
|
|
1439
|
+
- Do a full read instead when `openCount` disagrees with the number of open rows you hold, when it is absent, or
|
|
1440
|
+
when the read was truncated. Above GitHub's 1,000-result search ceiling a full read can't reach `openCount`, so the
|
|
1441
|
+
count can't confirm such a list: narrow the scope.
|
|
1442
|
+
|
|
1443
|
+
It sees only what moves a pull request's update time. Checks, mergeability and a push to the base branch don't, so
|
|
1444
|
+
cover those with `getPullRequestsBatch` etags.
|
|
1445
|
+
|
|
1415
1446
|
### 5.1 The filtered issue search and its count probe
|
|
1416
1447
|
|
|
1417
1448
|
`searchIssuesPage` answers "every issue in this scope matching X", which no other issue read can: the
|
|
@@ -1867,7 +1898,8 @@ const filters = wanted.filter(f => capability.includes(f));
|
|
|
1867
1898
|
`relationships` and `states`, plus `text`, `updatedAfter`, `createdAfter`, `includeArchived`, `draft`,
|
|
1868
1899
|
`repositoryScope`, `organizationScope`, and `sorts` — the ordering vocabulary, as `field:direction` keys. A key
|
|
1869
1900
|
not in `sorts` refuses the whole read, exactly like an inexpressible filter; `updated:desc` is always in it when
|
|
1870
|
-
the search exists at all, so omitting `criteria.sort` never refuses.
|
|
1901
|
+
the search exists at all, so omitting `criteria.sort` never refuses. `changedSince` says whether
|
|
1902
|
+
`criteria.changedSince` and the `openCount` it returns are supported (GitHub/GHE only; see §5).
|
|
1871
1903
|
- `issues` — the **repo-scoped** git-host read, **and** the issue-tracker read
|
|
1872
1904
|
(`listIssueTrackerIssuesPage` validates against this field).
|
|
1873
1905
|
- `issuesAccountWide` — the account-wide git-host read only. Usually narrower (GitLab can express
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/core-gitlens",
|
|
3
3
|
"description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.55.0",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "GitKraken",
|