Init commit

This commit is contained in:
ShreejitPanchal
2026-05-19 19:56:02 +08:00
commit 6601501eff
4047 changed files with 2185372 additions and 0 deletions

View File

@@ -0,0 +1,164 @@
import { ActivityPubActor } from './activitypub-actor.js'
import { ActivityPubSignature } from './activitypub-signature.js'
import {
ActivityFlagReasonObject,
ActivityObject,
APObjectId,
CacheFileObject,
PlayerSettingsObject,
PlaylistObject,
VideoCommentObject,
VideoObject,
WatchActionObject
} from './objects/index.js'
export type ActivityUpdateObject =
| Extract<ActivityObject, VideoObject | CacheFileObject | PlaylistObject | ActivityPubActor | PlayerSettingsObject | string>
| ActivityPubActor
// Cannot Extract from Activity because of circular reference
export type ActivityUndoObject =
| ActivityFollow
| ActivityLike
| ActivityDislike
| ActivityCreate<CacheFileObject | string>
| ActivityAnnounce
export type ActivityCreateObject = Extract<
ActivityObject,
VideoObject | CacheFileObject | WatchActionObject | VideoCommentObject | PlaylistObject | string
>
export type Activity =
| ActivityCreate<ActivityCreateObject>
| ActivityUpdate<ActivityUpdateObject>
| ActivityDelete
| ActivityFollow
| ActivityAccept
| ActivityAnnounce
| ActivityUndo<ActivityUndoObject>
| ActivityLike
| ActivityReject
| ActivityView
| ActivityDislike
| ActivityFlag
| ActivityApproveReply
| ActivityRejectReply
export type ActivityType =
| 'Create'
| 'Update'
| 'Delete'
| 'Follow'
| 'Accept'
| 'Announce'
| 'Undo'
| 'Like'
| 'Reject'
| 'View'
| 'Dislike'
| 'Flag'
| 'ApproveReply'
| 'RejectReply'
export interface ActivityAudience {
to: string[]
cc: string[]
}
export interface BaseActivity {
'@context'?: any[]
id: string
to?: string[] | string
cc?: string[] | string
actor: string | ActivityPubActor
type: ActivityType
signature?: ActivityPubSignature
}
export interface ActivityCreate<T extends ActivityCreateObject> extends BaseActivity {
type: 'Create'
object: T
}
export interface ActivityUpdate<T extends ActivityUpdateObject> extends BaseActivity {
type: 'Update'
object: T
}
export interface ActivityDelete extends BaseActivity {
type: 'Delete'
object: APObjectId
}
export interface ActivityFollow extends BaseActivity {
type: 'Follow'
object: string
}
export interface ActivityAccept extends BaseActivity {
type: 'Accept'
object: ActivityFollow
}
export interface ActivityApproveReply extends BaseActivity {
type: 'ApproveReply'
object: string
inReplyTo: string
}
export interface ActivityRejectReply extends BaseActivity {
type: 'RejectReply'
object: string
inReplyTo: string
}
export interface ActivityReject extends BaseActivity {
type: 'Reject'
object: ActivityFollow
}
export interface ActivityAnnounce extends BaseActivity {
type: 'Announce'
object: APObjectId
}
export interface ActivityUndo<T extends ActivityUndoObject> extends BaseActivity {
type: 'Undo'
object: T
}
export interface ActivityLike extends BaseActivity {
type: 'Like'
object: APObjectId
}
export interface ActivityView extends BaseActivity {
type: 'View'
actor: string
object: APObjectId
// If sending a "viewer" event
expires?: string
result?: {
type: 'InteractionCounter'
interactionType: 'WatchAction'
userInteractionCount: number
}
}
export interface ActivityDislike extends BaseActivity {
id: string
type: 'Dislike'
actor: string
object: APObjectId
}
export interface ActivityFlag extends BaseActivity {
type: 'Flag'
content: string
object: APObjectId | APObjectId[]
tag?: ActivityFlagReasonObject[]
startAt?: number
endAt?: number
}

View File

