UNPKG

@bzr/bazaar

Version:

The Bazaar SDK. Conveniently use Bazaar with your app in the browser.

50 lines (49 loc) 1.76 kB
import { type Doc, SendNotification, type SubscribeListener } from "../types"; /** * Constant of all the error types * */ export declare enum ErrorTypes { Unspecified = 1, NoPermission = 2, ReservedCollectionName = 3, CollectionDoesNotExist = 4, DatabaseDoesNotExist = 5 } /** * */ export declare class BazaarError extends Error { type: number; constructor(type: number, ...params: any[]); } export declare function isNoAppUserError(e: unknown): boolean; export declare function isNoPermissionError(e: unknown): boolean; /** * Generates a secure random string using the browser crypto functions */ export declare function generateRandomString(): string; /** * Opens and centers pop-up on specific window to account for multiple monitors * @param url url to open * @param windowName name to identify pop-up window * @param win the parent/opener window * @returns `Window` if successful, `null` if blocked by a built-in browser pop-up blocker. Otherwise fails silently I think... */ export declare function popupWindow(url: string, windowName: string, win: Window): Window | null; export declare function arrayMirrorSubscribeListener<T extends Doc>(data: T[], listener?: SubscribeListener<T>): { onInitial: (doc: T) => void; onAdd: (doc: T) => void; onChange: (oldDoc: T, newDoc: T) => void; onDelete: (doc: T) => void; }; export declare function objectMirrorSubscribeListener<T extends Doc>(data: T | undefined, listener?: SubscribeListener<T>): { onInitial: (doc: T) => void; onAdd: (doc: T) => void; onChange: (oldDoc: T, newDoc: T) => void; onDelete: (doc: T) => void; }; export declare const noSharingNotification: { createNotification: boolean; sendMessage: SendNotification; };