@bzr/bazaar
Version:
The Bazaar SDK. Conveniently use Bazaar with your app in the browser.
74 lines (73 loc) • 2.76 kB
TypeScript
import { type GrantedPermission, type Link, type NewPermission, type PermissionTemplate, type SharingNotification, type SubscribeListener, GrantedPermissionsQuery, LinksQuery, PermissionsQuery, ContextOptions } from "../types";
import { API } from "./raw";
/**
* The class that encapsulates the permissions API
* @internal
*/
export declare class PermissionsAPI {
private api;
private linkUri;
private contextOptions;
constructor(api: API, uri: string, contextOptions?: ContextOptions);
/**
* Creates permission for a collection query and a user.
* @param {NewPermission} permission "Specifies the permission to be created"
* @param {SharingNotification} notification "Specifies if/how the user is notified. Defaults to {createNotification: false, sendMessage: SendNotification.Never}"
*/
create(permission: NewPermission, notification?: SharingNotification): Promise<{
id: string;
}>;
/**
* Lists permissions.
* @param options - If no optional params are set, all permissions for the user are returned.
* @returns All permissions are returned if no options are passed.
*/
list(query?: PermissionsQuery): Promise<import("../types").Permission[]>;
/**
* Deletes permission with a given ID
* @param permissionId - ID of the permission to delete
*/
delete(permissionId: string): Promise<import("../types").BazaarMessage>;
/**
* Links
*/
links: {
/**
* Creates a link
*/
create: (permission: PermissionTemplate, description?: string, limit?: number) => Promise<{
id: string;
permission: PermissionTemplate;
limit: number;
description: string;
users: string[];
url: string;
}>;
/**
* Lists links
*/
list: (query?: LinksQuery) => Promise<Link[]>;
/**
* Subscribes to links changes
* @returns an unsubscribe function
*/
subscribe: (query: LinksQuery, listener: SubscribeListener<Link>) => Promise<() => Promise<import("../types").BazaarMessage>>;
/**
* Deletes a link
*/
delete: (linkId: string) => Promise<import("../types").BazaarMessage>;
};
/**
* Granted Permissions
*/
granted: {
list: (query?: GrantedPermissionsQuery) => Promise<GrantedPermission[]>;
subscribe: (query: GrantedPermissionsQuery, listener: SubscribeListener<GrantedPermission>) => Promise<() => Promise<import("../types").BazaarMessage>>;
delete: (grantedPermissionId: string) => Promise<import("../types").BazaarMessage>;
};
/**
* Groups
* @alpha
*/
private groups;
}