magically-sdk
Version:
Official SDK for Magically - Build mobile apps with AI
190 lines (189 loc) • 4.07 kB
TypeScript
export interface User {
_id: string;
id: string;
email: string;
name: string;
firstName?: string;
lastName?: string;
}
export interface AuthState {
user: User | null;
isAuthenticated: boolean;
isLoading: boolean;
error: string | null;
token?: string | null;
}
export interface TokenData {
accessToken: string;
refreshToken: string;
expiresIn: number;
tokenType: string;
}
export interface DataQueryOptions {
sort?: Record<string, 1 | -1>;
limit?: number;
skip?: number;
}
export interface DataQueryResult<T> {
data: T[];
total: number;
}
export interface DataInsertOptions<T = any> {
data: T;
upsert?: boolean;
}
export interface StandardFields {
_id: string;
creator: string;
createdAt: Date;
updatedAt: Date;
isPublic?: boolean;
}
export interface LLMTextContent {
type: 'text';
text: string;
}
export interface LLMImageContent {
type: 'image';
image: string | URL;
}
export type LLMContent = LLMTextContent | LLMImageContent;
export interface LLMMessage {
role: 'system' | 'user' | 'assistant';
content: string | LLMContent[];
}
export interface InvokeOptions {
model?: string;
temperature?: number;
response_json_schema?: object;
images?: string[];
}
export interface ChatOptions {
model?: string;
temperature?: number;
stream?: boolean;
}
export interface ImageOptions {
model?: string;
size?: '1024x1024' | '1792x1024' | '1024x1792';
quality?: 'standard' | 'hd';
n?: number;
}
export interface TranscribeOptions {
model?: string;
language?: string;
prompt?: string;
response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
temperature?: number;
}
export interface InvokeTextResponse {
text: string;
}
export interface ChatResponse {
message: {
role: 'assistant';
content: string;
};
usage: any;
}
export interface SingleImageResponse {
url: string;
filename: string;
prompt: string;
model: string;
size: string;
quality: string;
downloadUrl: string;
}
export interface MultipleImageResponse {
images: Array<{
url: string;
filename: string;
downloadUrl: string;
}>;
prompt: string;
model: string;
size: string;
count: number;
}
export interface ModelsResponse {
text: string[];
image: string[];
transcription: string[];
default: {
text: string;
image: string;
transcription: string;
};
}
export interface TranscribeResponse {
text: string;
language?: string;
duration?: number;
format?: string;
segments?: Array<{
id: number;
seek: number;
start: number;
end: number;
text: string;
tokens: number[];
temperature: number;
avg_logprob: number;
compression_ratio: number;
no_speech_prob: number;
}>;
words?: Array<{
word: string;
start: number;
end: number;
}>;
}
export interface FileUploadOptions {
tags?: string[];
metadata?: Record<string, any>;
}
export interface FileListOptions {
limit?: number;
skip?: number;
tags?: string[];
mimeType?: string;
}
export interface UploadedFile {
_id: string;
filename: string;
originalName: string;
mimeType: string;
size: number;
url: string;
downloadUrl: string;
pathname: string;
creator: string;
tags?: string[];
metadata?: Record<string, any>;
createdAt: Date;
updatedAt: Date;
}
export interface FileListResponse {
success: boolean;
data: UploadedFile[];
total: number;
limit: number;
skip: number;
}
export interface SDKConfig {
projectId: string;
apiUrl?: string;
apiKey?: string;
debug?: boolean;
linkingScheme?: string;
}
export interface AuthCallbackMessage {
type: 'magically-auth-callback';
accessToken: string;
user: {
id: string;
email: string;
name: string;
};
}