tnl-midjourney-api
Version:
A Node.js module for interacting with Midjourney via The Next Leg
149 lines (148 loc) • 6.93 kB
TypeScript
export declare namespace TNLTypes {
type ButtonTypes = 'U1' | 'U2' | 'U3' | 'U4' | 'V1' | 'V2' | 'V3' | 'V4' | '🔄' | '🪄 Make Variations' | '❤️ Favorite';
type SlashCommands = 'relax' | 'fast' | 'private' | 'stealth';
type Settings = 'MJ version 1' | 'MJ version 2' | 'MJ version 3' | 'MJ version 4' | 'MJ version 5' | 'Niji version 4' | 'Niji version 5' | 'MJ Test' | 'MJ Test Photo' | 'Half quality' | 'Base quality' | 'Base quality' | 'High quality (2x cost)' | 'Style low' | 'Style med' | 'Style high' | 'Style very high' | 'Reset Settings' | 'Public mode' | 'Stealth mode' | 'Remix mode' | 'Fast mode' | 'Relax mode';
namespace Request {
interface BaseRequest {
ref: string;
webhookOverride: string;
}
interface Imagine extends BaseRequest {
msg: string;
}
interface SlashCommand extends BaseRequest {
cmd: SlashCommands;
}
interface SetSettings extends BaseRequest {
settingsToggle: Settings;
}
type Info = BaseRequest;
interface Buttons extends BaseRequest {
button: ButtonTypes;
buttonMessageId: string;
}
interface Describe extends BaseRequest {
url: string;
}
}
namespace Response {
type Message = {
createdAt: string;
messageId: string;
success: boolean;
};
interface MessageAndProgress extends Request.BaseRequest {
progress: number | 'incomplete';
response: WebhookResponses.BaseResponse | WebhookResponses.Imagine | WebhookResponses.Describe | WebhookResponses.Info | WebhookResponses.Settings | WebhookResponses.SlashCommand;
}
type Seed = {
seed: string;
};
}
namespace WebhookResponses {
interface BaseResponse {
ref: string;
createdAt: string;
responseAt: string;
originatingMessageId: string;
buttonMessageId: string;
imageUrl: string;
buttons: string[];
}
interface Imagine extends BaseResponse {
content: string;
}
type Button = Imagine;
interface Describe extends BaseResponse {
content: string[] | string;
type: 'describe';
}
interface SlashCommand extends BaseResponse {
content: string;
}
interface Settings extends BaseResponse {
content: string;
}
interface Info extends BaseResponse {
content: {
'Fast Time Remaining': string;
'Job Mode': string;
'Lifetime Usage': string;
'Queued Jobs (fast)': string;
'Queued Jobs (relax)': string;
'Relaxed Usage': string;
Subscription: string;
'Visibility Mode': string;
};
type: 'info';
}
}
}
export declare class TNL {
private token;
constructor(token: string);
private createHeaders;
/**
* Create a new image from a prompt
* @param prompt - The prompt you want to use to generate the image
* @param ref - A reference string that will be returned in the webhook response
* @param webhookOverride - A webhook URL that will be used instead of the one set in the dashboard
*/
imagine(prompt: string, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>;
/**
* Create an image from a prompt and an image
* @param prompt - The prompt you want to use to generate the image
* @param imgUrl - The URL of the image you want to use as the base image
* @param ref - A reference string that will be returned in the webhook response
* @param webhookOverride - A webhook URL that will be used instead of the one set in the dashboard
*/
img2img(prompt: string, imgUrl: string, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>;
/**
* Describe an image
* @param imgUrl - The URL of the image you want to describe
* @param ref - A reference string that will be returned in the webhook response
* @param webhookOverride - A webhook URL that will be used instead of the one set in the dashboard
*/
describe(imgUrl: string, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>;
/**
* Use a button on an image. This can include upscale, variation, re-roll and more.
* @param button - A button type
* @param buttonMessageId - The buttonMessageId of the message that contains the button
* @param ref - A reference string that will be returned in the webhook response
* @param webhookOverride - A webhook URL that will be used instead of the one set in the dashboard
*/
button(button: TNLTypes.ButtonTypes, buttonMessageId: string, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>;
/**
* Get a seed of a message
* @param messageId - The message ID of the message you want to get the seed for
*/
getSeed(messageId: string): Promise<TNLTypes.Response.Seed>;
/**
* Use a slash command such as relax, fast, private, or stealth
* @param slashCommand - A slash command type
* @param ref - A reference string that will be returned in the webhook response
* @param webhookOverride - A webhook URL that will be used instead of the one set in the dashboard
*/
slashCommand(slashCommand: TNLTypes.SlashCommands, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>;
/**
* Get the settings available on your account
*/
getSettings(): Promise<TNLTypes.Response.Message>;
/**
* Set a setting on your account. You should use `getSettings()` in order to retrieve the settings available in your account.
* @param setting - The setting you want to change
* @param ref - A reference string that will be returned in the webhook response
* @param webhookOverride - A webhook URL that will be used instead of the one set in the dashboard
*/
setSettings(setting: TNLTypes.Settings, ref?: string, webhookOverride?: string): Promise<TNLTypes.Response.Message>;
/**
* Get Information about your account including Fast Time Remaining, Job Mode, Queued Jobs and more.
*/
getInfo(): Promise<TNLTypes.Response.Message>;
/**
* Get the progress and status of any message that you have sent
* @param messageId - The message ID of the message you want to get the progress of
* @param expireMins - A timeout for the request in minutes. If the request takes longer than this, it will return as 'incomplete'
*/
getMessageAndProgress(messageId: string, expireMins?: number): Promise<TNLTypes.Response.MessageAndProgress>;
}