Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix communities #21

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 25 additions & 67 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,10 @@ Create a community

```ts
create: (input, rest?) =>
Promise<{ status: 201; body: string; headers: Headers }>
Promise<
| { status: 201; body: string; headers: Headers }
| { status: 409; body: string; headers: Headers }
>
```

##### Access
Expand Down Expand Up @@ -2830,11 +2833,18 @@ You need to be **logged in** and have access to this resource.
##### Returns

```ts
Promise<{
status: 201
body: string
headers: Headers
}>
Promise<
| {
status: 201
body: string
headers: Headers
}
| {
status: 409
body: string
headers: Headers
}
>
```

#### `pubpub.community.get`
Expand Down Expand Up @@ -3287,8 +3297,14 @@ You need to be **logged in** and have access to this resource.

```ts
{
cache: RequestCache
extraHeaders: Record<string, undefined | string>
cache?: RequestCache | undefined
extraHeaders?:
| ({
[x: string]: undefined
[x: number]: undefined
[x: symbol]: undefined
} & Record<string, string | undefined>)
| undefined
}
```

Expand Down Expand Up @@ -6318,65 +6334,7 @@ Promise<{
Create a pub and upload a file and import it to a pub.

```ts
;(input, rest?) =>
Promise<{
status: 201
body: {
pub: {
id: string
communityId: string
title: string
description: string | null
avatar: string | null
viewHash: string | null
editHash: string | null
scopeSummaryId: string | null
slug: string
metadata: {
mtg_id: string
bibcode: string
mtg_presentation_id: string
} | null
doi: string | null
crossrefDepositRecordId: string | null
attributions: {
id: string
pubId: string
title: string | null
avatar: string | null
name: string | null
order: number
userId: string | null
orcid: string | null
isAuthor: boolean | null
roles: string[] | null
affiliation: string | null
createdAt?: string | undefined
updatedAt?: string | undefined
}[]
htmlTitle: string | null
htmlDescription: string | null
customPublishedAt: string | null
labels:
| { id: string; title: string; color: string; publicApply: boolean }[]
| null
downloads:
| { createdAt: string; type: 'formatted'; url: string }[]
| null
reviewHash: string | null
commentHash: string | null
draftId: string
createdAt?: string | undefined
updatedAt?: string | undefined
}
doc: {
type: 'doc'
content: any[]
attrs?: Record<string, any> | undefined
}
}
headers: Headers
}>
import: (input, rest?) => Promise<{ status: 201; body: { pub: { id: string; communityId: string; title: string; description: string | null; avatar: string | null; viewHash: string | null; editHash: string | null; scopeSummaryId: string | null; slug: string; metadata: { mtg_id: string; bibcode: string; mtg_presentation_id: string; } | null; doi: string | null; crossrefDepositRecordId: string | null; attributions: { id: string; pubId: string; title: string | null; avatar: string | null; name: string | null; order: number; userId: string | null; orcid: string | null; isAuthor: boolean | null; roles: string[] | null; affiliation: string | null; createdAt?: string | undefined; updatedAt?: string | undefined; }[]; htmlTitle: string | null; htmlDescription: string | null; customPublishedAt: string | null; labels: { id: string; title: string; color: string; publicApply: boolean; }[] | null; downloads: { createdAt: string; type: "formatted"; url: string; }[] | null; reviewHash: string | null; commentHash: string | null; draftId: string; createdAt?: string | undefined; updatedAt?: string | undefined; }; doc: { type: "doc"; content: any[]; attrs?: Record<string, any> | undefined; }; }; headers: Headers; }>;
```

###### Access
Expand Down
1 change: 1 addition & 0 deletions src/lib/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type RemovedRequests = keyof RemovedRequestsMap
export const getRequestsMap = {
get: true,
getMany: true,
getCommunities: true,
logout: true,
uploadPolicy: true,
} as const
Expand Down
14 changes: 14 additions & 0 deletions test/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ describe('PubPub', () => {
expect(json).toBeDefined()
})

it('should be able to get a community', async () => {
const {
body: [community],
} = await pubpub.community.getCommunities()

const { body: communtiy2 } = await pubpub.community.get({
params: {
id: community.id,
},
})

expect(communtiy2.id).toEqual(community.id)
})

it('should be able to get pubs', async () => {
const { body: pubs } = await pubpub.pub.getMany({
query: {
Expand Down
Loading