Skip to content

Commit

Permalink
Merge pull request #13 from pubpub/fix/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah authored Jan 10, 2024
2 parents 06981c0 + f4f12f0 commit 0115856
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 100 deletions.
2 changes: 1 addition & 1 deletion core
Submodule core updated 57 files
+6 −0 .jest/setup-env.js
+2 −0 client/components/Editor/schemas/math.tsx
+7 −2 client/containers/App/App.tsx
+4 −1 client/containers/DashboardOverview/CollectionOverview/collectionState.ts
+9 −1 client/containers/DashboardSettings/PubSettings/PubSettings.tsx
+9 −0 client/layouts/CollapsibleHeaderBPC/CollapsibleHeader.stories.tsx
+137 −0 client/layouts/CollapsibleHeaderBPC/CollapsibleHeader.tsx
+354 −0 client/layouts/CollapsibleHeaderBPC/collapsibleHeader.scss
+53 −0 client/layouts/CollapsibleHeaderBPC/collapsibleHeaderData.ts
+2 −0 client/layouts/CollapsibleHeaderBPC/index.ts
+1 −0 client/layouts/index.ts
+18 −0 package-lock.json
+1 −0 package.json
+30 −0 server/citation/__tests__/api.test.ts
+40 −27 server/citation/api.ts
+7 −1 server/facets/update.ts
+2 −0 server/hooks.ts
+4 −1 server/login/api.ts
+2 −1 server/logout/api.ts
+1 −0 server/member/hooks.ts
+18 −0 server/pub/__tests__/api.test.ts
+14 −19 server/pub/api.ts
+16 −6 server/pub/queries.ts
+30 −11 server/pubAttribution/hooks.ts
+24 −0 server/release/hooks.ts
+87 −11 server/routes/pubDocument.tsx
+5 −1 server/routes/pubDownloads.ts
+42 −0 server/routes/user.tsx
+31 −17 server/server.ts
+4 −1 server/user/api.ts
+40 −0 server/user/hooks.ts
+38 −38 server/user/queries.ts
+25 −1 server/userNotification/create.ts
+1 −1 server/userScopeVisit/queries.ts
+1 −2 server/utils/queryHelpers/communityOverview.ts
+5 −1 server/utils/queryHelpers/pubEnrich.ts
+6 −6 server/utils/search.ts
+10 −2 server/utils/workers.ts
+8 −0 server/workerTask/queries.ts
+9 −2 stubstub/modelize/builders.ts
+1 −0 utils/api/contracts/pub.ts
+1 −1 utils/api/schemas/facets.ts
+611 −0 utils/caching/__tests__/purge.test.ts
+129 −0 utils/caching/caching_strategy.md
+66 −0 utils/caching/createPurgeHooks.ts
+13 −0 utils/caching/getCorrectHostname.ts
+6 −0 utils/caching/getHashedUserId.ts
+107 −0 utils/caching/purgeMiddleware.ts
+69 −0 utils/caching/purgeSurrogateTag.ts
+78 −0 utils/caching/schedulePurge.ts
+25 −0 utils/caching/skipPurgeConditions.ts
+60 −0 utils/caching/uniqueCommunitiesFromMembersQuery.ts
+1 −1 utils/pubEdge/helpers.ts
+24 −3 workers/queue.ts
+4 −1 workers/tasks/export/export.ts
+4 −0 workers/tasks/export/metadata.ts
+1 −0 workers/tasks/export/types.ts
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 67 additions & 83 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,6 @@ You need to be **logged in** and have access to this resource.
accentTextColor: string
avatar: null | string
citeAs: null | string
communityId: string
defaultPubCollections: null | string[]
description: null | string
domain: null | string
Expand Down Expand Up @@ -3643,7 +3642,7 @@ You need to be **logged in** and have access to this resource.
CitationStyle:
| undefined
| {
citationStyle:
citationStyle?:
| 'acm-siggraph'
| 'american-anthro'
| 'apa'
Expand All @@ -3657,12 +3656,18 @@ You need to be **logged in** and have access to this resource.
| 'mla'
| 'vancouver'
| 'ama'
inlineCitationStyle: 'label' | 'count' | 'authorYear' | 'author'
| undefined
inlineCitationStyle?:
| 'label'
| 'count'
| 'authorYear'
| 'author'
| undefined
}
License:
| undefined
| {
kind:
kind?:
| 'cc-by'
| 'cc-0'
| 'cc-by-nc'
Expand All @@ -3671,30 +3676,53 @@ You need to be **logged in** and have access to this resource.
| 'cc-by-nc-sa'
| 'cc-by-sa'
| 'copyright'
copyrightSelection: {
choice: 'infer-from-scope' | 'choose-here'
year: number | null
}
| undefined
copyrightSelection?:
| {
choice?: 'infer-from-scope' | 'choose-here' | undefined
year?: number | null | undefined
}
| undefined
}
NodeLabels:
| undefined
| {
image: { enabled: boolean; text: string }
video: { enabled: boolean; text: string }
audio: { enabled: boolean; text: string }
table: { enabled: boolean; text: string }
math: { enabled: boolean; text: string }
iframe: { enabled: boolean; text: string }
image?:
| { enabled?: boolean | undefined; text?: string | undefined }
| undefined
video?:
| { enabled?: boolean | undefined; text?: string | undefined }
| undefined
audio?:
| { enabled?: boolean | undefined; text?: string | undefined }
| undefined
table?:
| { enabled?: boolean | undefined; text?: string | undefined }
| undefined
math?:
| { enabled?: boolean | undefined; text?: string | undefined }
| undefined
iframe?:
| { enabled?: boolean | undefined; text?: string | undefined }
| undefined
}
PubEdgeDisplay:
| undefined
| { defaultsToCarousel: boolean; descriptionIsVisible: boolean }
| {
defaultsToCarousel?: boolean | undefined
descriptionIsVisible?: boolean | undefined
}
PubHeaderTheme:
| undefined
| {
backgroundImage: string
backgroundColor: string
textStyle: 'light' | 'dark' | 'black-blocks' | 'white-blocks'
backgroundImage?: string | undefined
backgroundColor?: string | undefined
textStyle?:
| 'light'
| 'dark'
| 'black-blocks'
| 'white-blocks'
| undefined
}
}
scope: {
Expand Down Expand Up @@ -4603,67 +4631,25 @@ You need to be **logged in** and have access to this resource.
`input?`

```ts

| {
avatar: null | string
collectionId: null | string
communityId: string
createPubToken: undefined
customPublishedAt: null | string
description: null | string
doi: null | string
downloads:
| null
| {
createdAt: string
type: 'formatted'
url: string
}[]
htmlDescription: null | string
htmlTitle: null | string
slug: string
title: string
}
| {
avatar: null | string
collectionId: undefined
communityId: string
createPubToken: null | string
customPublishedAt: null | string
description: null | string
doi: null | string
downloads:
| null
| {
createdAt: string
type: 'formatted'
url: string
}[]
htmlDescription: null | string
htmlTitle: null | string
slug: string
title: string
}
| {
avatar: null | string
collectionId: undefined
communityId: string
createPubToken: undefined
customPublishedAt: null | string
description: null | string
doi: null | string
downloads:
| null
| {
createdAt: string
type: 'formatted'
url: string
}[]
htmlDescription: null | string
htmlTitle: null | string
slug: string
title: string
}
{
avatar: null | string
collectionId: null | string
createPubToken: null | string
customPublishedAt: null | string
description: null | string
doi: null | string
downloads:
| null
| {
createdAt: string
type: 'formatted'
url: string
}[]
htmlDescription: null | string
htmlTitle: null | string
slug: string
title: string
}
```

`rest?`
Expand Down Expand Up @@ -4763,8 +4749,7 @@ You need to be **logged in** and have access to this resource.
`input`

```ts
{
}
;undefined | null | {}
```

`rest`
Expand Down Expand Up @@ -4839,8 +4824,7 @@ You need to be **logged in** and have access to this resource.
`input`

```ts
{
}
;undefined | null | {}
```

`rest`
Expand Down
41 changes: 25 additions & 16 deletions src/lib/client-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,44 @@ export type Prettify<T> = {
export type ProxiedFunction<
F,
IsGetRoute extends boolean = false,
Property extends 'body' | 'query' = IsGetRoute extends false
BodyOrQuery extends 'body' | 'query' = IsGetRoute extends false
? 'body'
: 'query',
> = F extends (...args: infer A extends any[]) => infer R
? A[0] extends { [K in Property]: infer B }
> = F extends (...args: infer Arguments extends any[]) => infer R
? Arguments[0] extends { [K in BodyOrQuery]: infer B }
? // if only the body is required, make the second argument optional
Partial<Omit<A[0], Property>> extends Omit<A[0], Property>
? FormData extends B
Partial<Omit<Arguments[0], BodyOrQuery>> extends Omit<
Arguments[0],
BodyOrQuery
>
? // form bodies look like FormData & {...}, we don't want to require the FormData part
FormData extends B
? (
input: Exclude<B, FormData>,
rest?: Prettify<Omit<A[0], Property>>,
rest?: Prettify<Omit<Arguments[0], BodyOrQuery>>,
) => R
: Partial<Omit<B, 'communityId'>> extends Omit<B, 'communityId'>
? // if there are no required arguments, you don't need to pass the body
(
input?: Prettify<B>, //Prettify<Omit<B, 'communityId'>>,
rest?: Prettify<Omit<A[0], Property>>,
input?: Prettify<Omit<B, 'communityId'>>, //Prettify<Omit<B, 'communityId'>>,
rest?: Prettify<Omit<Arguments[0], BodyOrQuery>>,
) => R
: (
input: Prettify<Omit<B, 'communityId'>>,
rest?: Prettify<Omit<A[0], Property>>,
rest?: Prettify<Omit<Arguments[0], BodyOrQuery>>,
) => R
: (
input: Prettify<Omit<B, 'communityId'>>,
rest: Prettify<Omit<A[0], Property>>,
) => R
: undefined extends A[0]
? (input?: Prettify<A[0]>) => R
: (input: Prettify<A[0]>) => R
: FormData extends B
? (
input: Exclude<B, FormData>,
rest: Prettify<Omit<Arguments[0], BodyOrQuery>>,
) => R
: (
input: Prettify<Omit<B, 'communityId'>>,
rest: Prettify<Omit<Arguments[0], BodyOrQuery>>,
) => R
: undefined extends Arguments[0]
? (input?: Prettify<Arguments[0]>) => R
: (input: Prettify<Arguments[0]>) => R
: never

export type ProxiedClient<T> = {
Expand Down
30 changes: 30 additions & 0 deletions test/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ describe('PubPub', () => {

// it('should be able to update a community', async () => {})

let importedPubId: string
it('should be able to import a pub', async () => {
const { body } = await pubpub.pub.text.import({
files: [
Expand All @@ -190,6 +191,35 @@ describe('PubPub', () => {
expect(JSON.stringify(doc)?.includes('heya')).toBeTruthy()
expect(pub).toHaveProperty('title')
expect(pub.title).toBe('imported pub')

importedPubId = pub.id
}, 20000)

it('should be able to import to a pub', async () => {
const { body } = await pubpub.pub.text.importToPub(
{
files: [
{
blob: new Blob([':D'], { type: 'text/plain' }),
filename: 'happy.txt',
},
],
method: 'append',
},
{
params: {
pubId: importedPubId,
},
},
)

const { doc, pub } = body

expect(pub.id).toEqual(importedPubId)

const stringDoc = JSON.stringify(doc)
expect(stringDoc).toContain(':D')
expect(stringDoc).toContain('heya')
}, 20000)

it('should be able to query things', async () => {
Expand Down

0 comments on commit 0115856

Please sign in to comment.