@llamaduck/forgejo-ts 11.0.10-1
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 +209 -0
- package/dist/index.d.mts +21297 -0
- package/dist/index.d.ts +21297 -0
- package/dist/index.js +13202 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +12740 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# @llamaduck/forgejo-ts
|
|
2
|
+
|
|
3
|
+
Auto-generated, fully typed TypeScript client for the [Forgejo](https://forgejo.org/) API.
|
|
4
|
+
|
|
5
|
+
This package is automatically updated daily to track the latest Forgejo releases.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @llamaduck/forgejo-ts
|
|
11
|
+
# or
|
|
12
|
+
yarn add @llamaduck/forgejo-ts
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @llamaduck/forgejo-ts
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Basic Usage
|
|
20
|
+
|
|
21
|
+
Create a client and start making API calls:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { createClient, createConfig, getVersion, repoSearch } from '@llamaduck/forgejo-ts';
|
|
25
|
+
|
|
26
|
+
// Create a client
|
|
27
|
+
const client = createClient(createConfig({
|
|
28
|
+
baseUrl: 'https://codeberg.org/api/v1',
|
|
29
|
+
headers: { Authorization: 'token your-api-token' }
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
// Make API calls - pass the client in options
|
|
33
|
+
const version = await getVersion({ client });
|
|
34
|
+
console.log('Server version:', version.data?.version);
|
|
35
|
+
|
|
36
|
+
const repos = await repoSearch({ query: { q: 'typescript', limit: 10 } }, { client });
|
|
37
|
+
console.log('Found repos:', repos.data);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Multiple Clients
|
|
41
|
+
|
|
42
|
+
You can create multiple independent client instances:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { createClient, createConfig, repoSearch } from '@llamaduck/forgejo-ts';
|
|
46
|
+
|
|
47
|
+
const clientA = createClient(createConfig({
|
|
48
|
+
baseUrl: 'https://codeberg.org/api/v1',
|
|
49
|
+
headers: { Authorization: 'token token-a' }
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
const clientB = createClient(createConfig({
|
|
53
|
+
baseUrl: 'https://gitea.com/api/v1',
|
|
54
|
+
headers: { Authorization: 'token token-b' }
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
// Use different clients for different requests
|
|
58
|
+
const reposA = await repoSearch({ query: { q: 'test' } }, { client: clientA });
|
|
59
|
+
const reposB = await repoSearch({ query: { q: 'test' } }, { client: clientB });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Authentication
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { createClient, createConfig } from '@llamaduck/forgejo-ts';
|
|
66
|
+
|
|
67
|
+
// Token authentication (recommended)
|
|
68
|
+
const client = createClient(createConfig({
|
|
69
|
+
baseUrl: 'https://codeberg.org/api/v1',
|
|
70
|
+
headers: { Authorization: 'token your-personal-access-token' }
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
// Basic authentication
|
|
74
|
+
const auth = btoa('username:password');
|
|
75
|
+
const client = createClient(createConfig({
|
|
76
|
+
baseUrl: 'https://codeberg.org/api/v1',
|
|
77
|
+
headers: { Authorization: `Basic ${auth}` }
|
|
78
|
+
}));
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API Reference
|
|
82
|
+
|
|
83
|
+
All API functions are exported directly from the package:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import {
|
|
87
|
+
// Repositories
|
|
88
|
+
repoSearch,
|
|
89
|
+
repoGet,
|
|
90
|
+
userListRepos,
|
|
91
|
+
|
|
92
|
+
// Users
|
|
93
|
+
userGetCurrent,
|
|
94
|
+
userGet,
|
|
95
|
+
|
|
96
|
+
// Issues
|
|
97
|
+
issueSearch,
|
|
98
|
+
issueCreateIssue,
|
|
99
|
+
|
|
100
|
+
// Organizations
|
|
101
|
+
orgGet,
|
|
102
|
+
|
|
103
|
+
// And many more...
|
|
104
|
+
} from '@llamaduck/forgejo-ts';
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Each function accepts:
|
|
108
|
+
1. **Data/params** - The request data (path params, query params, body)
|
|
109
|
+
2. **Options** (optional) - Request options including the `client` instance
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
```typescript
|
|
113
|
+
// Search repositories
|
|
114
|
+
const repos = await repoSearch(
|
|
115
|
+
{ query: { q: 'typescript', limit: 10 } },
|
|
116
|
+
{ client }
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// Get a specific repository
|
|
120
|
+
const repo = await repoGet(
|
|
121
|
+
{ path: { owner: 'forgejo', repo: 'forgejo' } },
|
|
122
|
+
{ client }
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Create an issue
|
|
126
|
+
const issue = await issueCreateIssue(
|
|
127
|
+
{ path: { owner: 'user', repo: 'repo' } },
|
|
128
|
+
{ body: { title: 'Bug report', body: 'Description' } },
|
|
129
|
+
{ client }
|
|
130
|
+
);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Error Handling
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { repoGet } from '@llamaduck/forgejo-ts';
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
const repo = await repoGet(
|
|
140
|
+
{ path: { owner: 'user', repo: 'nonexistent' } },
|
|
141
|
+
{ client }
|
|
142
|
+
);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
if (error.status === 404) {
|
|
145
|
+
console.error('Repository not found');
|
|
146
|
+
} else {
|
|
147
|
+
console.error('API Error:', error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Version Information
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { FORGEJO_API_VERSION, GENERATED_AT } from '@llamaduck/forgejo-ts';
|
|
156
|
+
|
|
157
|
+
console.log('API Version:', FORGEJO_API_VERSION);
|
|
158
|
+
console.log('Generated:', GENERATED_AT);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Automatic Updates
|
|
162
|
+
|
|
163
|
+
This package is automatically updated via GitHub Actions:
|
|
164
|
+
|
|
165
|
+
- **Daily checks**: Runs every day at 6:00 AM UTC to check for new Forgejo versions
|
|
166
|
+
- **Automatic generation**: When a new version is detected, the client is regenerated from the Forgejo API spec
|
|
167
|
+
- **Automatic publishing**: New versions are automatically published to npm
|
|
168
|
+
|
|
169
|
+
The package version matches the Forgejo version it was generated from.
|
|
170
|
+
|
|
171
|
+
## Manual Generation
|
|
172
|
+
|
|
173
|
+
To generate the client locally:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Clone the repository
|
|
177
|
+
git clone https://github.com/your-username/forgejo-ts.git
|
|
178
|
+
cd forgejo-ts
|
|
179
|
+
|
|
180
|
+
# Install dependencies
|
|
181
|
+
npm install
|
|
182
|
+
|
|
183
|
+
# Generate client for a specific Forgejo version
|
|
184
|
+
FORGEJO_VERSION=14.0.2 npm run generate
|
|
185
|
+
|
|
186
|
+
# Build
|
|
187
|
+
npm run build
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Configuration
|
|
191
|
+
|
|
192
|
+
The `config.json` file specifies which major versions to track:
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"latest": 14,
|
|
197
|
+
"lts": 11
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
When Forgejo releases a new major version (e.g., v15), update this file to change the tracked versions.
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
Contributions are welcome! Please note that the `src/generated/` directory is auto-generated and should not be manually edited.
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT
|