Add docs for new stuff

This commit is contained in:
Jon Staab
2025-08-01 14:32:57 -07:00
parent 1f5f869f7c
commit c6434028a6
5 changed files with 200 additions and 0 deletions
+76
View File
@@ -0,0 +1,76 @@
# Commands
Commands are functions which pull from app state to publish events on behalf of the user. Most are async and return a thunk
## Relay Management (NIP 65)
```typescript
removeRelay(url: string, mode: RelayMode): Promise<Thunk>
addRelay(url: string, mode: RelayMode): Promise<Thunk>
```
## Inbox Relay Management (NIP 17)
```typescript
removeInboxRelay(url: string): Promise<Thunk>
addInboxRelay(url: string): Promise<Thunk>
```
## Profile Management (NIP 01)
```typescript
setProfile(profile: Profile): Thunk
```
## Follow Management (NIP 02)
```typescript
unfollow(value: string): Promise<Thunk>
follow(tag: string[]): Promise<Thunk>
```
## Mute Management
```typescript
unmute(value: string): Promise<Thunk>
mutePublicly(tag: string[]): Promise<Thunk>
mutePrivately(tag: string[]): Promise<Thunk>
setMutes(options: {
publicTags?: string[][]
privateTags?: string[][]
}): Promise<Thunk>
```
## Pin Management
```typescript
unpin(value: string): Promise<Thunk>
pin(tag: string[]): Promise<Thunk>
```
## Wrapped Messages (NIP 59)
```typescript
type SendWrappedOptions = Omit<ThunkOptions, "event" | "relays"> & {
template: EventTemplate
pubkeys: string[]
}
sendWrapped(options: SendWrappedOptions): Promise<MergedThunk>
```
## Relay Management (NIP 86)
```typescript
manageRelay(url: string, request: ManagementRequest): Promise<Response>
```
## Room Management (NIP 29)
```typescript
createRoom(url: string, room: RoomMeta): Thunk
deleteRoom(url: string, room: RoomMeta): Thunk
editRoom(url: string, room: RoomMeta): Thunk
joinRoom(url: string, room: RoomMeta): Thunk
leaveRoom(url: string, room: RoomMeta): Thunk
```
+107
View File
@@ -0,0 +1,107 @@
# User Data Loading
The User Data module provides utilities for loading and managing user-specific data like profiles, follows, mutes, pins, and relay selections. It includes both reactive stores and manual loading functions.
## Types
### UserDataLoader
```typescript
type UserDataLoader = (pubkey: string, relays?: string[], force?: boolean) => unknown
```
Function type for loading user data with optional relay specification and force refresh.
### MakeUserDataOptions
```typescript
type MakeUserDataOptions<T> = {
mapStore: Readable<Map<string, T>>
loadItem: UserDataLoader
}
```
Configuration for creating user data stores.
## User Data Stores
These reactive stores automatically load and cache user data:
```typescript
// User profile
export const userProfile: Store<Profile | undefined>
// User follows list
export const userFollows: Store<List | undefined>
// User mutes list
export const userMutes: Store<List | undefined>
// User pins list
export const userPins: Store<List | undefined>
// User relay selections
export const userRelaySelections: Store<List | undefined>
// User inbox relay selections
export const userInboxRelaySelections: Store<List | undefined>
// User blossom servers
export const userBlossomServers: Store<List | undefined>
```
## Manual Loading Functions
These functions allow manual loading of user data with optional relay specification and force refresh:
```typescript
// Load user profile
function loadUserProfile(relays?: string[], force?: boolean): Promise<void>
// Load user follows
function loadUserFollows(relays?: string[], force?: boolean): Promise<void>
// Load user mutes
function loadUserMutes(relays?: string[], force?: boolean): Promise<void>
// Load user pins
function loadUserPins(relays?: string[], force?: boolean): Promise<void>
// Load user relay selections
function loadUserRelaySelections(relays?: string[], force?: boolean): Promise<void>
// Load user inbox relay selections
function loadUserInboxRelaySelections(relays?: string[], force?: boolean): Promise<void>
// Load user blossom servers
function loadUserBlossomServers(relays?: string[], force?: boolean): Promise<void>
```
## Usage Examples
### Using Reactive Stores
```typescript
import { userProfile, userFollows } from '@welshman/app'
// Subscribe to user profile changes
userProfile.subscribe(profile => {
if (profile) {
console.log('User profile:', profile)
}
})
// Get current follows list
const follows = userFollows.get()
```
### Manual Loading
```typescript
import { loadUserMutes, loadUserRelaySelections } from '@welshman/app'
// Load user mutes from specific relays
await loadUserMutes(['wss://relay1.com', 'wss://relay2.com'])
// Force refresh user relay selections
await loadUserRelaySelections([], true)
// Load from default relays
await loadUserProfile()
```