@@ -0,0 +1,44 @@
import { ActivityIconObject, ActivityPubAttributedTo, ActivityUrlObject } from './objects/common-objects.js'
export type ActivityPubActorType = 'Person' | 'Application' | 'Group' | 'Service' | 'Organization'
export interface ActivityPubActor {
'@context': any[]
type: ActivityPubActorType
id: string
following: string
followers: string
playlists?: string
inbox: string
outbox: string
preferredUsername: string
url: ActivityUrlObject[]
name: string
endpoints: {
sharedInbox: string
}
summary: string
attributedTo?: ActivityPubAttributedTo[]
support?: string
publicKey: {
id: string
owner: string
publicKeyPem: string
}
// Lemmy attribute for groups
postingRestrictedToMods?: boolean
image?: ActivityIconObject | ActivityIconObject[]
icon?: ActivityIconObject | ActivityIconObject[]
published?: string
// Used by the user export feature
likes?: string
dislikes?: string
// On channels only
playerSettings?: string
}

View File

@@ -0,0 +1,9 @@
import { Activity } from './activity.js'
export interface ActivityPubCollection {
'@context': any[]
type: 'Collection' | 'CollectionPage'
totalItems: number
partOf?: string
items: Activity[]
}

View File

@@ -0,0 +1,12 @@
export interface ActivityPubOrderedCollection<T> {
id: string
'@context': any[]
type: 'OrderedCollection' | 'OrderedCollectionPage'
totalItems: number
orderedItems: T[]
partOf?: string
next?: string
first?: string
}

View File

@@ -0,0 +1,5 @@
import { Activity } from './activity.js'
import { ActivityPubCollection } from './activitypub-collection.js'
import { ActivityPubOrderedCollection } from './activitypub-ordered-collection.js'
export type RootActivity = Activity | ActivityPubCollection | ActivityPubOrderedCollection<Activity>

View File

@@ -0,0 +1,6 @@
export interface ActivityPubSignature {
type: string
created: Date
creator: string
signatureValue: string
}

View File

@@ -0,0 +1,20 @@
export type ContextType =
| 'Video'
| 'Comment'
| 'Playlist'
| 'Follow'
| 'Reject'
| 'Accept'
| 'View'
| 'Announce'
| 'CacheFile'
| 'Delete'
| 'Rate'
| 'Flag'
| 'Actor'
| 'Collection'
| 'WatchAction'
| 'Chapters'
| 'ApproveReply'
| 'RejectReply'
| 'PlayerSettings'

View File

@@ -0,0 +1,9 @@
export * from './objects/index.js'
export * from './activity.js'
export * from './activitypub-actor.js'
export * from './activitypub-collection.js'
export * from './activitypub-ordered-collection.js'
export * from './activitypub-root.js'
export * from './activitypub-signature.js'
export * from './context.js'
export * from './webfinger.js'

View File

@@ -0,0 +1,15 @@
import { ActivityFlagReasonObject } from './common-objects.js'
export interface AbuseObject {
type: 'Flag'
content: string
mediaType: 'text/markdown'
object: string | string[]
tag?: ActivityFlagReasonObject[]
startAt?: number
endAt?: number
}

View File

@@ -0,0 +1,19 @@
import { AbuseObject } from './abuse-object.js'
import { CacheFileObject } from './cache-file-object.js'
import { PlayerSettingsObject } from './player-settings-object.js'
import { PlaylistObject } from './playlist-object.js'
import { VideoCommentObject } from './video-comment-object.js'
import { VideoObject } from './video-object.js'
import { WatchActionObject } from './watch-action-object.js'
export type ActivityObject =
| VideoObject
| AbuseObject
| VideoCommentObject
| CacheFileObject
| PlaylistObject
| WatchActionObject
| PlayerSettingsObject
| string
export type APObjectId = string | { id: string }

View File

@@ -0,0 +1,9 @@
import { ActivityPlaylistUrlObject } from './common-objects.js'
export interface CacheFileObject {
id: string
type: 'CacheFile'
object: string
expires: string
url: ActivityPlaylistUrlObject
}

View File

