import { G as GetManyOptions, q as PubsManyResponse, s as Pub, c as PubPutPayload, g as License, N as NodeLabels, f as PubEdgeDisplay, e as PubHeaderTheme, h as CitationStyle, d as Facets, O as ReleaseResponse, p as WorkerTaskImportOutput, E as ExportFormats, aa as InitialData, ac as CollectionViewData, ad as PubViewDataDash, ae as CommunityViewData, af as PubViewDataPub, ab as CommunityData, j as CollectionKind, z as UpdateCollectionsMetaData, J as FacetsProps, A as Attribution, u as AttributionsPayload, l as CommunityPutPayload, k as CommunityPutResponse, H as allowedMimeTypes } from '../types-1a9baa55.js'; import { CollectionInitialData, Collection } from './collectionData.js'; import { Fragment } from 'prosemirror-model'; import { buildSchema } from './editor/schema.js'; import './editor/firebase.js'; import 'prosemirror-transform'; import 'firebase/database'; import './editor/types.js'; import './type-helpers.js'; /** * PubPub API client * * @example * * ```ts * * const communityId = '...' * const communityUrl = 'https://openpresstiu.pubpub.org' * * const pubpub = new PubPub(communityId, communityUrl) * * await pubpub.login(process.env.EMAIL, process.env.PASSWORD) * * const pub = await pubpub.createPub(communityId) * * * ``` */ declare class PubPub { private cookie?; communityId: string; communityUrl: string; loggedIn: boolean; private AWS_S3; constructor(communityId: string, communityUrl: string); /** * Login to the PubPub API. Needs to be called before any other method. **/ login(email: string, password: string): Promise; logout(): Promise>; authedRequest | string | void = Record | string>(path: string, method: 'GET', options?: RequestInit): Promise; authedRequest | string | void = Record | string>(path: string, method: 'POST' | 'PATCH' | 'PUT' | 'DELETE', body?: Record, options?: RequestInit): Promise; getPage: (slug: string) => Promise; /** * Helper method to update the facets of a pub or collection */ private updateFacets; /** * Methods for interacting with pages * * Very limited for now */ page: { /** * Create a new page */ create: ({ title, slug, description, }: { title: string; slug: string; description?: string | undefined; }) => Promise>; }; getManyPubs: (options?: GetManyOptions) => Promise; /** * Methods for interacting with pubs */ pub: { /** * Create a new pub * * At the moment it isn't possible to set any properties of the Pub when creating it, so you'll have to call `pub.update` after creating it * * @param collectionId The id of the collection you want to add the pub to */ create: (collectionId?: string) => Promise; /** * Update a pub * * This is a helper method that calls `/api/facets` and `PUT /api/pubs` under the hood * * @param pubId The id of the pub you want to update * @param props The properties you want to update */ update: (pubId: string, { title, description, avatar, slug, customPublishedAt, downloads, htmlTitle, license, doi, nodeLabels, pubEdgeDisplay, pubHeaderTheme, citationStyle, }: Omit & { license?: License | undefined; nodeLabels?: NodeLabels | undefined; pubEdgeDisplay?: PubEdgeDisplay | undefined; pubHeaderTheme?: PubHeaderTheme | undefined; citationStyle?: CitationStyle | undefined; }) => Promise>; /** * Remove a pub * * @param pubId The id of the pub you want to remove */ remove: (pubId: string) => Promise>; /** * Get a pub by its id * * @param pubId The id of the pub you want to get */ get: (pubId: string) => Promise; /** * Create a release for a pub * * @param pubId The id of the pub you want to create a release for */ createRelease: (pubId: string, { noteText, noteContent, }?: { noteText?: string | undefined; noteContent?: string | undefined; }) => Promise; /** * First connects to Firebase * Imports the files * Then sends the imported file to firebase * * @param pubSlug: The slug of the pub you want to import, including /draft. The slug is everything after the community url, e.g. /pub/my-pub-slug/draft * @param filesToImport: The files you want to import * @param postProcessor: A function that takes the document and returns a new document. This allows you to do custom post-processing on the document to do things that the PubPub importer does not allow yet, e.g. setting captions on Figures from an imported Word document. */ import: (pubSlug: string, filesToImport: FileImportPayload[] | FileImportPayload[][], postProcessor?: ((doc: Fragment, schema: ReturnType) => Fragment) | undefined) => Promise<{ importedFiles: WorkerTaskImportOutput; }>; export: ({ slug, pubId, format, }: ({ slug: string; pubId?: undefined; } | { slug?: undefined; pubId: string; }) & { format: ExportFormats; }) => Promise; content: any[]; }>; /** * Get a list of pubs */ getMany: (options?: GetManyOptions) => Promise; }; /** * These are hacks that are not part of the (un)official API * * Basically, we're scraping the page and parsing the (initial) data from the page, usually in a script tag in JSON format * Very unreliable, could break at any time. */ hacks: { /** * Get the data from a page that's passed as JSON in a script tag to the page * * @param slug The slug of the page * @param data The type of data you want to get, either `initial-data` or `view-data` */ getPageData: (slug: S, data?: D) => Promise : S extends `pub/${string}` ? PubViewDataPub : Record>; getCommunityData: () => Promise; /** * The only way I currently know to get collections is to go to the dashboard and scrape the data from there * * Very unreliable, could break at any time, plus very slow. */ getCollections: () => Promise<{ id: string; title: string; slug: string; avatar?: string | undefined; isRestricted: boolean; isPublic: boolean; viewHash: string; editHash: string; metadata: { doi?: string | undefined; url?: string | undefined; isbn?: string | undefined; copyrightYear?: string | undefined; publicationDate?: string | undefined; edition?: string | undefined; }; kind: "tag" | "issue" | "book" | "journal"; doi?: string | undefined; readNextPreviewSize: string; layout?: { blocks: { id: string; type: string; content: { text?: string | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id?: string | undefined; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: string | undefined; textAlign?: any; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: any; } | undefined; content?: { text?: string | undefined; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; level: number; fixedId: string; textAlign?: any; }; content: { text: string; type: string; }[]; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: any; textAlign?: any; }; content: { text: string; type: string; marks: { type: string; }[]; }[]; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; fileName?: string | undefined; fileSize?: string | undefined; }; content?: { text: string; type: string; marks?: { type: string; attrs: { href: string; title?: any; target?: any; }; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: any; textAlign?: any; }; content?: { text: string; type: string; marks?: { type: string; attrs: { href: string; title?: any; target?: any; }; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; }; content?: { text?: string | undefined; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text: string; type: string; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: any; textAlign?: any; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: string | undefined; url?: string | undefined; caption?: string | undefined; fileName?: string | undefined; fileSize?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; }; content?: { text?: string | undefined; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; } | undefined; content?: { text: string; type: string; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; }; content: { text: string; type: string; marks?: { type: string; }[] | undefined; }[]; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; class?: any; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text?: string | undefined; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; } | undefined; content?: { text?: string | undefined; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id?: string | undefined; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; class?: (string | null)[] | undefined; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs: { href: string; title?: any; target?: any; }; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: any; textAlign?: any; }; content: { text: string; type: string; marks?: { type: string; }[] | undefined; }[]; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: string | undefined; textAlign?: any; fileName?: string | undefined; fileSize?: string | undefined; }; content?: { type: string; attrs?: { id: string; rtl?: any; class?: any; textAlign?: any; } | undefined; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; text?: string | undefined; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; }; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; } | undefined; content?: { text: string; type: string; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: string | undefined; textAlign?: any; fileName?: string | undefined; fileSize?: string | undefined; }; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; url: string; href: string; size: number; align: string; altText: string; caption: string; hideLabel: boolean; fullResolution: boolean; }; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; }; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; fileName?: string | undefined; fileSize?: string | undefined; level?: number | undefined; fixedId?: string | undefined; }; content?: { text?: string | undefined; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: any; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; fileName?: string | undefined; fileSize?: string | undefined; level?: number | undefined; fixedId?: string | undefined; }; content?: { type: string; attrs?: { id: string; url: string; href?: any; size: number; align: string; altText: string; caption: string; hideLabel: boolean; fullResolution: boolean; } | undefined; text?: string | undefined; marks?: { type: string; attrs: { href: string; title?: any; target?: any; }; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; }; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; }; content?: { text: string; type: string; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | undefined; align?: string | undefined; buttonUrl?: string | undefined; buttonText?: string | undefined; buttonType?: string | undefined; showButton?: boolean | undefined; backgroundSize?: string | undefined; backgroundColor?: string | undefined; backgroundImage?: string | undefined; backgroundHeight?: string | undefined; defaultCollectionIds?: any[] | undefined; sort?: string | undefined; pubPreviewType?: string | undefined; hideDate?: boolean | undefined; html?: string | undefined; hideContributors?: boolean | undefined; title?: string | undefined; hideByline?: boolean | undefined; limit?: number | undefined; pubIds?: string[][] | undefined; collectionIds?: string[] | undefined; items?: { id: string; type: string; }[] | undefined; hideDates?: boolean | undefined; hideEdges?: boolean | undefined; hideDescription?: boolean | undefined; justify?: string | undefined; }; }[]; isNarrow: boolean; } | undefined; pageId?: string | undefined; communityId: string; scopeSummaryId: string; createdAt: string; updatedAt: string; crossrefDepositRecordId?: string | undefined; members: any[]; }[]>; getCollection: (slug: string) => Promise; getFullCollectionById_SLOW: (collectionId: string) => Promise; }; /** * Methods for interacting with collections */ collection: { /** * Create a new collection */ create: ({ title, kind, }: { title: string; kind: CollectionKind; }) => Promise; /** * Update a collection * * This is a helper method that calls `/api/facets` and `PUT /api/collections` under the hood * * @param collectionId The id of the collection you want to update * @param props The properties you want to update */ update: (collectionId: string, { citationStyle, license, nodeLabels, doi, slug, copyrightYear, edition, isbn, publicationDate, title, issue, pubEdgeDisplay, pubHeaderTheme, url, volume, }: UpdateCollectionsMetaData & FacetsProps) => Promise>; /** * Remove a collection * @param collectionId The id of the collection you want to remove */ remove: (collectionId: string) => Promise<{ success: boolean; }>; /** * Add a pub to a collection * * @param collectionId The id of the collection you want to add the pub to * @param pubId The id of the pub you want to add to the collection * */ addPub: (collectionPubId: string) => Promise<{ id: string; collectionId: string; pubId: string; rank: string; pubRank: string; updatedAt: string; createdAt: string; contextHint: null; isPrimary: boolean; }>; /** * Remove a pub from a collection * * @param collectionPubId The id of the pub you want to remove * * @returns The id of the removed pub */ removePub: (collectinPubId: string) => Promise; /** * Methods for interacting with attributions */ attributions: { get: ((id: string) => Promise) | undefined; create: (props: AttributionsPayload) => Promise>; /** * update an attribution * * You can either pass a name or a userId * If you pass a name, it will find the attribution with that name and update it */ update: (props: Omit) => Promise>; remove: (props: Omit) => Promise>; }; hacks: { /** * HACK: Get a list of all collections. Currently done by scraping the dashboard. */ getMany: () => Promise<{ id: string; title: string; slug: string; avatar?: string | undefined; isRestricted: boolean; isPublic: boolean; viewHash: string; editHash: string; metadata: { doi?: string | undefined; url?: string | undefined; isbn?: string | undefined; copyrightYear?: string | undefined; publicationDate?: string | undefined; edition?: string | undefined; }; kind: "tag" | "issue" | "book" | "journal"; doi?: string | undefined; readNextPreviewSize: string; layout?: { blocks: { id: string; type: string; content: { text?: string | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id?: string | undefined; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: string | undefined; textAlign?: any; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: any; } | undefined; content?: { text?: string | undefined; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; level: number; fixedId: string; textAlign?: any; }; content: { text: string; type: string; }[]; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: any; textAlign?: any; }; content: { text: string; type: string; marks: { type: string; }[]; }[]; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; fileName?: string | undefined; fileSize?: string | undefined; }; content?: { text: string; type: string; marks?: { type: string; attrs: { href: string; title?: any; target?: any; }; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: any; textAlign?: any; }; content?: { text: string; type: string; marks?: { type: string; attrs: { href: string; title?: any; target?: any; }; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; }; content?: { text?: string | undefined; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text: string; type: string; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: any; textAlign?: any; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: string | undefined; url?: string | undefined; caption?: string | undefined; fileName?: string | undefined; fileSize?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; }; content?: { text?: string | undefined; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; } | undefined; content?: { text: string; type: string; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; }; content: { text: string; type: string; marks?: { type: string; }[] | undefined; }[]; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; class?: any; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text?: string | undefined; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; } | undefined; content?: { text?: string | undefined; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id?: string | undefined; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; class?: (string | null)[] | undefined; fileName?: string | undefined; fileSize?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs: { href: string; title?: any; target?: any; }; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: any; textAlign?: any; }; content: { text: string; type: string; marks?: { type: string; }[] | undefined; }[]; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: string | undefined; textAlign?: any; fileName?: string | undefined; fileSize?: string | undefined; }; content?: { type: string; attrs?: { id: string; rtl?: any; class?: any; textAlign?: any; } | undefined; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; text?: string | undefined; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; }; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; } | undefined; content?: { text: string; type: string; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; rtl?: any; class?: string | undefined; textAlign?: any; fileName?: string | undefined; fileSize?: string | undefined; }; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; url: string; href: string; size: number; align: string; altText: string; caption: string; hideLabel: boolean; fullResolution: boolean; }; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; }; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; fileName?: string | undefined; fileSize?: string | undefined; level?: number | undefined; fixedId?: string | undefined; }; content?: { text?: string | undefined; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; level?: number | undefined; fixedId?: string | undefined; textAlign?: any; class?: any; } | undefined; content?: { text: string; type: string; marks?: { type: string; attrs?: { href: string; title?: any; target?: any; } | undefined; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; fileName?: string | undefined; fileSize?: string | undefined; level?: number | undefined; fixedId?: string | undefined; }; content?: { type: string; attrs?: { id: string; url: string; href?: any; size: number; align: string; altText: string; caption: string; hideLabel: boolean; fullResolution: boolean; } | undefined; text?: string | undefined; marks?: { type: string; attrs: { href: string; title?: any; target?: any; }; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; url?: string | undefined; href?: any; size?: number | undefined; align?: string | undefined; altText?: string | undefined; caption?: string | undefined; hideLabel?: boolean | undefined; fullResolution?: boolean | undefined; }; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs: { id?: string | undefined; rtl?: any; class?: any; textAlign?: any; }; content?: { text: string; type: string; }[] | undefined; }[]; } | { type: string; attrs: { meta: {}; }; content: { type: string; attrs?: { id: string; rtl?: any; class?: string | undefined; textAlign?: any; level?: number | undefined; fixedId?: string | undefined; } | undefined; content?: { text: string; type: string; marks?: { type: string; }[] | undefined; }[] | undefined; }[]; } | undefined; align?: string | undefined; buttonUrl?: string | undefined; buttonText?: string | undefined; buttonType?: string | undefined; showButton?: boolean | undefined; backgroundSize?: string | undefined; backgroundColor?: string | undefined; backgroundImage?: string | undefined; backgroundHeight?: string | undefined; defaultCollectionIds?: any[] | undefined; sort?: string | undefined; pubPreviewType?: string | undefined; hideDate?: boolean | undefined; html?: string | undefined; hideContributors?: boolean | undefined; title?: string | undefined; hideByline?: boolean | undefined; limit?: number | undefined; pubIds?: string[][] | undefined; collectionIds?: string[] | undefined; items?: { id: string; type: string; }[] | undefined; hideDates?: boolean | undefined; hideEdges?: boolean | undefined; hideDescription?: boolean | undefined; justify?: string | undefined; }; }[]; isNarrow: boolean; } | undefined; pageId?: string | undefined; communityId: string; scopeSummaryId: string; createdAt: string; updatedAt: string; crossrefDepositRecordId?: string | undefined; members: any[]; }[]>; /** * HACK: Gets the data from a specific collection, requires the slug. * If you do not have the slug, use `getByIdSlow` instead. */ get: (slug: string) => Promise; /** * HACK: Get a specific collection. Currently just runs getMany and finds the correct collection from the list, * therefore is not faster than getMany. */ getByIdSlow: (collectionId: string) => Promise; }; }; private makeAttributionsOperations; /** * Upload a file to PubPub. * * @param file The file to upload. Can be a Blob (when using the browser or Node) or a Buffer (when using Node) * @param fileName The name of the file * @param mimeType The mime type of the file * * @returns The URL of the uploaded file on https://assets.pubpub.org * * @example * ### Node * ```ts * const pdf = await fs.readFileSync('path/to/file.pdf') * * const { url } = await pubpub.uploadFile(pdf, 'file.pdf', 'application/pdf') * ``` * * ### Browser * ```ts * const pdf = await fetch('path/to/file.pdf') * const pdfBlob = await pdf.blob() * * const { url } = await pubpub.uploadFile(pdfBlob, 'file.pdf', 'application/pdf') * ``` * * @since 0.3.0 private, allows for passing strings * * This method has been made private to avoid abuse of the upload feature. */ private uploadFile; /** * Returns a signed policy for uploading a file to PubPub. */ private uploadPolicy; /** * Methods for interacting with PubPub on the community level, e.g. changing the community name, adding CSS etc. */ community: { /** * Update the community settings */ update: ({ pubHeaderTheme, license, citationStyle, nodeLabels, pubEdgeDisplay, ...putPayload }: CommunityPutPayload & FacetsProps) => Promise>; /** * Update the global community CSS */ css: (css: string) => Promise<{}>; /** * HACK: Get community data */ get: () => Promise; }; /** * More complete import function thta also takes care of properly uploading and labeling all files. */ private importFull; /** * Basic export function, equivalent to the `/api/export` endpoint */ private exportPub; /** * Basic import function, equivalent to the `/api/import` endpoint */ private importFiles; /** * Pings workertask endpoint until every second until the task is complete */ private waitForWorkerTask; } interface FileImportPayload { file: Blob | Buffer | File | string; fileName: string; mimeType: (typeof allowedMimeTypes)[number]; } export { PubPub };