@intellectual-frontiers/ergonex 0.3.6 → 0.3.8

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/dist/layout.d.ts CHANGED
@@ -10,8 +10,8 @@
10
10
  * @module
11
11
  */
12
12
  import { type Result } from "@intellectual-frontiers/core";
13
- import { type HostKinds } from "./vendor/ts/githost/mod.js";
14
- import type { HostKind, RepoRef } from "./vendor/ts/githost/mod.js";
13
+ import { type HostKinds } from "@intellectual-frontiers/githost";
14
+ import type { HostKind, RepoRef } from "@intellectual-frontiers/githost";
15
15
  import { type PortableError } from "./portable.js";
16
16
  import { type BrandError, type BranchName, type GitHost, type PortableSegment, type RepoPath } from "./types.js";
17
17
  /** The folders that belong to the workspace itself, which no host and no segment of a remote may be named like. */
@@ -13,8 +13,8 @@
13
13
  * @module
14
14
  */
15
15
  import { type Result } from "@intellectual-frontiers/core";
16
- import { type HostKinds } from "./vendor/ts/githost/mod.js";
17
- import type { RepoRef } from "./vendor/ts/githost/mod.js";
16
+ import { type HostKinds } from "@intellectual-frontiers/githost";
17
+ import type { RepoRef } from "@intellectual-frontiers/githost";
18
18
  import type { Finding } from "./findings.js";
19
19
  import { type ToolCatalog } from "./tools/catalog.js";
20
20
  import { type Policy } from "./policy.js";
package/dist/mod.js CHANGED
@@ -911,7 +911,7 @@ function toSarif(findings, tool = "ergonex") {
911
911
  }
912
912
 
913
913
  // src/state-record.ts
914
- var ERGONEX_VERSION = "0.3.6";
914
+ var ERGONEX_VERSION = "0.3.8";
915
915
  var STATE_RECORD_PATH = ".ergonex/state.auto.json";
