Skip to main content

Function: createPreprintRecord()

createPreprintRecord(agent, data): Promise<CreateRecordResult>

Defined in: web/lib/atproto/record-creator.ts:234

Create a preprint submission record in the user's PDS.

Parameters

agent

Agent

Authenticated ATProto Agent

data

Form data with files and metadata

abstract

string = ...

authors

object[] = ...

conflictOfInterest

string = ...

doi

string = ...

object[] = ...

facets

object[] = ...

fieldNodes

object[] = ...

fundingInfo

object[] = ...

keywords

string[] = ...

license

"cc-by-4.0" | "cc-by-sa-4.0" | "cc-by-nc-4.0" | "cc-by-nc-sa-4.0" | "cc0-1.0" | "arxiv-perpetual" = ...

pdfFile

File = ...

PDF file (File object before upload)

preregistration

string = ...

supplementaryFiles

object[] = ...

Supplementary files

title

string = ...

Returns

Promise<CreateRecordResult>

Created record result

Remarks

This is the primary function for submitting preprints. It:

  1. Uploads the PDF document to the user's PDS
  2. Uploads any supplementary materials
  3. Creates the preprint record with blob references

The record is created in the user's PDS, NOT in Chive's storage. Chive will index this record when it appears on the firehose.

Throws

Error if agent is not authenticated

Throws

Error if PDF upload fails

Throws

Error if record creation fails

Example

const agent = useAgent();
if (!agent) throw new Error('Not authenticated');

const result = await createPreprintRecord(agent, {
pdfFile: myPdfFile,
title: 'My Research Paper',
abstract: 'This paper presents...',
authors: [{ did: agent.session.did, order: 1, name: 'Alice' }],
fieldNodes: [{ uri: 'at://did:plc:governance/pub.chive.graph.field/ml' }],
});

console.log('Published at:', result.uri);