diff --git a/changelog.md b/changelog.md index 0be781c..b120813 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,14 @@ # Changelog +## 2026-02-28 - 1.1.0 - feat(orgs) +add organization and organization-repository APIs: getOrg, getOrgRepos, createOrg, createOrgRepo + +- Added getOrg(orgName): fetch a single organization by name +- Added getOrgRepos(orgName, opts?): list repositories in an organization with pagination, sorting by updated, and optional search query +- Added createOrg(name, opts?): create a new organization with fullName, description, and visibility (defaults to public) +- Added createOrgRepo(orgName, name, opts?): create a repository within an organization; description optional and private defaults to true +- Endpoints use encodeURIComponent for orgName in URLs to ensure safe requests + ## 2026-02-24 - 1.0.3 - fix(gitea) no changes detected in the diff; no code or doc updates diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index ff88c91..34a0869 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@apiclient.xyz/gitea', - version: '1.0.3', + version: '1.1.0', description: 'A TypeScript client for the Gitea API, providing easy access to repositories, organizations, secrets, and action runs.' } diff --git a/ts/gitea.classes.giteaclient.ts b/ts/gitea.classes.giteaclient.ts index 099392a..301fca0 100644 --- a/ts/gitea.classes.giteaclient.ts +++ b/ts/gitea.classes.giteaclient.ts @@ -149,6 +149,56 @@ export class GiteaClient { return this.request('GET', `/api/v1/orgs?page=${page}&limit=${limit}`); } + /** + * Get a single organization by name + */ + public async getOrg(orgName: string): Promise { + return this.request('GET', `/api/v1/orgs/${encodeURIComponent(orgName)}`); + } + + /** + * List repositories within an organization + */ + public async getOrgRepos(orgName: string, opts?: IListOptions): Promise { + const page = opts?.page || 1; + const limit = opts?.perPage || 50; + let url = `/api/v1/orgs/${encodeURIComponent(orgName)}/repos?page=${page}&limit=${limit}&sort=updated`; + if (opts?.search) { + url += `&q=${encodeURIComponent(opts.search)}`; + } + return this.request('GET', url); + } + + /** + * Create a new organization + */ + public async createOrg(name: string, opts?: { + fullName?: string; + description?: string; + visibility?: string; + }): Promise { + return this.request('POST', '/api/v1/orgs', { + username: name, + full_name: opts?.fullName || name, + description: opts?.description || '', + visibility: opts?.visibility || 'public', + }); + } + + /** + * Create a repository within an organization + */ + public async createOrgRepo(orgName: string, name: string, opts?: { + description?: string; + private?: boolean; + }): Promise { + return this.request('POST', `/api/v1/orgs/${encodeURIComponent(orgName)}/repos`, { + name, + description: opts?.description || '', + private: opts?.private ?? true, + }); + } + // --------------------------------------------------------------------------- // Repository Secrets // ---------------------------------------------------------------------------