Skip to content

Commit 2e801e4

Browse files
committed
chore: further conflict cleanup
1 parent c12dcd8 commit 2e801e4

3 files changed

Lines changed: 2 additions & 120 deletions

File tree

server/api/atproto/bluesky-oembed.get.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

shared/schemas/atproto.ts

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
import {
2-
boolean,
3-
minLength,
4-
nonEmpty,
5-
object,
6-
optional,
7-
picklist,
8-
pipe,
9-
regex,
10-
startsWith,
11-
string,
12-
url,
13-
} from 'valibot'
1+
import { boolean, object, optional, pipe, string, url } from 'valibot'
142
import type { InferOutput } from 'valibot'
15-
import { AT_URI_REGEX, BLUESKY_URL_REGEX, ERROR_BLUESKY_URL_FAILED } from '#shared/utils/constants'
163

174
/**
185
* INFO: Validates AT Protocol createSession response
@@ -29,45 +16,6 @@ export const PDSSessionSchema = object({
2916

3017
export type PDSSessionResponse = InferOutput<typeof PDSSessionSchema>
3118

32-
/**
33-
* INFO: Validates AT Protocol URI format (at://did:plc:.../app.bsky.feed.post/...)
34-
* Used for referencing Bluesky posts in our database and API routes.
35-
*/
36-
export const BlueSkyUriSchema = object({
37-
uri: pipe(
38-
string(),
39-
startsWith('at://'),
40-
minLength(10),
41-
regex(AT_URI_REGEX, 'Must be a valid at:// URI'),
42-
),
43-
})
44-
45-
export type BlueSkyUri = InferOutput<typeof BlueSkyUriSchema>
46-
47-
/**
48-
* INFO: Validates query parameters for Bluesky oEmbed generation.
49-
* - url: Must be a valid bsky.app profile post URL
50-
* - colorMode: Optional theme preference (defaults to 'system')
51-
*/
52-
export const BlueskyOEmbedRequestSchema = object({
53-
url: pipe(string(), nonEmpty(), regex(BLUESKY_URL_REGEX, ERROR_BLUESKY_URL_FAILED)),
54-
colorMode: optional(picklist(['system', 'dark', 'light']), 'system'),
55-
})
56-
57-
export type BlueskyOEmbedRequest = InferOutput<typeof BlueskyOEmbedRequestSchema>
58-
59-
/**
60-
* INFO: Explicit type generation for the response.
61-
*/
62-
export const BlueskyOEmbedResponseSchema = object({
63-
embedUrl: string(),
64-
did: string(),
65-
postId: string(),
66-
handle: string(),
67-
})
68-
69-
export type BlueskyOEmbedResponse = InferOutput<typeof BlueskyOEmbedResponseSchema>
70-
7119
export const BlogMetaRequestSchema = object({
7220
url: pipe(string(), url()),
7321
})

shared/utils/constants.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const CACHE_MAX_AGE_ONE_YEAR = 60 * 60 * 24 * 365
99

1010
// API Strings
1111
export const NPMX_SITE = 'https://npmx.dev'
12-
export const BLUESKY_EMBED_BASE_ROUTE = 'https://embed.bsky.app'
1312
export const BLUESKY_API = 'https://public.api.bsky.app/'
1413
export const BLUESKY_COMMENTS_REQUEST = '/api/atproto/bluesky-comments'
1514
export const NPM_REGISTRY = 'https://registry.npmjs.org'
@@ -18,9 +17,6 @@ export const ERROR_PACKAGE_ANALYSIS_FAILED = 'Failed to analyze package.'
1817
export const ERROR_PACKAGE_VERSION_AND_FILE_FAILED = 'Version and file path are required.'
1918
export const ERROR_PACKAGE_REQUIREMENTS_FAILED =
2019
'Package name, version, and file path are required.'
21-
export const ERROR_BLUESKY_URL_FAILED =
22-
'Invalid Bluesky URL format. Expected: https://bsky.app/profile/HANDLE/post/POST_ID'
23-
export const ERROR_BLUESKY_EMBED_FAILED = 'Failed to generate Bluesky embed.'
2420
export const ERROR_FILE_LIST_FETCH_FAILED = 'Failed to fetch file list.'
2521
export const ERROR_CALC_INSTALL_SIZE_FAILED = 'Failed to calculate install size.'
2622
export const NPM_MISSING_README_SENTINEL = 'ERROR: No README data found!'
@@ -77,10 +73,7 @@ export const BACKGROUND_THEMES = {
7773
black: 'oklch(0.4 0 0)',
7874
} as const
7975

80-
// Regex
81-
export const AT_URI_REGEX = /^at:\/\/(did:plc:[a-z0-9]+)\/app\.bsky\.feed\.post\/([a-z0-9]+)$/
82-
export const BLUESKY_URL_REGEX = /^https:\/\/bsky\.app\/profile\/[^/]+\/post\/[^/]+$/
83-
// INFO: For capture groups
76+
// INFO: Regex for capture groups
8477
export const BLUESKY_URL_EXTRACT_REGEX = /profile\/([^/]+)\/post\/([^/]+)/
8578
export const BSKY_POST_AT_URI_REGEX =
8679
/^at:\/\/(did:plc:[a-z0-9]+)\/app\.bsky\.feed\.post\/([a-z0-9]+)$/

0 commit comments

Comments
 (0)