@llamaduck/forgejo-ts 11.0.10

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,213 @@
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 Configuration
20
+
21
+ ```typescript
22
+ import { configure, RepositoryService, UserService } from '@llamaduck/forgejo-ts';
23
+
24
+ // Configure the client
25
+ configure({
26
+ baseUrl: 'https://your-forgejo-instance.com/api/v1',
27
+ token: 'your-api-token', // Optional: for authenticated requests
28
+ });
29
+
30
+ // Now use any service
31
+ const repos = await RepositoryService.repoSearch({ q: 'hello' });
32
+ console.log(repos);
33
+ ```
34
+
35
+ ### Authentication Options
36
+
37
+ ```typescript
38
+ import { configure } from '@llamaduck/forgejo-ts';
39
+
40
+ // Token authentication (recommended)
41
+ configure({
42
+ baseUrl: 'https://your-forgejo-instance.com/api/v1',
43
+ token: 'your-personal-access-token',
44
+ });
45
+
46
+ // Basic authentication
47
+ configure({
48
+ baseUrl: 'https://your-forgejo-instance.com/api/v1',
49
+ username: 'your-username',
50
+ password: 'your-password',
51
+ });
52
+ ```
53
+
54
+ ### Direct OpenAPI Configuration
55
+
56
+ For more control, you can configure the OpenAPI object directly:
57
+
58
+ ```typescript
59
+ import { OpenAPI } from '@llamaduck/forgejo-ts';
60
+
61
+ OpenAPI.BASE = 'https://your-forgejo-instance.com/api/v1';
62
+ OpenAPI.TOKEN = 'your-api-token';
63
+
64
+ // Or use a function for dynamic token retrieval
65
+ OpenAPI.TOKEN = async () => {
66
+ return getTokenFromSomewhere();
67
+ };
68
+ ```
69
+
70
+ ### Using Services
71
+
72
+ All API endpoints are organized into services:
73
+
74
+ ```typescript
75
+ import {
76
+ RepositoryService,
77
+ UserService,
78
+ OrganizationService,
79
+ IssueService,
80
+ AdminService,
81
+ // ... and more
82
+ } from '@llamaduck/forgejo-ts';
83
+
84
+ // Get current user
85
+ const user = await UserService.userGetCurrent();
86
+
87
+ // List repositories
88
+ const repos = await RepositoryService.repoSearch({
89
+ q: 'typescript',
90
+ limit: 10,
91
+ });
92
+
93
+ // Create an issue
94
+ const issue = await IssueService.issueCreateIssue({
95
+ owner: 'username',
96
+ repo: 'repo-name',
97
+ body: {
98
+ title: 'Bug report',
99
+ body: 'Description of the bug',
100
+ },
101
+ });
102
+ ```
103
+
104
+ ### Error Handling
105
+
106
+ ```typescript
107
+ import { ApiError, RepositoryService } from '@llamaduck/forgejo-ts';
108
+
109
+ try {
110
+ const repo = await RepositoryService.repoGet({
111
+ owner: 'user',
112
+ repo: 'nonexistent',
113
+ });
114
+ } catch (error) {
115
+ if (error instanceof ApiError) {
116
+ console.error('API Error:', error.status, error.message);
117
+ console.error('Response body:', error.body);
118
+ }
119
+ }
120
+ ```
121
+
122
+ ### Canceling Requests
123
+
124
+ ```typescript
125
+ import { RepositoryService, CancelError } from '@llamaduck/forgejo-ts';
126
+
127
+ const request = RepositoryService.repoSearch({ q: 'test' });
128
+
129
+ // Cancel the request
130
+ request.cancel();
131
+
132
+ try {
133
+ await request;
134
+ } catch (error) {
135
+ if (error instanceof CancelError) {
136
+ console.log('Request was canceled');
137
+ }
138
+ }
139
+ ```
140
+
141
+ ## Available Services
142
+
143
+ - `ActivitypubService` - ActivityPub federation endpoints
144
+ - `AdminService` - Administration endpoints (requires admin access)
145
+ - `IssueService` - Issues and pull requests
146
+ - `MiscellaneousService` - Miscellaneous endpoints (version, settings, etc.)
147
+ - `NotificationService` - User notifications
148
+ - `OrganizationService` - Organizations and teams
149
+ - `PackageService` - Package registry
150
+ - `RepositoryService` - Repositories, branches, commits, files
151
+ - `SettingsService` - Instance settings
152
+ - `UserService` - Users, followers, tokens, keys
153
+
154
+ ## Version Information
155
+
156
+ ```typescript
157
+ import { FORGEJO_API_VERSION, GENERATED_AT } from '@llamaduck/forgejo-ts';
158
+
159
+ console.log('API Version:', FORGEJO_API_VERSION);
160
+ console.log('Generated:', GENERATED_AT);
161
+ ```
162
+
163
+ ## Automatic Updates
164
+
165
+ This package is automatically updated via GitHub Actions:
166
+
167
+ - **Daily checks**: Runs every day at 6:00 AM UTC to check for new Forgejo versions
168
+ - **Automatic generation**: When a new version is detected, the client is regenerated from the Forgejo API spec
169
+ - **Automatic publishing**: New versions are automatically published to npm
170
+
171
+ The package version matches the Forgejo version it was generated from.
172
+
173
+ ## Manual Generation
174
+
175
+ To generate the client locally:
176
+
177
+ ```bash
178
+ # Clone the repository
179
+ git clone https://github.com/your-username/forgejo-ts.git
180
+ cd forgejo-ts
181
+
182
+ # Install dependencies
183
+ npm install
184
+
185
+ # Generate client for a specific Forgejo version
186
+ FORGEJO_VERSION=14.0.2 npm run generate
187
+
188
+ # Build
189
+ npm run build
190
+ ```
191
+
192
+ The script fetches the Swagger spec directly from Codeberg.
193
+
194
+ ## Configuration
195
+
196
+ The `config.json` file specifies which major versions to track:
197
+
198
+ ```json
199
+ {
200
+ "latest": 14,
201
+ "lts": 11
202
+ }
203
+ ```
204
+
205
+ When Forgejo releases a new major version (e.g., v15), update this file to change the tracked versions.
206
+
207
+ ## Contributing
208
+
209
+ Contributions are welcome! Please note that the `src/generated/` directory is auto-generated and should not be manually edited.
210
+
211
+ ## License
212
+
213
+ MIT