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'
142import 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
3017export 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-
7119export const BlogMetaRequestSchema = object ( {
7220 url : pipe ( string ( ) , url ( ) ) ,
7321} )
0 commit comments