2026-01-06 16:35:15 +01:00

165 lines
4.8 KiB
TypeScript

import type { Event } from 'nostr-tools'
export interface NostrProfile {
pubkey: string
name?: string
about?: string
picture?: string
nip05?: string
lud16?: string // Lightning address (user@domain.com)
lud06?: string // LNURL format
}
export type ArticleCategory = 'science-fiction' | 'scientific-research' | 'author-presentation'
export type KindType =
| 'article'
| 'series'
| 'review'
| 'purchase'
| 'review_tip'
| 'sponsoring'
export interface MediaRef {
url: string
type: 'image' | 'video'
}
export interface Page {
number: number // Page number (1-indexed)
type: 'markdown' | 'image'
content: string // Markdown content or image URL
}
export interface Article {
id: string // Format: <hash>_<index>_<version>
hash: string // SHA-256 hash of the object
version: number // Version number (0 by default)
index: number // Index for duplicates (0 by default)
pubkey: string
title: string
preview: string
content: string
description: string // Description of the content (required)
contentDescription: string // Description of the content type (required)
createdAt: number
zapAmount: number
paid: boolean
invoice?: string // BOLT11 invoice from event tags (if author created one)
paymentHash?: string // Payment hash from event tags
category?: ArticleCategory // Category of the article
isPresentation?: boolean // True if this is an author presentation article
mainnetAddress?: string // Bitcoin mainnet address for sponsoring (presentation articles only)
totalSponsoring?: number // Total sponsoring received in sats (presentation articles only)
authorPresentationId?: string // ID of the author's presentation article (for standard articles)
seriesId?: string // Series event id
bannerUrl?: string // NIP-95 banner (full size image)
thumbnailUrl: string // Thumbnail image URL (required)
media?: MediaRef[] // Embedded media (NIP-95)
pages?: Page[] // A5 pages (for series publications)
kindType?: KindType
}
export interface AuthorPresentationArticle extends Article {
category: 'author-presentation'
isPresentation: true
mainnetAddress: string
totalSponsoring: number
originalCategory?: 'science-fiction' | 'scientific-research' // Original category from tags for filtering
}
export interface Series {
id: string // Format: <hash>_<index>_<version>
hash: string // SHA-256 hash of the object
version: number // Version number (0 by default)
index: number // Index for duplicates (0 by default)
pubkey: string
title: string
description: string
preview: string
coverUrl?: string // Full size cover image
thumbnailUrl: string // Thumbnail image URL (required)
category: ArticleCategory
totalSponsoring?: number
totalPayments?: number
kindType?: KindType
}
export interface Review {
id: string // Format: <hash>_<index>_<version>
hash: string // SHA-256 hash of the object
version: number // Version number (0 by default)
index: number // Index for duplicates (0 by default)
articleId: string
authorPubkey: string
reviewerPubkey: string
content: string
description: string // Description of the review (required)
createdAt: number
title?: string
text?: string // Optional plain text message
rewarded?: boolean
rewardAmount?: number
kindType?: KindType
}
export interface ZapRequest {
event: Event
amount: number
targetPubkey: string
targetEventId?: string
}
export interface Purchase {
id: string // Format: <hash>_<index>_<version>
hash: string // SHA-256 hash of the object
version: number // Version number (0 by default)
index: number // Index for duplicates (0 by default)
payerPubkey: string
articleId: string
authorPubkey: string
amount: number // Amount in sats
paymentHash: string
createdAt: number
kindType?: KindType
}
export interface Sponsoring {
id: string // Format: <hash>_<index>_<version>
hash: string // SHA-256 hash of the object
version: number // Version number (0 by default)
index: number // Index for duplicates (0 by default)
payerPubkey: string
authorPubkey: string
amount: number // Amount in sats
paymentHash: string
seriesId?: string
articleId?: string
createdAt: number
text?: string // Optional plain text message
kindType?: KindType
}
export interface ReviewTip {
id: string // Format: <hash>_<index>_<version>
hash: string // SHA-256 hash of the object
version: number // Version number (0 by default)
index: number // Index for duplicates (0 by default)
payerPubkey: string
articleId: string
reviewId: string
reviewerPubkey: string
authorPubkey: string
amount: number // Amount in sats
paymentHash: string
createdAt: number
text?: string // Optional plain text message
kindType?: KindType
}
export interface NostrConnectState {
connected: boolean
pubkey: string | null
profile: NostrProfile | null
}