916
916
  var EMPTY_RECORD = {
917
917
  ergonex: ERGONEX_VERSION,
@@ -2656,7 +2656,7 @@ var exchangeDecoder = object({
2656
2656
  body: string
2657
2657
  });
2658
2658
 
2659
- // ../ts/githost/capabilities.ts
2659
+ // ../githost/src/capabilities.ts
2660
2660
  var COMMON_CAPABILITIES = ["CloneUrl", "Credentials", "DefaultBranch", "SignedCommits"];
2661
2661
  var HOSTED = [...COMMON_CAPABILITIES, "ProtectedBranches", "Issues", "ChangeRequests"];
2662
2662
  var CAPABILITIES = {
@@ -2671,7 +2671,7 @@ function maxDepth(kind) {
2671
2671
  return supports(kind, "NestedGroups") ? Number.POSITIVE_INFINITY : 2;
2672
2672
  }
2673
2673
 
2674
- // ../ts/githost/remote.ts
2674
+ // ../githost/src/remote.ts
2675
2675
  function describeRemoteError(e) {
2676
2676
  switch (e.kind) {
2677
2677
  case "empty":
@@ -2807,7 +2807,7 @@ function sameRepository(a, b) {
2807
2807
  return a.host.toLowerCase() === b.host.toLowerCase() && a.path.length === b.path.length && a.path.every((s, i) => s.toLowerCase() === (b.path[i] ?? "").toLowerCase());
2808
2808
  }
2809
2809
 
2810
- // ../ts/githost/github.ts
2810
+ // ../githost/src/github.ts
2811
2811
  var repoShape = object({ private: boolean, default_branch: string, clone_url: string, archived: boolean }, { visibility: string });
2812
2812
  var issueShape = object({ number: integer, title: string, state: literal("open", "closed"), html_url: string }, { body: nullable(string), labels: array(oneOf(string, object({ name: string }))), pull_request: unknownValue });
2813
2813
  var subIssuesShape = array(object({ number: integer }));
@@ -2823,7 +2823,7 @@ var branchShape = object({ name: string, protected: boolean });
2823
2823
  var protectionShape = object({}, { required_pull_request_reviews: unknownValue, allow_force_pushes: object({ enabled: boolean }) });
2824
2824
  var commitShape = object({ commit: object({ verification: object({ verified: boolean }) }) });
2825
2825
 
2826
- // ../ts/githost/gitlab.ts
2826
+ // ../githost/src/gitlab.ts
2827
2827
  var projectShape = object({ http_url_to_repo: string }, { archived: boolean, visibility: literal("public", "internal", "private"), default_branch: nullable(string) });
2828
2828
  var issueShape2 = object({ iid: integer, title: string, state: literal("opened", "closed"), web_url: string }, { description: nullable(string), labels: array(string) });
2829
2829
  var mergeRequestShape = object({
package/dist/plan.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Sha256 } from "@intellectual-frontiers/crypto";
2
- import type { RepoRef } from "./vendor/ts/githost/mod.js";
2
+ import type { RepoRef } from "@intellectual-frontiers/githost";
3
3
  import { type RepoState } from "./state.js";
4
4
  import type { BranchName, RepoPath, Version } from "./types.js";
5
5
  /** The repository the manifest names, at its path. */
@@ -14,7 +14,7 @@ import { type Sha256 } from "@intellectual-frontiers/crypto";
14
14
  import { type Finding } from "./findings.js";
15
15
  import { type GeneratedFile } from "./render.js";
16
16
  /** The version of Ergonex the record names. */
17
- export declare const ERGONEX_VERSION = "0.3.6";
17
+ export declare const ERGONEX_VERSION = "0.3.8";
18
18
  /** Where the state record is, below the root. */
19
19
  export declare const STATE_RECORD_PATH = ".ergonex/state.auto.json";
20
20
  /** One generated file as it was written. */
package/dist/state.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RepoRef } from "./vendor/ts/githost/mod.js";
1
+ import type { RepoRef } from "@intellectual-frontiers/githost";
2
2
  /** What a host layer read of a path. */
3
3
  export type RepoFacts = {
4
4
  readonly kind: "absent";
package/ergonex.mjs CHANGED
@@ -3137,7 +3137,7 @@ var exchangeDecoder = object({
3137
3137
  body: string
3138
3138
  });
3139
3139
 
3140
- // ../ts/githost/capabilities.ts
3140
+ // ../githost/src/capabilities.ts
3141
3141
  var COMMON_CAPABILITIES = ["CloneUrl", "Credentials", "DefaultBranch", "SignedCommits"];
3142
3142
  var HOSTED = [...COMMON_CAPABILITIES, "ProtectedBranches", "Issues", "ChangeRequests"];
3143
3143
  var CAPABILITIES = {
@@ -3152,7 +3152,7 @@ function maxDepth(kind) {
3152
3152
  return supports(kind, "NestedGroups") ? Number.POSITIVE_INFINITY : 2;
3153
3153
  }
3154
3154
 
3155
- // ../ts/githost/remote.ts
3155
+ // ../githost/src/remote.ts
3156
3156
  function describeRemoteError(e) {
3157
3157
  switch (e.kind) {
3158
3158
  case "empty":
@@ -3288,7 +3288,7 @@ function sameRepository(a, b) {
3288
3288
  return a.host.toLowerCase() === b.host.toLowerCase() && a.path.length === b.path.length && a.path.every((s, i) => s.toLowerCase() === (b.path[i] ?? "").toLowerCase());
3289
3289
  }
3290
3290
 
3291
- // ../ts/githost/github.ts
3291
+ // ../githost/src/github.ts
3292
3292
  var repoShape = object({ private: boolean, default_branch: string, clone_url: string, archived: boolean }, { visibility: string });
3293
3293
  var issueShape = object({ number: integer, title: string, state: literal("open", "closed"), html_url: string }, { body: nullable(string), labels: array(oneOf(string, object({ name: string }))), pull_request: unknownValue });
3294
3294
  var subIssuesShape = array(object({ number: integer }));
@@ -3304,7 +3304,7 @@ var branchShape = object({ name: string, protected: boolean });
3304
3304
  var protectionShape = object({}, { required_pull_request_reviews: unknownValue, allow_force_pushes: object({ enabled: boolean }) });
3305
3305
  var commitShape = object({ commit: object({ verification: object({ verified: boolean }) }) });
3306
3306
 
3307
- // ../ts/githost/gitlab.ts
3307
+ // ../githost/src/gitlab.ts
3308
3308
  var projectShape = object({ http_url_to_repo: string }, { archived: boolean, visibility: literal("public", "internal", "private"), default_branch: nullable(string) });
3309
3309
  var issueShape2 = object({ iid: integer, title: string, state: literal("opened", "closed"), web_url: string }, { description: nullable(string), labels: array(string) });
3310
3310
  var mergeRequestShape = object({
@@ -3859,7 +3859,7 @@ function checkFiles(files, repositories) {
3859
3859
  }
3860
3860
 
3861
3861
  // src/state-record.ts
3862
- var ERGONEX_VERSION = "0.3.6";
3862
+ var ERGONEX_VERSION = "0.3.8";
3863
3863
  var STATE_RECORD_PATH = ".ergonex/state.auto.json";
3864
3864
  var EMPTY_RECORD = {
3865
3865
  ergonex: ERGONEX_VERSION,
@@ -7255,7 +7255,7 @@ function modulesOnPath(pathVar, firstSeen, today, isWindows = false) {
7255
7255
  return out;
7256
7256
  }
7257
7257
 
7258
- // ../ts/mizan/changes/declaration.ts
7258
+ // ../mizan/src/changes/declaration.ts
7259
7259
  var REGULATED_DOMAINS = ["FederalSecurity", "DeviceQuality", "ElectronicRecords", "DeviceSoftware", "TrustServices"];
7260
7260
  function dayOf(text) {
7261
7261
  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
@@ -7830,7 +7830,7 @@ var helpModule = {
7830
7830
  commands: [help]
7831
7831
  };
7832
7832
 
7833
- // ../ts/mizan/changes/commit-message.ts
7833
+ // ../mizan/src/changes/commit-message.ts
7834
7834
  var TARGET = String.raw`((?:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)?)#(\d+)`;
7835
7835
  var OWN_LINE = new RegExp(String.raw`^(refs|closes):?\s+${TARGET}\s*$`, "i");
7836
7836
  var CLOSING_WORD = new RegExp(String.raw`\b(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved):?\s+${TARGET}`, "gi");
@@ -10893,7 +10893,7 @@ var EVIDENCE_ROOT = "quality/evidence";
10893
10893
  var CASE_EVENT = "ifc.test.case";
10894
10894
  var RUN_GRADE = "E3";
10895
10895
  var NO_GRADE = "E0";
10896
- // ../ts/kernel/grc.ts
10896
+ // ../grc/src/grc.ts
10897
10897
  var INSTANT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[.,](\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/i;
10898
10898
  var CANONICAL_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
10899
10899
  function instantOf(text) {
@@ -10976,7 +10976,7 @@ var durationDecoder = refined("an ISO 8601 duration", (t) => {
10976
10976
  var severityDecoder = literal(...SEVERITIES2);
10977
10977
  var waiverInput = mapDecoder(object({ id: string, control: string, subjects: array(string), reason: string, approvedBy: roleDecoder, grantedAt: instantDecoder }, { expiresAt: instantDecoder }), (w) => w);
10978
10978
 
10979
- // ../ts/kernel/evidence.ts
10979
+ // ../grc/src/evidence.ts
10980
10980
  var GENESIS = "0".repeat(64);
10981
10981
  var sha256Decoder = (input, path = "$") => {
10982
10982
  const s = typeof input === "string" && /^[0-9a-f]{64}$/.test(input) ? sha256Of(input) : undefined;
@@ -10995,7 +10995,7 @@ var manifestDecoder2 = object({
10995
10995
  files: array(object({ path: string, size: refine(integer, "size", (n) => n >= 0), sha256: sha256Decoder }))
10996
10996
  });
10997
10997
 
10998
- // ../ts/kernel/assess.ts
10998
+ // ../grc/src/assess.ts
10999
10999
  var impactDeclarationDecoder = object({ paths: array(string), controls: array(string) });
11000
11000
  var RISK_LEVELS = ["very-low", "low", "moderate", "high", "very-high"];
11001
11001
  var levelDecoder = literal(...RISK_LEVELS);
@@ -11009,7 +11009,7 @@ var riskDecoder = object({
11009
11009
  reviewBy: instantDecoder
11010
11010
  }, { description: string, controls: array(string) });
11011
11011
 
11012
- // ../ts/kernel/oscal.ts
11012
+ // ../grc/src/oscal.ts
11013
11013
  var OPEN_OUTCOMES = new Set(["fail", "warn", "gap", "error", "accepted"]);
11014
11014
 
11015
11015
  // ../ts/kernel/test-report.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intellectual-frontiers/ergonex",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "description": "Ergonex, the workspaces management of Intellectual Frontiers: one command that sets up, configures and operates a team's software repositories, package registries and builds, on Windows, macOS and Linux, with Bun by default and Node 26 as the backup.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,11 +19,11 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@intellectual-frontiers/core": "0.1.2",
23
- "@intellectual-frontiers/crypto": "0.1.2",
24
- "@intellectual-frontiers/formats": "0.1.2",
25
- "@intellectual-frontiers/net": "0.1.1",
26
- "@intellectual-frontiers/terminal": "0.1.2"
22
+ "@intellectual-frontiers/core": "0.1.3",
23
+ "@intellectual-frontiers/crypto": "0.1.3",
24
+ "@intellectual-frontiers/formats": "0.1.3",
25
+ "@intellectual-frontiers/githost": "0.1.1",
26
+ "@intellectual-frontiers/terminal": "0.1.3"
27
27
  },
28
28
  "files": [
29
29
  "dist",
@@ -1,18 +0,0 @@
1
- /**
2
- * What each kind of Git host offers (commons 0020-ifccm FR-040, FR-017): the table of `ifccm:GitManagerKind` and its `ifccm:supports`, as the pure types the adapters and the
3
- * workspace read, and the typed answer for a capability a kind lacks. A test holds this table equal to the ontology's.
4
- *
5
- * @module
6
- */
7
- import { type Result } from "@intellectual-frontiers/core";
8
- import type { Capability, HostFailure, HostKind } from "./types.js";
9
- /** The four capabilities every kind offers (`ifccm:CloneUrl`, `ifccm:Credentials`, `ifccm:DefaultBranch`, `ifccm:SignedCommits`). */
10
- export declare const COMMON_CAPABILITIES: readonly Capability[];
11
- /** The capabilities of each kind: GitHub the common four and the three a host adds, GitLab those and groups to any depth, plain Git the common four alone. */
12
- export declare const CAPABILITIES: Readonly<Record<HostKind, ReadonlySet<Capability>>>;
13
- /** Whether a kind of host offers a capability. */
14
- export declare function supports(kind: HostKind, capability: Capability): boolean;
15
- /** The answer for a capability that a kind of host does not offer: typed, naming the host and the capability, never a guess (0020-ifccm FR-041). */
16
- export declare function unsupported(host: HostKind, capability: Capability): Result<never, HostFailure>;
17
- /** The most path segments (owner or groups, then repository) a kind of host takes: 2 where it has no nested groups, unlimited where it has. */
18
- export declare function maxDepth(kind: HostKind): number;
@@ -1,16 +0,0 @@
1
- import type { GitHostClient, RepoRef } from "./types.js";
2
- /** How a plain Git client is made. */
3
- export type PlainGitOptions = {
4
- /** The program (`git` on the path by default). */
5
- readonly program?: string;
6
- /** The URL or path a repository is asked from; its HTTPS clone URL by default. Never one with a credential in it. */
7
- readonly remoteOf?: (ref: RepoRef) => string;
8
- /** A clone of the repository on this computer, where the signature of a commit can be read; none by default (a signature is then `not-found`). */
9
- readonly localOf?: (ref: RepoRef) => string | undefined;
10
- /** Variables added to `git`'s environment (a test points `GIT_CONFIG_GLOBAL` at its own file; nothing here may be a credential). */
11
- readonly env?: Readonly<Record<string, string>>;
12
- };
13
- /** The branch a `git ls-remote --symref <url> HEAD` says HEAD points to: empty where it says none (an empty repository). */
14
- export declare function defaultBranchOf(lsRemote: string): string;
15
- /** A plain Git client: the common four capabilities, and `unsupported` for protected branches, issues and change requests. */
16
- export declare function plainGitClient(options?: PlainGitOptions): GitHostClient;
@@ -1,15 +0,0 @@
1
- import type { Transport } from "@intellectual-frontiers/net/http-client";
2
- import type { GitHostClient } from "./types.js";
3
- /** How a GitHub client is made. */
4
- export type GithubOptions = {
5
- /** How requests are sent: the live transport, or a recorded one. */
6
- readonly transport: Transport;
7
- /** A token, from the environment by the caller; never stored in a file and never in a result. Absent: only what is public. */
8
- readonly token?: string | undefined;
9
- /** The one host this client serves (`github.com` by default); a reference to another host is `not-found`, so the token is never sent elsewhere. */
10
- readonly host?: string;
11
- /** The API's base URL (`https://api.github.com` for `github.com`, `https://<host>/api/v3` for another host by default). */
12
- readonly apiBase?: string;
13
- };
14
- /** A GitHub client over a transport: the common four capabilities and protected branches, issues and pull requests, with no nested groups. */
15
- export declare function githubClient(options: GithubOptions): GitHostClient;
@@ -1,15 +0,0 @@
1
- import type { Transport } from "@intellectual-frontiers/net/http-client";
2
- import type { GitHostClient } from "./types.js";
3
- /** How a GitLab client is made. */
4
- export type GitlabOptions = {
5
- /** How requests are sent: the live transport, or a recorded one. */
6
- readonly transport: Transport;
7
- /** The host's address without the API path (`https://gitlab.com` by default); its host name is the one host this client serves. */
8
- readonly baseUrl?: string;
9
- /** A token, from the environment by the caller; never stored in a file and never in a result. Absent: only what is public. */
10
- readonly token?: string | undefined;
11
- /** What the token is: a personal or project access token (`PRIVATE-TOKEN`, the default), or a CI job's token (`JOB-TOKEN`). */
12
- readonly tokenKind?: "access" | "job";
13
- };
14
- /** A GitLab client over a transport: the common four capabilities, protected branches, issues and merge requests, and groups to any depth. */
15
- export declare function gitlabClient(options: GitlabOptions): GitHostClient;
@@ -1,29 +0,0 @@
1
- import { type Transport } from "@intellectual-frontiers/net/http-client";
2
- import { type PlainGitOptions } from "./git.js";
3
- import type { GitHostClient, RepoRef } from "./types.js";
4
- export { CAPABILITIES, COMMON_CAPABILITIES, maxDepth, supports, unsupported } from "./capabilities.js";
5
- export { githubClient, type GithubOptions } from "./github.js";
6
- export { defaultBranchOf, plainGitClient, type PlainGitOptions } from "./git.js";
7
- export { gitlabClient, type GitlabOptions } from "./gitlab.js";
8
- export { cloneUrlOf, describeRef, describeRemoteError, hostKindOf, type HostKinds, parseRemote, readRemote, type ReadRemote, type RemoteError, sameRepository, } from "./remote.js";
9
- export { type BranchProtection, type Capability, type ChangeRequestInfo, describeFailure, type GitHostClient, type HostFailure, type HostKind, type HostResult, type IssueInfo, type RepoInfo, type RepoRef, type Visibility, } from "./types.js";
10
- /** What `clientFor` reads and uses. */
11
- export type ClientForOptions = {
12
- /** The caller's environment: where the token is read from, and nowhere else. */
13
- readonly env: Readonly<Record<string, string | undefined>>;
14
- /** How requests are sent; the live transport (with backoff, and a credential allowed only where a token is given) by default. */
15
- readonly transport?: Transport;
16
- /** For a plain Git remote: where it is asked from and where a clone is. */
17
- readonly plain?: PlainGitOptions;
18
- /**
19
- * The hosts, besides `github.com` and `gitlab.com`, that may be sent a token: those the manifest names (a self-managed GitLab, GitHub Enterprise Server). A host not here is asked with no
20
- * credential, so that an environment's token is never sent to a host nobody named.
21
- */
22
- readonly trustedHosts?: readonly string[];
23
- /** The base URL of a self-managed GitLab, where the reference's host is not `gitlab.com` and is not served over `https://<host>`. */
24
- readonly gitlabBaseUrl?: string;
25
- /** The API's base URL of a GitHub Enterprise Server host, where it is not `https://<host>/api/v3`. */
26
- readonly githubApiBase?: string;
27
- };
28
- /** The client for a reference's kind of host, with the token the environment holds for it, if any and if the host may receive one. */
29
- export declare function clientFor(ref: RepoRef, options: ClientForOptions): GitHostClient;
@@ -1,59 +0,0 @@
1
- /**
2
- * A Git remote URL read as a repository on a host (commons 0020-ifccm FR-039, FR-019): the https, `git://`, `ssh://` and scp-like (`git@host:owner/repo`) forms give the same
3
- * `RepoRef`, whichever way the remote is written, so that a clone made over SSH is the repository the manifest names over HTTPS.
4
- *
5
- * @remarks
6
- * A credential in the URL (`https://user:token@host/...`) is dropped: no result, no error and no message holds it. The host name is lower-cased and its port is dropped (an SSH port and
7
- * an HTTPS port say how to reach a host, not which repository it is); the path is kept as the host writes it, without `.git` and without a trailing slash. The kind of host is GitHub for
8
- * `github.com`, GitLab for `gitlab.com` and for a host a map names, and plain Git for every other: a self-managed GitLab is named, never guessed from a URL (FR-019).
9
- *
10
- * @limits It reads no file and asks no host. A local path or a `file:` URL is not a remote of a host and is an error.
11
- *
12
- * @module
13
- */
14
- import { type Result } from "@intellectual-frontiers/core";
15
- import type { HostKind, RepoRef } from "./types.js";
16
- /** Why a text is not a remote URL of a repository on a host. Never holds the URL, which may hold a credential. */
17
- export type RemoteError = {
18
- readonly kind: "empty";
19
- } | {
20
- readonly kind: "local-path";
21
- } | {
22
- readonly kind: "unsupported-scheme";
23
- readonly scheme: string;
24
- } | {
25
- readonly kind: "no-host";
26
- } | {
27
- readonly kind: "no-path";
28
- } | {
29
- readonly kind: "bad-segment";
30
- readonly reason: string;
31
- };
32
- /** A remote error as one sentence. */
33
- export declare function describeRemoteError(e: RemoteError): string;
34
- /** The hosts that are not plain Git, by name: a map from a lower-case host name to its kind, as the manifest names them (a self-managed GitLab, or GitHub Enterprise Server). */
35
- export type HostKinds = Readonly<Record<string, HostKind>>;
36
- /** The kind of a host: GitHub for `github.com`, GitLab for `gitlab.com`, what the map says for a host it names, and plain Git for every other (0020-ifccm FR-043). */
37
- export declare function hostKindOf(host: string, hostKinds?: HostKinds): HostKind;
38
- /**
39
- * A remote URL as the repository it names. The forms: `https://host/path(.git)`, `http://`, `git://`, `ssh://[user@]host[:port]/path(.git)` and `[user@]host:path(.git)`. A credential in
40
- * the URL is dropped; `hostKinds` names the hosts that are not plain Git.
41
- */
42
- export declare function parseRemote(url: string, hostKinds?: HostKinds): Result<RepoRef, RemoteError>;
43
- /** A remote as a person writes it: the repository, and the branch where the text is the address of a branch's page. */
44
- export type ReadRemote = {
45
- readonly ref: RepoRef;
46
- readonly branch?: string;
47
- };
48
- /**
49
- * A remote as a person writes it, where the domain says the rest: `github.com/owner/repo` and `gitlab.example.com/group/sub/repo` need no `https://`, `owner/repo` is a repository of GitHub,
50
- * `github:owner/repo` and `gitlab:group/sub/repo` name the host's kind, and the address of a branch's page (`.../tree/main`) is the repository and that branch. Every form `parseRemote` reads is read as it does.
51
- * A text that begins with `/`, `.` or `~`, a Windows drive or a `file:` URL is a path on this computer and an error, as it is there.
52
- */
53
- export declare function readRemote(input: string, hostKinds?: HostKinds): Result<ReadRemote, RemoteError>;
54
- /** The HTTPS URL a repository is cloned from, with no credential in it. */
55
- export declare function cloneUrlOf(ref: RepoRef): string;
56
- /** A repository as `host/owner/repo`: the name used in messages, never a URL with a credential. */
57
- export declare function describeRef(ref: RepoRef): string;
58
- /** Whether two references name the same repository: the same host, and paths equal by their case (GitHub and GitLab paths are not case-sensitive). */
59
- export declare function sameRepository(a: RepoRef, b: RepoRef): boolean;
@@ -1,101 +0,0 @@
1
- import type { Result } from "@intellectual-frontiers/core";
2
- /** The kinds of host: the keys of the code list `ifccm:GitManagerKind`, the one list of Git host kinds (`ifccm:hostedOn` ranges over it). */
3
- export type HostKind = "Github" | "Gitlab" | "Git";
4
- /** The capabilities a host may offer: the keys of the code list `ifccm:GitCapability`. */
5
- export type Capability = "CloneUrl" | "Credentials" | "DefaultBranch" | "SignedCommits" | "ProtectedBranches" | "Issues" | "ChangeRequests" | "NestedGroups";
6
- /** A repository on a host: the host name, and the path from it (owner then repository on GitHub; groups to any depth then repository on GitLab). Never contains a scheme or `.git`. */
7
- export type RepoRef = {
8
- readonly kind: HostKind;
9
- /** The host name, such as `github.com`, `gitlab.com` or the name of a self-managed host. */
10
- readonly host: string;
11
- /** The path segments, the last being the repository. */
12
- readonly path: readonly string[];
13
- };
14
- /** Whether a repository may be seen by anyone: `unknown` where the host was not asked or does not say. */
15
- export type Visibility = "public" | "private" | "internal" | "unknown";
16
- /** What a host says of a repository. */
17
- export type RepoInfo = {
18
- readonly ref: RepoRef;
19
- readonly visibility: Visibility;
20
- readonly defaultBranch: string;
21
- /** The URL a clone is made from (HTTPS), without a credential in it. */
22
- readonly cloneUrl: string;
23
- readonly archived: boolean;
24
- };
25
- /** What a host says of an issue: the words and sections the change-control check reads. */
26
- export type IssueInfo = {
27
- /** The number the host gives it, in the repository (`#N` on GitHub, `#N` of a project on GitLab). */
28
- readonly number: number;
29
- readonly title: string;
30
- readonly body: string;
31
- readonly state: "open" | "closed";
32
- readonly url: string;
33
- /** The issue this one is a child of, where the host has parent and child issues. */
34
- readonly parent?: number | undefined;
35
- /** The issues that are children of this one, where the host has them. */
36
- readonly children: readonly number[];
37
- readonly labels: readonly string[];
38
- /**
39
- * Whether `parent` and `children` are the host's answer (`known`) or the host's API offers no parent and child issues, so that they are empty for want of an answer
40
- * (`unavailable`: GitLab's REST API v4). Absent means `known`.
41
- */
42
- readonly hierarchy?: "known" | "unavailable" | undefined;
43
- };
44
- /** What a host says of a pull request or a merge request. */
45
- export type ChangeRequestInfo = {
46
- readonly number: number;
47
- readonly title: string;
48
- readonly state: "open" | "closed" | "merged";
49
- readonly url: string;
50
- readonly sourceBranch: string;
51
- readonly targetBranch: string;
52
- };
53
- /** Whether a branch of a repository is protected (no push, no force, review required). */
54
- export type BranchProtection = {
55
- readonly branch: string;
56
- readonly protected: boolean;
57
- readonly requiresReview: boolean;
58
- readonly allowsForcePush: boolean;
59
- /**
60
- * `protected-only` where the host says the branch is protected and the credential may not read the rules (GitHub shows them to administrators only), so that `requiresReview` and
61
- * `allowsForcePush` are `false` for want of an answer, not by the host's word. Absent means `full`.
62
- */
63
- readonly detail?: "full" | "protected-only" | undefined;
64
- };
65
- /** Why a host did not answer. */
66
- export type HostFailure = {
67
- readonly kind: "unsupported";
68
- readonly capability: Capability;
69
- readonly host: HostKind;
70
- } | {
71
- readonly kind: "unauthorized";
72
- readonly reason: string;
73
- } | {
74
- readonly kind: "not-found";
75
- readonly what: string;
76
- } | {
77
- readonly kind: "rate-limited";
78
- readonly retryAfterSeconds?: number | undefined;
79
- } | {
80
- readonly kind: "unreachable";
81
- readonly reason: string;
82
- } | {
83
- readonly kind: "unexpected";
84
- readonly status: number;
85
- readonly reason: string;
86
- };
87
- /** An answer of a host. */
88
- export type HostResult<T> = Result<T, HostFailure>;
89
- /** The one interface to a host. Every method that a host may lack returns `unsupported` for it, and `capabilities` says which. */
90
- export type GitHostClient = {
91
- readonly kind: HostKind;
92
- readonly capabilities: ReadonlySet<Capability>;
93
- repository(ref: RepoRef): Promise<HostResult<RepoInfo>>;
94
- issue(ref: RepoRef, number: number): Promise<HostResult<IssueInfo>>;
95
- changeRequest(ref: RepoRef, number: number): Promise<HostResult<ChangeRequestInfo>>;
96
- branchProtection(ref: RepoRef, branch: string): Promise<HostResult<BranchProtection>>;
97
- /** Whether the commit's signature is verified by the host, where the host can say. */
98
- commitVerified(ref: RepoRef, sha: string): Promise<HostResult<boolean>>;
99
- };
100
- /** The words of a failure, as a sentence for a finding. */
101
- export declare function describeFailure(f: HostFailure): string;