this repo has no description
at main 62 lines 2.3 kB view raw
1import { At, ComAtprotoLabelDefs } from "@atcute/client/lexicons"; 2import type { WebsocketHandler } from "@fastify/websocket"; 3import type { 4 RawReplyDefaultExpression, 5 RawRequestDefaultExpression, 6 RawServerDefault, 7 RequestGenericInterface, 8 RouteGenericInterface, 9 RouteHandlerMethod, 10} from "fastify"; 11 12type NullishKeys<T> = { 13 [K in keyof T]: null extends T[K] ? K : undefined extends T[K] ? K : never; 14}[keyof T]; 15type NonNullishKeys<T> = Exclude<keyof T, NullishKeys<T>>; 16export type NonNullishPartial<T> = 17 & { [K in NullishKeys<T>]+?: Exclude<T[K], null | undefined> } 18 & { [K in NonNullishKeys<T>]-?: T[K] }; 19 20/** 21 * Data required to create a label. 22 */ 23export interface CreateLabelData { 24 /** The label value. */ 25 val: string; 26 /** The subject of the label. If labeling an account, this should be a string beginning with `did:`. */ 27 uri: string; 28 /** Optionally, a CID specifying the version of `uri` to label. */ 29 cid?: string | undefined; 30 /** Whether this label is negating a previous instance of this label applied to the same subject. */ 31 neg?: boolean | undefined; 32 /** The DID of the actor who created this label, if different from the labeler. */ 33 src?: string | undefined; 34 /** The creation date of the label. Must be in ISO 8601 format. */ 35 cts?: string | undefined; 36 /** The expiration date of the label, if any. Must be in ISO 8601 format. */ 37 exp?: string | undefined; 38} 39export type UnsignedLabel = Omit<ComAtprotoLabelDefs.Label, "sig">; 40export type SignedLabel = UnsignedLabel & { sig: Uint8Array }; 41export type FormattedLabel = UnsignedLabel & { sig?: At.Bytes }; 42export type SavedLabel = UnsignedLabel & { sig: ArrayBuffer; id: number }; 43 44export type QueryHandler< 45 T extends RouteGenericInterface["Querystring"] = RouteGenericInterface["Querystring"], 46> = RouteHandlerMethod< 47 RawServerDefault, 48 RawRequestDefaultExpression, 49 RawReplyDefaultExpression, 50 { Querystring: T } 51>; 52export type ProcedureHandler< 53 T extends RouteGenericInterface["Body"] = RouteGenericInterface["Body"], 54> = RouteHandlerMethod< 55 RawServerDefault, 56 RawRequestDefaultExpression, 57 RawReplyDefaultExpression, 58 { Body: T } 59>; 60export type SubscriptionHandler< 61 T extends RequestGenericInterface["Querystring"] = RequestGenericInterface["Querystring"], 62> = WebsocketHandler<RawServerDefault, RawRequestDefaultExpression, { Querystring: T }>;