@@ -0,0 +1,165 @@
import { AbusePredefinedReasonsString } from '../../moderation/abuse/abuse-reason.model.js'
import { NSFWFlagString } from '../../videos/nsfw-flag.enum.js'
export interface ActivityIdentifierObject {
identifier: string
name: string
}
export interface ActivityIconObject {
type: 'Image'
url: string
mediaType: string
width: number
height: number | null
}
// ---------------------------------------------------------------------------
export type ActivityVideoUrlObjectAttachment = {
type: 'PropertyValue'
name: 'ffprobe_codec_type'
value: 'video' | 'audio'
} | {
type: 'PropertyValue'
name: 'peertube_format_flag'
value: 'web-video' | 'fragmented'
}
export type ActivityVideoUrlObject = {
type: 'Link'
mediaType: 'video/mp4' | 'video/webm' | 'video/ogg' | 'audio/mp4'
href: string
height: number
width: number | null
size: number
fps: number
attachment: ActivityVideoUrlObjectAttachment[]
}
// ---------------------------------------------------------------------------
export type ActivityPlaylistSegmentHashesObject = {
type: 'Link'
name: 'sha256'
mediaType: 'application/json'
href: string
}
export type ActivityVideoFileMetadataUrlObject = {
type: 'Link'
rel: ['metadata', any]
mediaType: 'application/json'
height: number
width: number | null
href: string
fps: number
}
export type ActivityCaptionUrlObject = {
type: 'Link'
mediaType: 'text/vtt'
href: string
}
export type ActivityTrackerUrlObject = {
type: 'Link'
rel: ['tracker', 'websocket' | 'http']
name: string
href: string
}
export type ActivityStreamingPlaylistInfohashesObject = {
type: 'Infohash'
name: string
}
export type ActivityPlaylistUrlObject = {
type: 'Link'
mediaType: 'application/x-mpegURL'
href: string
tag?: ActivityTagObject[]
}
export type ActivityBitTorrentUrlObject = {
type: 'Link'
mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
href: string
height: number
width: number | null
fps: number | null
}
export type ActivityMagnetUrlObject = {
type: 'Link'
mediaType: 'application/x-bittorrent;x-scheme-handler/magnet'
href: string
height: number
width: number | null
fps: number | null
}
export type ActivityHtmlUrlObject = {
type: 'Link'
mediaType: 'text/html'
href: string
}
export interface ActivityHashTagObject {
type: 'Hashtag'
href?: string
name: string
}
export interface ActivityMentionObject {
type: 'Mention'
href?: string
name: string
}
export interface ActivityFlagReasonObject {
type: 'Hashtag'
name: AbusePredefinedReasonsString
}
export interface ActivitySensitiveTagObject {
type: 'SensitiveTag'
name: NSFWFlagString
}
export type ActivityTagObject =
| ActivityPlaylistSegmentHashesObject
| ActivityStreamingPlaylistInfohashesObject
| ActivityVideoUrlObject
| ActivityHashTagObject
| ActivitySensitiveTagObject
| ActivityMentionObject
| ActivityBitTorrentUrlObject
| ActivityMagnetUrlObject
| ActivityVideoFileMetadataUrlObject
export type ActivityUrlObject =
| ActivityVideoUrlObject
| ActivityPlaylistUrlObject
| ActivityBitTorrentUrlObject
| ActivityMagnetUrlObject
| ActivityHtmlUrlObject
| ActivityVideoFileMetadataUrlObject
| ActivityTrackerUrlObject
| ActivityCaptionUrlObject
export type ActivityPubAttributedTo = { type: 'Group' | 'Person', id: string } | string
export interface ActivityTombstoneObject {
'@context'?: any
id: string
url?: string
type: 'Tombstone'
name?: string
formerType?: string
inReplyTo?: string
published: string
updated: string
deleted: string
}

View File

@@ -0,0 +1,12 @@
export * from './abuse-object.js'
export * from './activitypub-object.js'
export * from './cache-file-object.js'
export * from './common-objects.js'
export * from './playlist-element-object.js'
export * from './playlist-object.js'
export * from './video-caption-object.js'
export * from './video-chapters-object.js'
export * from './video-comment-object.js'
export * from './video-object.js'
export * from './player-settings-object.js'
export * from './watch-action-object.js'

View File

@@ -0,0 +1,8 @@
import { PlayerThemeChannelSetting, PlayerThemeVideoSetting } from '../../player/player-theme.type.js'
export interface PlayerSettingsObject {
type: 'PlayerSettings'
id: string
object: string
theme: PlayerThemeVideoSetting | PlayerThemeChannelSetting
}

View File

@@ -0,0 +1,10 @@
export interface PlaylistElementObject {
id: string
type: 'PlaylistElement'
url: string
position: number
startTimestamp?: number
stopTimestamp?: number
}

