Files
AstralRinth/packages/api-client/src/modules/labrinth/organizations/v3.ts
T
Truman Gao 681ae5d1d8 refactor: removing useAsyncData for tanstack query (#5262)
* refactor: most places with useAsyncData replaced with tanstack query

* refactor report list and report view

* refactor organization page to use tanstack query

* fix types

* refactor collection page and include proper loading state

* fix followed projects proper loading state

* fix 404 handling

* fix organization loading and 404 states

* pnpm prepr

* refactor: remove useAsyncData on newsletter button

* refactor: remove useAsyncData on auth globals fetch

* refactor: settings/billing/index.vue to useQuery instead of useAsyncData

* refactor: user page to remove useAsyncData

* pnpm prepr

* fix reports pages

* fix notifications page

* fix billing page cannot read properties of null and prop warnings

* fix refresh causing 404 by removing useBaseFetch and use api-client

* fix stale data after removing organization from project

* pnpm prepr

* fix news erroring in build

* fix: project page loads header only after content

* fix: user page tanstack problems (start on migrating away from useBaseFetch)

* fix: start swapping useBaseFetch usages to api-client

* Revert "fix: start swapping useBaseFetch usages to api-client"

This reverts commit 3df3fab11d535159132b1288dd7cacc38282b553.

* fix: remove debug logging

* fix: lint

---------

Co-authored-by: Calum H. <calum@modrinth.com>
Co-authored-by: Calum H. (IMB11) <contact@cal.engineer>
2026-03-16 19:10:29 +00:00

53 lines
1.3 KiB
TypeScript

import { AbstractModule } from '../../../core/abstract-module'
import type { Labrinth } from '../types'
export class LabrinthOrganizationsV3Module extends AbstractModule {
public getModuleID(): string {
return 'labrinth_organizations_v3'
}
/**
* Get an organization by ID or slug
*
* @param idOrSlug - Organization ID or slug
* @returns Promise resolving to the organization data
*
* @example
* ```typescript
* const org = await client.labrinth.organizations_v3.get('my-org')
* ```
*/
public async get(idOrSlug: string): Promise<Labrinth.Organizations.v3.Organization> {
return this.client.request<Labrinth.Organizations.v3.Organization>(
`/organization/${idOrSlug}`,
{
api: 'labrinth',
version: 3,
method: 'GET',
},
)
}
/**
* Get an organization's projects
*
* @param idOrSlug - Organization ID or slug
* @returns Promise resolving to the organization's projects
*
* @example
* ```typescript
* const projects = await client.labrinth.organizations_v3.getProjects('my-org')
* ```
*/
public async getProjects(idOrSlug: string): Promise<Labrinth.Projects.v3.Project[]> {
return this.client.request<Labrinth.Projects.v3.Project[]>(
`/organization/${idOrSlug}/projects`,
{
api: 'labrinth',
version: 3,
method: 'GET',
},
)
}
}