(identifier: AtIdentifierString, pdsPublicClient: Client)
| 260 | * @returns |
| 261 | */ |
| 262 | const 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 | } |
no test coverage detected