@sodiumlabs/plume-url
Version:
The official Plume URL wrapper
85 lines (80 loc) • 2.3 kB
TypeScript
interface PlumeURLRESTOptions {
/**
* The API key to use.
*/
apiKey?: string;
userAgent?: string;
}
declare class PlumeURLREST {
readonly options: PlumeURLRESTOptions;
static readonly baseURL: string;
static readonly defaultUserAgent: string;
constructor(options?: PlumeURLRESTOptions);
request(method: string, path: string, body?: object): Promise<Response>;
get<T = unknown>(path: string): Promise<T>;
post<T = unknown>(path: string, body?: object): Promise<T>;
}
interface CreateURLOptions {
url: string;
expiresAt?: number | null;
description?: string | null;
customId?: string | null;
}
type EditURLOptions = Partial<CreateURLOptions>;
interface SearchURLOptions {
customId?: string | null;
limit?: number;
page?: number;
expired?: boolean;
}
interface SearchURLResults {
urls: URLData[];
}
interface URLData {
userId: string;
createdAt: number;
destination: string;
shortenId: string;
shorten: string;
infoPage: string;
customId: string | null;
description: string | null;
expiresAt: number | null;
expired: boolean;
views: number;
disabled: boolean;
}
interface PlumeURLOptions extends PlumeURLRESTOptions {
}
/**
* The client to interact with Plume URL.
*/
declare class PlumeURL {
readonly rest: PlumeURLREST;
constructor(options?: PlumeURLOptions);
/**
* Create a new shortened URL.
*/
createURL(options: CreateURLOptions): Promise<URLData>;
/**
* Search URLs.
*/
search({ customId, limit, page, expired }: SearchURLOptions): Promise<SearchURLResults>;
/**
* Get an URL.
*/
getURL(id: string): Promise<URLData>;
/**
* Edit an URL.
*/
editURL(id: string, options: EditURLOptions): Promise<void>;
/**
* Delete an URL.
*/
deleteURL(id: string): Promise<void>;
}
declare class PlumeURLError extends Error {
res?: (Response | null) | undefined;
constructor(message: string, options?: ErrorOptions | undefined, res?: (Response | null) | undefined);
}
export { type CreateURLOptions, type EditURLOptions, PlumeURL, PlumeURLError, type PlumeURLOptions, PlumeURLREST, type PlumeURLRESTOptions, type SearchURLOptions, type SearchURLResults, type URLData };