@humanwhocodes/crosspost
Version:
A utility to post across multiple social networks.
68 lines (67 loc) • 1.66 kB
TypeScript
export type ImageEmbed = {
/**
* The alt text for the image.
*/
alt?: string | undefined;
/**
* The image data.
*/
data: Uint8Array;
};
export type ImageEmbedArray = [ImageEmbed] | [ImageEmbed, ImageEmbed] | [ImageEmbed, ImageEmbed, ImageEmbed] | [ImageEmbed, ImageEmbed, ImageEmbed, ImageEmbed];
export type PostOptions = {
/**
* An array of images to include.
*/
images?: ImageEmbedArray | undefined;
/**
* Signal for aborting operations.
*/
signal?: AbortSignal | undefined;
};
export type PostToOptions = {
/**
* Signal for aborting operations.
*/
signal?: AbortSignal | undefined;
};
export type PostToEntry = {
/**
* The message to post.
*/
message: string;
/**
* The ID of the strategy to use for posting.
*/
strategyId: string;
/**
* An array of images to include.
*/
images?: ImageEmbedArray | undefined;
};
export type Strategy = {
/**
* The display name of the strategy.
*/
name: string;
/**
* A unique ID for the strategy.
*/
id: string;
/**
* A function that posts a message.
*/
post: (message: string, options?: PostOptions) => Promise<any>;
/**
* A function that extracts or calculates a URL from the response.
*/
getUrlFromResponse?: ((response: any) => string) | undefined;
/**
* The maximum message length for the strategy.
*/
MAX_MESSAGE_LENGTH: number;
/**
* Calculates the message length according to the strategy's algorithm.
*/
calculateMessageLength: (message: string) => number;
};