[Clipclops] Add screen to view and send clip clops (#3754)
* add new routes with placeholder screens * add clops list * add a clop input * add some better padding to the clops * some more adjustments * add rnkc * implement rnkc * implement rnkc * be a little less weird about it * rename clop stuff * rename more clop * one more * [Clipclops] Temp codegenerated lexicon (#3749) * add codegenerated lexicon * replace hailey's types * use codegen'd types in components * fix error + throw if fetch failed * remove bad imports * update messageslist and messageitem * import useState * add clop service URL hook * add dm service url storage * use context * use context for service url (temp) * remove log * nits --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
@@ -0,0 +1,195 @@
|
||||
import {
|
||||
AppBskyActorDefs,
|
||||
AppBskyEmbedRecord,
|
||||
AppBskyRichtextFacet,
|
||||
} from '@atproto/api'
|
||||
import {ValidationResult} from '@atproto/lexicon'
|
||||
|
||||
export interface Message {
|
||||
id?: string
|
||||
text: string
|
||||
/** Annotations of text (mentions, URLs, hashtags, etc) */
|
||||
facets?: AppBskyRichtextFacet.Main[]
|
||||
embed?: AppBskyEmbedRecord.Main | {$type: string; [k: string]: unknown}
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isMessage(v: unknown): v is Message {
|
||||
return isObj(v) && hasProp(v, '$type') && v.$type === 'temp.dm.defs#message'
|
||||
}
|
||||
|
||||
export function validateMessage(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export interface MessageView {
|
||||
id: string
|
||||
rev: string
|
||||
text: string
|
||||
/** Annotations of text (mentions, URLs, hashtags, etc) */
|
||||
facets?: AppBskyRichtextFacet.Main[]
|
||||
embed?: AppBskyEmbedRecord.Main | {$type: string; [k: string]: unknown}
|
||||
sender?: MessageViewSender
|
||||
sentAt: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isMessageView(v: unknown): v is MessageView {
|
||||
return (
|
||||
isObj(v) && hasProp(v, '$type') && v.$type === 'temp.dm.defs#messageView'
|
||||
)
|
||||
}
|
||||
|
||||
export function validateMessageView(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export interface DeletedMessage {
|
||||
id: string
|
||||
rev?: string
|
||||
sender?: MessageViewSender
|
||||
sentAt: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isDeletedMessage(v: unknown): v is DeletedMessage {
|
||||
return (
|
||||
isObj(v) && hasProp(v, '$type') && v.$type === 'temp.dm.defs#deletedMessage'
|
||||
)
|
||||
}
|
||||
|
||||
export function validateDeletedMessage(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export interface MessageViewSender {
|
||||
did: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isMessageViewSender(v: unknown): v is MessageViewSender {
|
||||
return (
|
||||
isObj(v) &&
|
||||
hasProp(v, '$type') &&
|
||||
v.$type === 'temp.dm.defs#messageViewSender'
|
||||
)
|
||||
}
|
||||
|
||||
export function validateMessageViewSender(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export interface ChatView {
|
||||
id: string
|
||||
rev: string
|
||||
members: AppBskyActorDefs.ProfileViewBasic[]
|
||||
lastMessage?:
|
||||
| MessageView
|
||||
| DeletedMessage
|
||||
| {$type: string; [k: string]: unknown}
|
||||
unreadCount: number
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isChatView(v: unknown): v is ChatView {
|
||||
return isObj(v) && hasProp(v, '$type') && v.$type === 'temp.dm.defs#chatView'
|
||||
}
|
||||
|
||||
export function validateChatView(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export type IncomingMessageSetting =
|
||||
| 'all'
|
||||
| 'none'
|
||||
| 'following'
|
||||
| (string & {})
|
||||
|
||||
export interface LogBeginChat {
|
||||
rev: string
|
||||
chatId: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isLogBeginChat(v: unknown): v is LogBeginChat {
|
||||
return (
|
||||
isObj(v) && hasProp(v, '$type') && v.$type === 'temp.dm.defs#logBeginChat'
|
||||
)
|
||||
}
|
||||
|
||||
export function validateLogBeginChat(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export interface LogCreateMessage {
|
||||
rev: string
|
||||
chatId: string
|
||||
message: MessageView | DeletedMessage | {$type: string; [k: string]: unknown}
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isLogCreateMessage(v: unknown): v is LogCreateMessage {
|
||||
return (
|
||||
isObj(v) &&
|
||||
hasProp(v, '$type') &&
|
||||
v.$type === 'temp.dm.defs#logCreateMessage'
|
||||
)
|
||||
}
|
||||
|
||||
export function validateLogCreateMessage(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export interface LogDeleteMessage {
|
||||
rev: string
|
||||
chatId: string
|
||||
message: MessageView | DeletedMessage | {$type: string; [k: string]: unknown}
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isLogDeleteMessage(v: unknown): v is LogDeleteMessage {
|
||||
return (
|
||||
isObj(v) &&
|
||||
hasProp(v, '$type') &&
|
||||
v.$type === 'temp.dm.defs#logDeleteMessage'
|
||||
)
|
||||
}
|
||||
|
||||
export function validateLogDeleteMessage(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export function isObj(v: unknown): v is Record<string, unknown> {
|
||||
return typeof v === 'object' && v !== null
|
||||
}
|
||||
|
||||
export function hasProp<K extends PropertyKey>(
|
||||
data: object,
|
||||
prop: K,
|
||||
): data is Record<K, unknown> {
|
||||
return prop in data
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export interface InputSchema {
|
||||
chatId: string
|
||||
messageId: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export type OutputSchema = TempDmDefs.DeletedMessage
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
qp?: QueryParams
|
||||
encoding: 'application/json'
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {
|
||||
chatId: string
|
||||
}
|
||||
|
||||
export type InputSchema = undefined
|
||||
|
||||
export interface OutputSchema {
|
||||
chat: TempDmDefs.ChatView
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {
|
||||
members: string[]
|
||||
}
|
||||
|
||||
export type InputSchema = undefined
|
||||
|
||||
export interface OutputSchema {
|
||||
chat: TempDmDefs.ChatView
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {
|
||||
cursor?: string
|
||||
}
|
||||
|
||||
export type InputSchema = undefined
|
||||
|
||||
export interface OutputSchema {
|
||||
cursor?: string
|
||||
logs: (
|
||||
| TempDmDefs.LogBeginChat
|
||||
| TempDmDefs.LogCreateMessage
|
||||
| TempDmDefs.LogDeleteMessage
|
||||
| {$type: string; [k: string]: unknown}
|
||||
)[]
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {
|
||||
chatId: string
|
||||
limit?: number
|
||||
cursor?: string
|
||||
}
|
||||
|
||||
export type InputSchema = undefined
|
||||
|
||||
export interface OutputSchema {
|
||||
cursor?: string
|
||||
messages: (
|
||||
| TempDmDefs.MessageView
|
||||
| TempDmDefs.DeletedMessage
|
||||
| {$type: string; [k: string]: unknown}
|
||||
)[]
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export type InputSchema = undefined
|
||||
|
||||
export interface OutputSchema {
|
||||
allowIncoming: TempDmDefs.IncomingMessageSetting
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export interface InputSchema {
|
||||
chatId: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface OutputSchema {
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
qp?: QueryParams
|
||||
encoding: 'application/json'
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {
|
||||
limit?: number
|
||||
cursor?: string
|
||||
}
|
||||
|
||||
export type InputSchema = undefined
|
||||
|
||||
export interface OutputSchema {
|
||||
cursor?: string
|
||||
chats: TempDmDefs.ChatView[]
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export interface InputSchema {
|
||||
chatId: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface OutputSchema {
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
qp?: QueryParams
|
||||
encoding: 'application/json'
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export interface InputSchema {
|
||||
chatId: string
|
||||
message: TempDmDefs.Message
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export type OutputSchema = TempDmDefs.MessageView
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
qp?: QueryParams
|
||||
encoding: 'application/json'
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import {ValidationResult} from '@atproto/lexicon'
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export interface InputSchema {
|
||||
items: BatchItem[]
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface OutputSchema {
|
||||
items: TempDmDefs.MessageView[]
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
qp?: QueryParams
|
||||
encoding: 'application/json'
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
export interface BatchItem {
|
||||
chatId: string
|
||||
message: TempDmDefs.Message
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export function isBatchItem(v: unknown): v is BatchItem {
|
||||
return (
|
||||
isObj(v) &&
|
||||
hasProp(v, '$type') &&
|
||||
v.$type === 'temp.dm.sendMessageBatch#batchItem'
|
||||
)
|
||||
}
|
||||
|
||||
export function validateBatchItem(v: unknown): ValidationResult {
|
||||
return {
|
||||
success: true,
|
||||
value: v,
|
||||
}
|
||||
}
|
||||
|
||||
export function isObj(v: unknown): v is Record<string, unknown> {
|
||||
return typeof v === 'object' && v !== null
|
||||
}
|
||||
|
||||
export function hasProp<K extends PropertyKey>(
|
||||
data: object,
|
||||
prop: K,
|
||||
): data is Record<K, unknown> {
|
||||
return prop in data
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export interface InputSchema {
|
||||
chatId: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface OutputSchema {
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
qp?: QueryParams
|
||||
encoding: 'application/json'
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export interface InputSchema {
|
||||
chatId: string
|
||||
messageId?: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export type OutputSchema = TempDmDefs.ChatView
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
qp?: QueryParams
|
||||
encoding: 'application/json'
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import {Headers, XRPCError} from '@atproto/xrpc'
|
||||
|
||||
import * as TempDmDefs from './defs'
|
||||
|
||||
export interface QueryParams {}
|
||||
|
||||
export interface InputSchema {
|
||||
allowIncoming?: TempDmDefs.IncomingMessageSetting
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface OutputSchema {
|
||||
allowIncoming: TempDmDefs.IncomingMessageSetting
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
headers?: Headers
|
||||
qp?: QueryParams
|
||||
encoding: 'application/json'
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
success: boolean
|
||||
headers: Headers
|
||||
data: OutputSchema
|
||||
}
|
||||
|
||||
export function toKnownErr(e: any) {
|
||||
if (e instanceof XRPCError) {
|
||||
}
|
||||
return e
|
||||
}
|
||||
Reference in New Issue
Block a user