Import Instagram archive to a Bluesky account
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refactor Bluesky types into modular structure

- Split Bluesky-related types into separate files under `src/bluesky/types/`
- Create index files for easier module exports
- Reorganize imports in `bluesky.ts` to use new type structure
- Add index files for other modules to improve import consistency

+121 -101
+8 -100
src/bluesky/bluesky.ts
··· 2 2 AtpAgent, 3 3 RichText, 4 4 BlobRef, 5 - AppBskyFeedPost, 6 - AppBskyEmbedDefs, 7 - AppBskyRichtextFacet, 8 5 AppBskyEmbedVideo, 9 6 AppBskyEmbedImages, 10 7 } from "@atproto/api"; 11 - import { logger } from "../logger/logger"; 12 8 13 - export interface VideoEmbed extends AppBskyEmbedVideo.Main { 14 - $type: "app.bsky.embed.video"; 15 - buffer: Buffer; 16 - mimeType: string; 17 - video: BlobRef; 18 - size?: number; 19 - captions?: AppBskyEmbedVideo.Caption[]; 20 - /** Alt text description of the video, for accessibility. */ 21 - alt?: string; 22 - aspectRatio?: AppBskyEmbedDefs.AspectRatio; 23 - } 24 - 25 - export interface ImageEmbed extends AppBskyEmbedImages.Image { 26 - $type: "app.bsky.embed.images#image"; 27 - alt: string; 28 - image: BlobRef; 29 - mimeType: string; 30 - // Remove Buffer and Blob - we'll convert during upload 31 - uploadData?: Buffer | Blob; 32 - } 33 - 34 - export class ImageEmbedImpl implements ImageEmbed { 35 - readonly $type = "app.bsky.embed.images#image"; 36 - [k: string]: unknown; 37 - 38 - constructor( 39 - public alt: string, 40 - public image: BlobRef, 41 - public mimeType: string, 42 - public uploadData?: Buffer | Blob 43 - ) {} 44 - 45 - toJSON() { 46 - return { 47 - $type: this.$type, 48 - alt: this.alt, 49 - image: this.image, 50 - }; 51 - } 52 - } 53 - 54 - export interface ImagesEmbed extends AppBskyEmbedImages.Main { 55 - $type: "app.bsky.embed.images"; 56 - images: ImageEmbed[]; 57 - } 58 - 59 - type EmbeddedMedia = VideoEmbed | ImagesEmbed; 60 - 61 - export class VideoEmbedImpl implements VideoEmbed { 62 - readonly $type = "app.bsky.embed.video"; 63 - [k: string]: unknown; 64 - 65 - constructor( 66 - public alt: string | undefined, 67 - public buffer: Buffer, 68 - public mimeType: string, 69 - public size: number | undefined, 70 - public video: BlobRef, 71 - public aspectRatio?: AppBskyEmbedDefs.AspectRatio, 72 - public captions?: AppBskyEmbedVideo.Caption[] 73 - ) {} 74 - 75 - toJSON() { 76 - return { 77 - $type: this.$type, 78 - alt: this.alt, 79 - buffer: "[Buffer length=" + this.buffer.length + "]", 80 - mimeType: this.mimeType, 81 - size: this.size, 82 - video: this.video, 83 - }; 84 - } 85 - } 86 - 87 - export class ImagesEmbedImpl implements ImagesEmbed { 88 - readonly $type = "app.bsky.embed.images"; 89 - [k: string]: unknown; 9 + import { logger } from "../logger/logger"; 90 10 91 - constructor(public images: ImageEmbed[]) {} 92 - } 93 - 94 - export interface PostRecord extends Partial<AppBskyFeedPost.Record> {} 11 + import { 12 + ImageEmbed, 13 + EmbeddedMedia, 14 + ImageEmbedImpl, 15 + VideoEmbedImpl, 16 + ImagesEmbedImpl 17 + } from "./types"; 95 18 96 - /** 97 - * Simple bluesky record. 98 - * @see AppBskyFeedPost.Record 99 - */ 100 - export class PostRecordImpl implements PostRecord { 101 - readonly $type = "app.bsky.feed.post"; 102 - [k: string]: unknown; 103 - 104 - constructor( 105 - public text: string, 106 - public createdAt: string, 107 - public facets: AppBskyRichtextFacet.Main[], 108 - public embed: EmbeddedMedia 109 - ) {} 110 - } 111 19 112 20 export class BlueskyClient { 113 21 private readonly agent: AtpAgent;
+2
src/bluesky/index.ts
··· 1 + export * from './types'; 2 + export * from './bluesky';
+4
src/bluesky/types/EmbeddedMedia.ts
··· 1 + import { VideoEmbed } from "./VideoEmbed"; 2 + import { ImagesEmbed } from "./ImagesEmbed"; 3 + 4 + export type EmbeddedMedia = VideoEmbed | ImagesEmbed;
+29
src/bluesky/types/ImageEmbed.ts
··· 1 + import { AppBskyEmbedImages, BlobRef } from "@atproto/api"; 2 + 3 + export interface ImageEmbed extends AppBskyEmbedImages.Image { 4 + $type: "app.bsky.embed.images#image"; 5 + alt: string; 6 + image: BlobRef; 7 + mimeType: string; 8 + uploadData?: Buffer | Blob; 9 + } 10 + 11 + export class ImageEmbedImpl implements ImageEmbed { 12 + readonly $type = "app.bsky.embed.images#image"; 13 + [k: string]: unknown; 14 + 15 + constructor( 16 + public alt: string, 17 + public image: BlobRef, 18 + public mimeType: string, 19 + public uploadData?: Buffer | Blob 20 + ) {} 21 + 22 + toJSON() { 23 + return { 24 + $type: this.$type, 25 + alt: this.alt, 26 + image: this.image, 27 + }; 28 + } 29 + }
+14
src/bluesky/types/ImagesEmbed.ts
··· 1 + import { AppBskyEmbedImages } from "@atproto/api"; 2 + import { ImageEmbed } from "./ImageEmbed"; 3 + 4 + export interface ImagesEmbed extends AppBskyEmbedImages.Main { 5 + $type: "app.bsky.embed.images"; 6 + images: ImageEmbed[]; 7 + } 8 + 9 + export class ImagesEmbedImpl implements ImagesEmbed { 10 + readonly $type = "app.bsky.embed.images"; 11 + [k: string]: unknown; 12 + 13 + constructor(public images: ImageEmbed[]) {} 14 + }
+16
src/bluesky/types/PostRecord.ts
··· 1 + import { AppBskyFeedPost, AppBskyRichtextFacet } from "@atproto/api"; 2 + import { EmbeddedMedia } from "./EmbeddedMedia"; 3 + 4 + export interface PostRecord extends Partial<AppBskyFeedPost.Record> {} 5 + 6 + export class PostRecordImpl implements PostRecord { 7 + readonly $type = "app.bsky.feed.post"; 8 + [k: string]: unknown; 9 + 10 + constructor( 11 + public text: string, 12 + public createdAt: string, 13 + public facets: AppBskyRichtextFacet.Main[], 14 + public embed: EmbeddedMedia 15 + ) {} 16 + }
+38
src/bluesky/types/VideoEmbed.ts
··· 1 + import { AppBskyEmbedVideo, AppBskyEmbedDefs, BlobRef } from "@atproto/api"; 2 + 3 + export interface VideoEmbed extends AppBskyEmbedVideo.Main { 4 + $type: "app.bsky.embed.video"; 5 + buffer: Buffer; 6 + mimeType: string; 7 + video: BlobRef; 8 + size?: number; 9 + captions?: AppBskyEmbedVideo.Caption[]; 10 + alt?: string; 11 + aspectRatio?: AppBskyEmbedDefs.AspectRatio; 12 + } 13 + 14 + export class VideoEmbedImpl implements VideoEmbed { 15 + readonly $type = "app.bsky.embed.video"; 16 + [k: string]: unknown; 17 + 18 + constructor( 19 + public alt: string | undefined, 20 + public buffer: Buffer, 21 + public mimeType: string, 22 + public size: number | undefined, 23 + public video: BlobRef, 24 + public aspectRatio?: AppBskyEmbedDefs.AspectRatio, 25 + public captions?: AppBskyEmbedVideo.Caption[] 26 + ) {} 27 + 28 + toJSON() { 29 + return { 30 + $type: this.$type, 31 + alt: this.alt, 32 + buffer: "[Buffer length=" + this.buffer.length + "]", 33 + mimeType: this.mimeType, 34 + size: this.size, 35 + video: this.video, 36 + }; 37 + } 38 + }
+5
src/bluesky/types/index.ts
··· 1 + export * from "./ImageEmbed"; 2 + export * from "./VideoEmbed"; 3 + export * from "./ImagesEmbed"; 4 + export * from "./PostRecord"; 5 + export * from "./EmbeddedMedia";
+1
src/image/index.ts
··· 1 + export * from './image';
+1
src/logger/index.ts
··· 1 + export * from './logger';
+1
src/media/index.ts
··· 1 + export * from './media';
+1
src/video/index.ts
··· 1 + export * from './video';
+1 -1
src/video/video.ts
··· 1 1 import ffmpeg from 'fluent-ffmpeg'; 2 2 import ffprobe from '@ffprobe-installer/ffprobe'; 3 3 import { logger } from '../logger/logger' 4 - import { BlueskyClient, VideoEmbed } from '../bluesky/bluesky'; 4 + import { BlueskyClient, VideoEmbed } from '../bluesky'; 5 5 import { BlobRef } from '@atproto/api'; 6 6 7 7 // Configure ffmpeg to use ffprobe