@molecule/api-git-provider-gitea 1.0.2

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/README.md ADDED
@@ -0,0 +1,86 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-07T00:19:25.239Z
7
+ -->
8
+
9
+ # @molecule/api-git-provider-gitea
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ `@molecule/api-git-provider-gitea` — a `@molecule/api-git-provider` bond.
16
+
17
+ Register it with `registerGitProvider(provider)` in `setupBonds()`; the app
18
+ then never names this host. See the core package for the interface and for
19
+ why `basicAuthUsername` may be null.
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { registerGitProvider } from '@molecule/api-git-provider'
25
+ import { provider } from '@molecule/api-git-provider-gitea'
26
+
27
+ registerGitProvider(provider)
28
+ ```
29
+
30
+ ## Type
31
+
32
+ `provider`
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ npm install @molecule/api-git-provider-gitea @molecule/api-git-provider @molecule/api-http
38
+ ```
39
+
40
+ ## API
41
+
42
+ ### Constants
43
+
44
+ #### `provider`
45
+
46
+ The Gitea provider.
47
+
48
+ `defaultHost` is `gitea.com`, the project's own hosted instance, but Gitea is
49
+ overwhelmingly SELF-HOSTED — Forgejo and Codeberg are the same API. Point a
50
+ deployment at its own instance by overriding the host; the API paths below are
51
+ identical across all of them.
52
+
53
+ ```typescript
54
+ const provider: GitProvider
55
+ ```
56
+
57
+ ## Core Interface
58
+
59
+ Implements `@molecule/api-git-provider` interface.
60
+
61
+ ## Bond Wiring
62
+
63
+ Setup function to register this provider with the core interface:
64
+
65
+ ```typescript
66
+ import { registerGitProvider } from '@molecule/api-git-provider'
67
+ import { provider } from '@molecule/api-git-provider-gitea'
68
+
69
+ export function setupGitProviderGitea(): void {
70
+ registerGitProvider(provider)
71
+ }
72
+ ```
73
+
74
+ ## Injection Notes
75
+
76
+ ### Requirements
77
+
78
+ Peer dependencies:
79
+
80
+ - `@molecule/api-git-provider` ^1.0.2
81
+ - `@molecule/api-http` ^1.0.1
82
+
83
+ ### Runtime Dependencies
84
+
85
+ - `@molecule/api-git-provider`
86
+ - `@molecule/api-http`
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `@molecule/api-git-provider-gitea` — a `@molecule/api-git-provider` bond.
3
+ *
4
+ * Register it with `registerGitProvider(provider)` in `setupBonds()`; the app
5
+ * then never names this host. See the core package for the interface and for
6
+ * why `basicAuthUsername` may be null.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { registerGitProvider } from '@molecule/api-git-provider'
11
+ * import { provider } from '@molecule/api-git-provider-gitea'
12
+ *
13
+ * registerGitProvider(provider)
14
+ * ```
15
+ *
16
+ * @module
17
+ */
18
+ export * from './provider.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,eAAe,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `@molecule/api-git-provider-gitea` — a `@molecule/api-git-provider` bond.
3
+ *
4
+ * Register it with `registerGitProvider(provider)` in `setupBonds()`; the app
5
+ * then never names this host. See the core package for the interface and for
6
+ * why `basicAuthUsername` may be null.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { registerGitProvider } from '@molecule/api-git-provider'
11
+ * import { provider } from '@molecule/api-git-provider-gitea'
12
+ *
13
+ * registerGitProvider(provider)
14
+ * ```
15
+ *
16
+ * @module
17
+ */
18
+ export * from './provider.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Gitea git-hosting provider — also covers Forgejo and Codeberg.
3
+ *
4
+ * @module
5
+ */
6
+ import type { GitProvider } from '@molecule/api-git-provider';
7
+ /**
8
+ * The Gitea provider.
9
+ *
10
+ * `defaultHost` is `gitea.com`, the project's own hosted instance, but Gitea is
11
+ * overwhelmingly SELF-HOSTED — Forgejo and Codeberg are the same API. Point a
12
+ * deployment at its own instance by overriding the host; the API paths below are
13
+ * identical across all of them.
14
+ */
15
+ export declare const provider: GitProvider;
16
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,WAAW,EAGZ,MAAM,4BAA4B,CAAA;AAmCnC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,WA2DtB,CAAA"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Gitea git-hosting provider — also covers Forgejo and Codeberg.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Normalize Gitea's repository shape.
8
+ *
9
+ * Gitea models its API on GitHub's, so the field names line up — but `size` is
10
+ * KB here as it is there, and `updated_at` stands in for GitHub's `pushed_at`.
11
+ *
12
+ * @param repo - Gitea's repository JSON.
13
+ * @returns The normalized repository, or null when unusable.
14
+ */
15
+ const normalize = (repo) => repo.full_name && repo.clone_url
16
+ ? {
17
+ fullName: repo.full_name,
18
+ url: repo.clone_url,
19
+ private: typeof repo.private === 'boolean' ? repo.private : null,
20
+ defaultBranch: repo.default_branch ?? null,
21
+ sizeKb: typeof repo.size === 'number' ? repo.size : null,
22
+ updatedAt: repo.updated_at ?? null,
23
+ description: repo.description ?? null,
24
+ }
25
+ : null;
26
+ /**
27
+ * The Gitea provider.
28
+ *
29
+ * `defaultHost` is `gitea.com`, the project's own hosted instance, but Gitea is
30
+ * overwhelmingly SELF-HOSTED — Forgejo and Codeberg are the same API. Point a
31
+ * deployment at its own instance by overriding the host; the API paths below are
32
+ * identical across all of them.
33
+ */
34
+ export const provider = {
35
+ id: 'gitea',
36
+ label: 'Gitea',
37
+ defaultHost: 'gitea.com',
38
+ auth: {
39
+ kind: 'oauth',
40
+ // Instance-relative: every Gitea/Forgejo install serves these paths, so the
41
+ // public host is only a default. A self-hosted deployment overrides both.
42
+ authorizeUrl: 'https://gitea.com/login/oauth/authorize',
43
+ tokenUrl: 'https://gitea.com/login/oauth/access_token',
44
+ // Gitea's scopes are coarser than GitHub's: `write:repository` covers push
45
+ // and implies read.
46
+ scope: 'write:repository',
47
+ },
48
+ basicAuthUsername: 'x-access-token',
49
+ apiBaseForHost(host) {
50
+ return `https://${host}/api/v1`;
51
+ },
52
+ apiHeaders(token) {
53
+ const headers = {
54
+ 'user-agent': 'molecule-dev',
55
+ accept: 'application/json',
56
+ };
57
+ if (token)
58
+ headers.authorization = `token ${token}`;
59
+ return headers;
60
+ },
61
+ async listRepositories(input) {
62
+ const { get } = await import('@molecule/api-http');
63
+ const base = this.apiBaseForHost(input.host);
64
+ const response = await get(`${base}/user/repos?limit=${input.perPage}&page=${input.page}`, { headers: this.apiHeaders(input.token), timeout: 15_000 });
65
+ return (response.data ?? []).flatMap((repo) => {
66
+ const normalized = normalize(repo);
67
+ return normalized ? [normalized] : [];
68
+ });
69
+ },
70
+ async getRepository(input) {
71
+ const { get } = await import('@molecule/api-http');
72
+ const base = this.apiBaseForHost(input.host);
73
+ try {
74
+ const response = await get(`${base}/repos/${input.path}`, {
75
+ headers: this.apiHeaders(input.token),
76
+ timeout: 15_000,
77
+ });
78
+ return response.data ? normalize(response.data) : null;
79
+ }
80
+ catch (error) {
81
+ const status = error?.response?.status;
82
+ if (status === 404)
83
+ return null;
84
+ throw error;
85
+ }
86
+ },
87
+ };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@molecule/api-git-provider-gitea",
3
+ "version": "1.0.2",
4
+ "description": "Git hosting provider for Gitea (gitea.com) — OAuth endpoints, token auth shape, repository listing and lookup.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "keywords": [
24
+ "molecule",
25
+ "git",
26
+ "provider",
27
+ "gitea"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/molecule-dev/molecule.git",
33
+ "directory": "packages/api/bonds/git-provider/gitea"
34
+ },
35
+ "devDependencies": {
36
+ "@molecule/api-git-provider": "1.0.2",
37
+ "@molecule/api-http": "1.0.1",
38
+ "@types/node": "26.1.2",
39
+ "typescript": "6.0.3",
40
+ "vitest": "4.1.10"
41
+ },
42
+ "peerDependencies": {
43
+ "@molecule/api-git-provider": "^1.0.2",
44
+ "@molecule/api-http": "^1.0.1"
45
+ }
46
+ }