@theholocron/codecov-client 0.0.0-stage → 1.58.0-alpha.33
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/LICENSE +21 -0
- package/README.md +22 -2
- package/dist/index.d.mts +60 -0
- package/dist/index.mjs +37 -0
- package/package.json +63 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Newton Koumantzelis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@theholocron/codecov-client`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript client for the [Codecov REST API v2](https://docs.codecov.com/reference/overview).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @theholocron/codecov-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createCodecovClient } from "@theholocron/codecov-client";
|
|
15
|
+
|
|
16
|
+
const codecov = createCodecovClient({ token: process.env.CODECOV_API_TOKEN! });
|
|
17
|
+
|
|
18
|
+
const repo = await codecov.repos.get("github", "theholocron", "holocron");
|
|
19
|
+
const owner = await codecov.owners.get("github", "theholocron");
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The token is a Codecov API (personal access) token, sent as `Authorization: Bearer`. A repository _upload_ token is a
|
|
23
|
+
different credential, and the REST API documents only the personal token.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import "@theholocron/http-client";
|
|
2
|
+
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
3
|
+
/** Options for `createCodecovClient`. */
|
|
4
|
+
interface CodecovClientOptions {
|
|
5
|
+
/** A Codecov API token (a personal access token from the account's Access settings), sent as a bearer token. */
|
|
6
|
+
token: string;
|
|
7
|
+
/** Override base URL for testing. Defaults to https://api.codecov.io/api/v2. */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
/** Structured logger for request/response diagnostics. Defaults to a no-op. */
|
|
12
|
+
logger?: Logger;
|
|
13
|
+
/** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
|
|
14
|
+
errors?: ErrorSink;
|
|
15
|
+
}
|
|
16
|
+
/** The git hosting services Codecov knows an owner by. */
|
|
17
|
+
type CodecovService = "bitbucket" | "bitbucket_server" | "github" | "github_enterprise" | "gitlab" | "gitlab_enterprise";
|
|
18
|
+
/** A repository as Codecov reports it. Only the fields Holocron reads are typed; Codecov sends more. */
|
|
19
|
+
interface CodecovRepo {
|
|
20
|
+
/** The repository name. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Whether the repository is private. */
|
|
23
|
+
private?: boolean;
|
|
24
|
+
/** The default branch. */
|
|
25
|
+
branch?: string;
|
|
26
|
+
/** Whether the repository has received a coverage upload. */
|
|
27
|
+
active?: boolean;
|
|
28
|
+
/** Whether the repository has not been manually deactivated. */
|
|
29
|
+
activated?: boolean;
|
|
30
|
+
/** The owner. */
|
|
31
|
+
author?: {
|
|
32
|
+
/** The service the owner is on. */
|
|
33
|
+
service?: string;
|
|
34
|
+
/** The owner's login. */
|
|
35
|
+
username?: string;
|
|
36
|
+
/** The owner's display name. */
|
|
37
|
+
name?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** An owner (a user or organization) as Codecov reports it. Only the fields Holocron reads are typed. */
|
|
41
|
+
interface CodecovOwner {
|
|
42
|
+
/** The owner's login on the service. */
|
|
43
|
+
username: string;
|
|
44
|
+
/** The service the owner is on. */
|
|
45
|
+
service?: string;
|
|
46
|
+
/** The owner's display name. */
|
|
47
|
+
name?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Creates a Codecov API client with `owners` and `repos` groups, both sharing one REST client. */
|
|
50
|
+
export declare function createCodecovClient(opts: CodecovClientOptions): {
|
|
51
|
+
owners: {
|
|
52
|
+
get: (service: CodecovService, owner: string) => Promise<CodecovOwner>;
|
|
53
|
+
};
|
|
54
|
+
repos: {
|
|
55
|
+
get: (service: CodecovService, owner: string, repo: string) => Promise<CodecovRepo>;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/** The client `createCodecovClient` returns. */
|
|
59
|
+
export type CodecovClient = ReturnType<typeof createCodecovClient>;
|
|
60
|
+
export type { CodecovClientOptions, CodecovOwner, CodecovRepo, CodecovService };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRestClient } from "@theholocron/http-client";
|
|
2
|
+
// src/owners/owners.ts
|
|
3
|
+
/** The `owners` group of the Codecov client. */
|
|
4
|
+
function owners(rest) {
|
|
5
|
+
return {
|
|
6
|
+
/** Get one owner: `GET /{service}/{owner}/`. */
|
|
7
|
+
get: (service, owner) => rest.request(`/${service}/${encodeURIComponent(owner)}/`) };
|
|
8
|
+
}
|
|
9
|
+
// src/repos/repos.ts
|
|
10
|
+
/** The `repos` group of the Codecov client. */
|
|
11
|
+
function repos(rest) {
|
|
12
|
+
return {
|
|
13
|
+
/** Get one repository: `GET /{service}/{owner}/repos/{repo}/`. */
|
|
14
|
+
get: (service, owner, repo) => rest.request(`/${service}/${encodeURIComponent(owner)}/repos/${encodeURIComponent(repo)}/`) };
|
|
15
|
+
}
|
|
16
|
+
// src/utils.ts
|
|
17
|
+
/** Builds the REST client every Codecov group shares. */
|
|
18
|
+
function createCodecovRestClient(opts) {
|
|
19
|
+
return createRestClient({
|
|
20
|
+
baseUrl: opts.baseUrl ?? "https://api.codecov.io/api/v2",
|
|
21
|
+
token: opts.token,
|
|
22
|
+
vendor: "Codecov",
|
|
23
|
+
fetch: opts.fetch,
|
|
24
|
+
logger: opts.logger,
|
|
25
|
+
errors: opts.errors
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// src/index.ts
|
|
29
|
+
/** Creates a Codecov API client with `owners` and `repos` groups, both sharing one REST client. */
|
|
30
|
+
function createCodecovClient(opts) {
|
|
31
|
+
const rest = createCodecovRestClient(opts);
|
|
32
|
+
return {
|
|
33
|
+
owners: owners(rest),
|
|
34
|
+
repos: repos(rest)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export { createCodecovClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/codecov-client",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.58.0-alpha.33",
|
|
4
|
+
"description": "A TypeScript client for the Codecov REST API",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"codecov",
|
|
7
|
+
"coverage",
|
|
8
|
+
"ci",
|
|
9
|
+
"typescript",
|
|
10
|
+
"http-client",
|
|
11
|
+
"api"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://docs.theholocron.dev/holocron/clients/codecov/",
|
|
14
|
+
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/theholocron/holocron.git",
|
|
18
|
+
"directory": "clients/codecov-client"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "Newton Koumantzelis",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"default": "./dist/index.mjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.33",
|
|
36
|
+
"@theholocron/observability": "^0.7.0-alpha.4"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^26",
|
|
40
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
41
|
+
"@vitest/eslint-plugin": "^1.6.28",
|
|
42
|
+
"eslint": "^10.14.0",
|
|
43
|
+
"eslint-plugin-n": "^18.5.0",
|
|
44
|
+
"globals": "^17.14.0",
|
|
45
|
+
"tsdown": "^0.23.5",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vitest": "^5.1.0",
|
|
48
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.17",
|
|
49
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.17",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.17",
|
|
51
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.17"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.0.0"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsdown && node ../scripts/check-bundle-size.mjs",
|
|
61
|
+
"lint:code": "eslint .",
|
|
62
|
+
"test:unit": "vitest run --coverage",
|
|
63
|
+
"test:watch": "vitest",
|
|
64
|
+
"typecheck": "tsc --noEmit"
|
|
65
|
+
}
|
|
6
66
|
}
|