Skip to content

Commit

Permalink
Merge pull request #21 from pubpub/fix/communities
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah authored Jun 13, 2024
2 parents 9f1353e + 06f6edf commit 3f756ce
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 68 deletions.
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

0 comments on commit 3f756ce

Please sign in to comment.