@hirall/client
Version:
Official TypeScript/JavaScript client for Hirall - Backend-as-a-Service
157 lines (155 loc) • 4.01 kB
text/typescript
/**
* Hirall TypeScript SDK
* Official client library for Hirall
*/
declare class HirallClient {
private apiUrl;
private apiKey;
private headers;
constructor(apiUrl: string, apiKey: string);
/**
* Database operations
*/
get db(): DatabaseClient;
/**
* Authentication
*/
get auth(): AuthClient;
/**
* Storage operations
*/
get storage(): StorageClient;
/**
* Real-time subscriptions
*/
get realtime(): RealtimeClient;
/**
* Edge functions
*/
get functions(): FunctionsClient;
/**
* AI features
*/
get ai(): AIClient;
}
/**
* Database Client
*/
declare class DatabaseClient {
private apiUrl;
private headers;
constructor(apiUrl: string, headers: Record<string, string>);
from<T = any>(table: string): QueryBuilder<T>;
query<T = any>(sql: string, params?: any[]): Promise<T[]>;
}
/**
* Query Builder
*/
declare class QueryBuilder<T> {
private apiUrl;
private headers;
private table;
private selectColumns;
private whereConditions;
private orderByClause?;
private limitValue?;
private offsetValue?;
constructor(apiUrl: string, headers: Record<string, string>, table: string);
select(columns?: string): this;
eq(column: string, value: any): this;
neq(column: string, value: any): this;
gt(column: string, value: any): this;
lt(column: string, value: any): this;
order(column: string, options?: {
ascending?: boolean;
}): this;
limit(count: number): this;
offset(count: number): this;
execute(): Promise<T[]>;
single(): Promise<T | null>;
insert(data: Partial<T>): Promise<T>;
update(data: Partial<T>): Promise<T[]>;
delete(): Promise<void>;
}
/**
* Auth Client
*/
declare class AuthClient {
private apiUrl;
private headers;
constructor(apiUrl: string, headers: Record<string, string>);
signUp(email: string, password: string): Promise<any>;
signIn(email: string, password: string): Promise<any>;
signOut(): Promise<any>;
}
/**
* Storage Client
*/
declare class StorageClient {
private apiUrl;
private headers;
constructor(apiUrl: string, headers: Record<string, string>);
bucket(name: string): BucketClient;
}
declare class BucketClient {
private apiUrl;
private headers;
private bucketName;
constructor(apiUrl: string, headers: Record<string, string>, bucketName: string);
upload(path: string, file: File | Blob): Promise<any>;
download(path: string): Promise<Blob>;
delete(path: string): Promise<any>;
}
/**
* Realtime Client
*/
declare class RealtimeClient {
private wsUrl;
private apiKey;
private ws?;
constructor(wsUrl: string, apiKey: string);
channel(name: string): Channel;
connect(): WebSocket;
send(message: any): void;
}
declare class Channel {
private client;
private name;
private listeners;
constructor(client: RealtimeClient, name: string);
on(event: string, callback: Function): this;
subscribe(): this;
send(event: string, payload: any): void;
}
/**
* Functions Client
*/
declare class FunctionsClient {
private apiUrl;
private headers;
constructor(apiUrl: string, headers: Record<string, string>);
invoke(name: string, payload?: any): Promise<any>;
}
/**
* AI Client
*/
declare class AIClient {
private apiUrl;
private headers;
constructor(apiUrl: string, headers: Record<string, string>);
generateEmbedding(text: string): Promise<any>;
semanticSearch(query: string, limit?: number): Promise<any>;
chat(messages: Array<{
role: string;
content: string;
}>): Promise<any>;
}
/**
* Create Hirall client
*/
declare function createClient(apiUrl: string, apiKey: string): HirallClient;
declare const _default: {
createClient: typeof createClient;
HirallClient: typeof HirallClient;
};
export { HirallClient, createClient, _default as default };