MCPcopy
hub / github.com/npmx-dev/npmx.dev / checkPublication

Function checkPublication

modules/standard-site-sync.ts:262–298  ·  view source on GitHub ↗
(identifier: AtIdentifierString, pdsPublicClient: Client)

Source from the content-addressed store, hash-verified

260 * @returns
261 */
262const checkPublication = async (identifier: AtIdentifierString, pdsPublicClient: Client) => {
263 const publicationTid = npmxPublicationRkey()
264
265 //Check to see if we have a publication yet
266 const publicationCheck = await pdsPublicClient.xrpcSafe(com.atproto.repo.getRecord, {
267 params: {
268 repo: identifier,
269 collection: site.standard.publication.$nsid,
270 rkey: publicationTid,
271 },
272 })
273
274 if (publicationCheck.success) {
275 // We have a publication record
276 return
277 }
278
279 if (publicationCheck instanceof XrpcResponseError) {
280 //Means it's not been uploaded and we can do that now
281 if (publicationCheck.error === 'RecordNotFound') {
282 return {
283 tid: publicationTid,
284 record: site.standard.publication.$build({
285 name: 'npmx.dev',
286 url: 'https://npmx.dev',
287 description: 'a fast, modern browser for the npm registry',
288 preferences: {
289 showInDiscover: true,
290 },
291 }),
292 }
293 }
294 }
295 // Was another error and need to log it
296 console.error('[standard-site-sync]: Error syncing document', publicationCheck.error)
297 return
298}

Callers 1

setupFunction · 0.85

Calls 1

npmxPublicationRkeyFunction · 0.90

Tested by

no test coverage detected