View File

@@ -0,0 +1,31 @@
import { ActivityIconObject, ActivityPubAttributedTo } from './common-objects.js'
export interface PlaylistObject {
id: string
type: 'Playlist'
name: string
content: string
mediaType: 'text/markdown'
uuid: string
totalItems: number
attributedTo: ActivityPubAttributedTo[]
icon?: ActivityIconObject
published: string
updated: string
videoChannelPosition: number
orderedItems?: string[]
partOf?: string
next?: string
first?: string
to?: string[]
}

View File

@@ -0,0 +1,7 @@
import { ActivityCaptionUrlObject, ActivityIdentifierObject, ActivityPlaylistUrlObject } from './common-objects.js'
export interface VideoCaptionObject extends ActivityIdentifierObject {
automaticallyGenerated: boolean
url: (ActivityCaptionUrlObject | ActivityPlaylistUrlObject)[]
}

View File

@@ -0,0 +1,11 @@
export interface VideoChaptersObject {
id: string
hasPart: VideoChapterObject[]
}
// Same as https://schema.org/hasPart
export interface VideoChapterObject {
name: string
startOffset: number
endOffset: number
}

View File

@@ -0,0 +1,21 @@
import { ActivityPubAttributedTo, ActivityTagObject } from './common-objects.js'
export interface VideoCommentObject {
type: 'Note'
id: string
content: string
mediaType: 'text/markdown'
inReplyTo: string
published: string
updated: string
url: string
attributedTo: ActivityPubAttributedTo
tag: ActivityTagObject[]
replyApproval: string | null
to?: string[]
cc?: string[]
}

View File

@@ -0,0 +1,98 @@
import { LiveVideoLatencyModeType, VideoCommentPolicyType, VideoStateType } from '../../videos/index.js'
import {
ActivityIconObject,
ActivityIdentifierObject,
ActivityPubAttributedTo,
ActivityTagObject,
ActivityUrlObject
} from './common-objects.js'
import { VideoCaptionObject } from './video-caption-object.js'
import { VideoChapterObject } from './video-chapters-object.js'
export interface VideoObject {
type: 'Video'
id: string
name: string
duration: string
uuid: string
tag: ActivityTagObject[]
category: ActivityIdentifierObject
licence: ActivityIdentifierObject
language: ActivityIdentifierObject
subtitleLanguage: VideoCaptionObject[]
views: number
sensitive: boolean
summary: string
isLiveBroadcast: boolean
liveSaveReplay: boolean
permanentLive: boolean
latencyMode: LiveVideoLatencyModeType
commentsPolicy: VideoCommentPolicyType
canReply: 'as:Public' | 'https://www.w3.org/ns/activitystreams#Public'
downloadEnabled: boolean
waitTranscoding: boolean
state: VideoStateType
published: string
originallyPublishedAt: string
updated: string
uploadDate: string
schedules?: {
startDate: Date
}[]
mediaType: 'text/markdown'
content: string
support: string
aspectRatio: number
icon: ActivityIconObject[]
url: ActivityUrlObject[]
likes: string
dislikes: string
shares: string
comments: string
hasParts: string | VideoChapterObject[]
playerSettings: string
attributedTo: ActivityPubAttributedTo[]
preview?: ActivityPubStoryboard[]
to?: string[]
cc?: string[]
// For export
attachment?: {
type: 'Video'
url: string
mediaType: string
height: number
size: number
fps: number
}[]
}
export interface ActivityPubStoryboard {
type: 'Image'
rel: ['storyboard']
url: {
href: string
mediaType: string
width: number
height: number
tileWidth: number
tileHeight: number
tileDuration: string
}[]
}

View File

@@ -0,0 +1,23 @@
export interface WatchActionObject {
id: string
type: 'WatchAction'
startTime: string
endTime: string
location?: {
addressCountry: string
addressRegion: string
}
uuid: string
object: string
actionStatus: 'CompletedActionStatus'
duration: string
watchSections: {
startTimestamp: number
endTimestamp: number
}[]
}

View File

@@ -0,0 +1,9 @@
export interface WebFingerData {
subject: string
aliases: string[]
links: {
rel: 'self'
type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
href: string
}[]
}