Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bzr/bazaar

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bzr/bazaar - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

dist/api/context.d.ts

5

dist/api/collection.d.ts
import { API } from "./raw";
import type { SubscribeListener, BazaarMessage, CollectionOptions, FilterObject, OrderBy, Doc, AnyDoc, DeepPartial } from "../types";
import type { SubscribeListener, BazaarMessage, CollectionOptions, FilterObject, OrderBy, Doc, AnyDoc, DeepPartial, ContextOptions } from "../types";
/**

@@ -10,3 +10,4 @@ * @internal

private collectionOptions;
constructor(api: API, collectionName: string, collectionOptions?: CollectionOptions);
private contextOptions;
constructor(api: API, collectionName: string, collectionOptions?: CollectionOptions, contextOptions?: ContextOptions);
getOne(docId: string): Promise<T>;

@@ -13,0 +14,0 @@ getAll(filter?: FilterObject, options?: {

8

dist/api/collections.d.ts

@@ -0,1 +1,2 @@

import { ContextOptions } from "../types";
import type { API } from "./raw";

@@ -8,11 +9,12 @@ /**

private api;
constructor(api: API);
private contextOptions;
constructor(api: API, contextOptions?: ContextOptions);
/**
* Creates a collection.
*/
create(collectionName: string): Promise<import("..").BazaarMessage>;
create(collectionName: string): Promise<import("../types").BazaarMessage>;
/**
* Drops a collection.
*/
drop(collectionName: string): Promise<import("..").BazaarMessage>;
drop(collectionName: string): Promise<import("../types").BazaarMessage>;
/**

@@ -19,0 +21,0 @@ * Lists all collection names.

@@ -1,2 +0,2 @@

import { type GrantedPermission, type Link, type NewPermission, type PermissionTemplate, type PermissionType, type SharingNotification, type SubscribeListener } from "../types";
import { type GrantedPermission, type Link, type NewPermission, type PermissionTemplate, type SharingNotification, type SubscribeListener, GrantedPermissionsQuery, LinksQuery, PermissionsQuery, ContextOptions } from "../types";
import { API } from "./raw";

@@ -10,3 +10,4 @@ /**

private linkUri;
constructor(api: API, uri: string);
private contextOptions;
constructor(api: API, uri: string, contextOptions?: ContextOptions);
/**

@@ -25,7 +26,3 @@ * Creates permission for a collection query and a user.

*/
list(options?: {
collectionName?: string;
userId?: string;
type?: PermissionType;
}): Promise<import("../types").Permission[]>;
list(query?: PermissionsQuery): Promise<import("../types").Permission[]>;
/**

@@ -54,6 +51,3 @@ * Deletes permission with a given ID

*/
list: (options?: {
collectionName?: string;
type?: PermissionType;
}) => Promise<Link[]>;
list: (query?: LinksQuery) => Promise<Link[]>;
/**

@@ -63,6 +57,3 @@ * Subscribes to links changes

*/
subscribe: (options: {
collectionName?: string;
type?: PermissionType;
}, listener: SubscribeListener<Link>) => Promise<() => Promise<import("../types").BazaarMessage>>;
subscribe: (query: LinksQuery, listener: SubscribeListener<Link>) => Promise<() => Promise<import("../types").BazaarMessage>>;
/**

@@ -77,14 +68,11 @@ * Deletes a link

granted: {
list: (options?: {
collectionName?: string;
ownerId?: string;
type?: PermissionType;
}) => Promise<GrantedPermission[]>;
list: (query?: GrantedPermissionsQuery) => Promise<GrantedPermission[]>;
subscribe: (query: GrantedPermissionsQuery, listener: SubscribeListener<GrantedPermission>) => Promise<() => Promise<import("../types").BazaarMessage>>;
delete: (grantedPermissionId: string) => Promise<import("../types").BazaarMessage>;
subscribe: (options: {
collectionName?: string;
ownerId?: string;
type?: PermissionType;
}, listener: SubscribeListener<GrantedPermission>) => Promise<() => Promise<import("../types").BazaarMessage>>;
};
/**
* Groups
* @alpha
*/
private groups;
}

@@ -1,2 +0,2 @@

import type { APIOptions, Permission, NewPermission, SubscribeListener, BazaarMessage, Contact, User, GrantedPermission, PermissionType, PermissionTemplate, Doc, BasicLink, CollectionCommonOptions, CollectionGetAllOptions, CollectionCommonAllOptions, SharingNotification, Notification, CreateNotification } from "../types";
import type { APIOptions, Permission, NewPermission, SubscribeListener, BazaarMessage, Contact, User, GrantedPermission, PermissionTemplate, Doc, BasicLink, ContextOptions, CollectionGetAllOptions, CollectionQueryOptions, SharingNotification, Notification, CreateNotification, Org, Team, PermissionGroup, LinksQuery, PermissionsQuery, GrantedPermissionsQuery, NewPermissionGroup } from "../types";
/**

@@ -68,3 +68,3 @@ * The class that encapsulates the low level data API

*/
collectionGetOne<T extends Doc>(collectionName: string, docId: string, options?: CollectionCommonOptions): Promise<{
collectionGetOne<T extends Doc>(collectionName: string, docId: string, options?: ContextOptions): Promise<{
data: T | null;

@@ -91,3 +91,3 @@ }>;

*/
collectionSubscribeOne<T extends Doc>(collectionName: string, docId: string, options: CollectionCommonOptions, listener: SubscribeListener<T>): Promise<() => Promise<string>>;
collectionSubscribeOne<T extends Doc>(collectionName: string, docId: string, options: ContextOptions, listener: SubscribeListener<T>): Promise<() => Promise<string>>;
/**

@@ -101,3 +101,3 @@ * Subscribes to collection changes. Private by default, or public with read permission.

*/
collectionSubscribeAll<T extends Doc>(collectionName: string, options: CollectionCommonAllOptions, listener: SubscribeListener<T>): Promise<() => Promise<string>>;
collectionSubscribeAll<T extends Doc>(collectionName: string, options: CollectionQueryOptions, listener: SubscribeListener<T>): Promise<() => Promise<string>>;
/**

@@ -111,3 +111,3 @@ * Inserts a collection doc.

*/
collectionInsertOne(collectionName: string, doc: object, options?: CollectionCommonOptions): Promise<{
collectionInsertOne(collectionName: string, doc: object, options?: ContextOptions): Promise<{
data: string;

@@ -123,3 +123,3 @@ }>;

*/
collectionUpdateOne(collectionName: string, docId: string, doc: object, options?: CollectionCommonOptions): Promise<BazaarMessage>;
collectionUpdateOne(collectionName: string, docId: string, doc: object, options?: ContextOptions): Promise<BazaarMessage>;
/**

@@ -133,3 +133,3 @@ * Replaces a collection doc. Private by default, or public with insert, update, delete permissions.

*/
collectionReplaceOne(collectionName: string, docId: string, doc: object, options?: CollectionCommonOptions): Promise<BazaarMessage>;
collectionReplaceOne(collectionName: string, docId: string, doc: object, options?: ContextOptions): Promise<BazaarMessage>;
/**

@@ -142,3 +142,3 @@ * Deletes a doc

*/
collectionDeleteOne(collectionName: string, docId: string, options?: CollectionCommonOptions): Promise<BazaarMessage>;
collectionDeleteOne(collectionName: string, docId: string, options?: ContextOptions): Promise<BazaarMessage>;
/**

@@ -150,11 +150,11 @@ * Deletes all collection docs matching an optional filter.

*/
collectionDeleteAll(collectionName: string, options?: CollectionCommonAllOptions): Promise<BazaarMessage>;
collectionDeleteAll(collectionName: string, options?: CollectionQueryOptions): Promise<BazaarMessage>;
/**
* Creates a collection.
*/
collectionsCreate(collectionName: string): Promise<BazaarMessage>;
collectionsCreate(collectionName: string, options?: ContextOptions): Promise<BazaarMessage>;
/**
* Drops a collection.
*/
collectionsDrop(collectionName: string): Promise<BazaarMessage>;
collectionsDrop(collectionName: string, options?: ContextOptions): Promise<BazaarMessage>;
/**

@@ -164,3 +164,3 @@ * Lists all collection names.

*/
collectionsList(): Promise<{
collectionsList(options?: ContextOptions): Promise<{
data: string[];

@@ -171,10 +171,7 @@ }>;

*
* @param options - If no options are set, all permissions are returned.
* @returns All permissions matching options.
* @param query - If no options are set, all permissions are returned.
* @param options - database ID options.
* @returns All permissions matching query options.
*/
permissionsList(options?: {
collectionName?: string;
userId?: string;
type?: PermissionType;
}): Promise<{
permissionsList(query?: PermissionsQuery, options?: ContextOptions): Promise<{
data: Permission[];

@@ -185,3 +182,3 @@ }>;

*/
permissionsCreate(permission: NewPermission, notification: SharingNotification): Promise<{
permissionsCreate(permission: NewPermission, notification: SharingNotification, options?: ContextOptions): Promise<{
id: string;

@@ -194,7 +191,7 @@ }>;

*/
permissionsDelete(permissionId: string): Promise<BazaarMessage>;
permissionsDelete(permissionId: string, options?: ContextOptions): Promise<BazaarMessage>;
/**
* Creates a permission link.
*/
linksCreate(permission: PermissionTemplate, description?: string, limit?: number): Promise<{
linksCreate(permission: PermissionTemplate, description?: string, limit?: number, options?: ContextOptions): Promise<{
data: BasicLink;

@@ -205,9 +202,7 @@ }>;

*
* @param options - If no options are set, all links are returned.
* @param query - If no options are set, all links are returned.
* @param options - database ID options.
* @returns Where `data` is an array of links
*/
linksList(options?: {
collectionName?: string;
type?: PermissionType;
}): Promise<{
linksList(query?: LinksQuery, options?: ContextOptions): Promise<{
data: BasicLink[];

@@ -218,2 +213,3 @@ }>;

*
* @param query -
* @param options -

@@ -223,6 +219,3 @@ * @param listener - The callback function that receives link change events.

*/
linksSubscribe(options: {
collectionName?: string;
type?: PermissionType;
}, listener: SubscribeListener<BasicLink>): Promise<() => Promise<BazaarMessage>>;
linksSubscribe(query: LinksQuery, options: ContextOptions, listener: SubscribeListener<BasicLink>): Promise<() => Promise<BazaarMessage>>;
/**

@@ -237,7 +230,3 @@ * Deletes permission links.

*/
grantedPermissionsList(options?: {
collectionName?: string;
ownerId?: string;
type?: PermissionType;
}): Promise<{
grantedPermissionsList(query: GrantedPermissionsQuery, options: ContextOptions): Promise<{
data: GrantedPermission[];

@@ -251,7 +240,3 @@ }>;

*/
grantedPermissionsSubscribe(options: {
collectionName?: string;
ownerId?: string;
type?: PermissionType;
}, listener: SubscribeListener<GrantedPermission>): Promise<() => Promise<BazaarMessage>>;
grantedPermissionsSubscribe(query: GrantedPermissionsQuery, options: ContextOptions, listener: SubscribeListener<GrantedPermission>): Promise<() => Promise<BazaarMessage>>;
/**

@@ -264,2 +249,48 @@ * Deletes a granted permission

/**
* Get a group
*
* @param groupId - The ID of the group to get.
*/
groupsGet(groupId: string, options?: ContextOptions): Promise<{
data: PermissionGroup;
}>;
/**
* Lists groups.
*
* @param options - database ID options.
* @returns All groups matching query.
*/
groupsList(options?: ContextOptions): Promise<{
data: PermissionGroup[];
}>;
/**
* Creates a group.
*/
groupsCreate(group: NewPermissionGroup, options?: ContextOptions): Promise<{
id: string;
}>;
/**
* Add member to a group.
*
* @param groupId - The ID of the group
* @param userId - The ID of the user
* @param options - database ID options.
*/
groupsAddMember(groupId: string, userId: string, options?: ContextOptions): Promise<BazaarMessage>;
/**
* Remove member from a group.
*
* @param groupId - The ID of the group
* @param userId - The ID of the user
* @param options - database ID options.
*
*/
groupsRemoveMember(groupId: string, userId: string, options?: ContextOptions): Promise<BazaarMessage>;
/**
* Deletes a group.
*
* @param groupId - The ID of the group to delete.
*/
groupsDelete(groupId: string, options?: ContextOptions): Promise<BazaarMessage>;
/**
* Creates a notification.

@@ -329,2 +360,27 @@ */

contactsSubscribe(listener: SubscribeListener<Contact>): Promise<() => Promise<BazaarMessage>>;
/**
* Gets all orgs user is member/admin.
*/
organizationsList(): Promise<{
data: Org[];
}>;
/**
* Gets the org info for a given ID or handle.
* @param payload - The ID or handle of the org, requires one of the two.
*/
organizationsGet(payload: {
userId?: string;
handle?: string;
}): Promise<{
data: Org;
}>;
/**
* Lists teams
* @returns a list of teams
*/
teamsList(payload: {
type?: "user" | "org";
}): Promise<{
data: Team[];
}>;
private onModalMessage;

@@ -331,0 +387,0 @@ private closeModal;

@@ -5,7 +5,8 @@ import { CollectionAPI } from "./api/collection";

import { SocialAPI } from "./api/social";
import type { BazaarOptions, CollectionOptions, Doc, LoginType } from "./types";
import type { BazaarOptions, CollectionOptions, ContextOptions, Doc, LoginType } from "./types";
import { BazaarContext } from "./api/context";
/**
* Types of errors that can return from the API
*/
export { ErrorTypes, BazaarError, isNoAppUserError, isNoPermissionError, arrayMirrorSubscribeListener, objectMirrorSubscribeListener, } from "./utils";
export { ErrorTypes, BazaarError, isNoAppUserError, isNoPermissionError, arrayMirrorSubscribeListener, objectMirrorSubscribeListener, noSharingNotification, } from "./utils";
export { CollectionAPI } from "./api/collection";

@@ -15,7 +16,8 @@ export { CollectionsAPI } from "./api/collections";

export { SocialAPI } from "./api/social";
export { BazaarContext } from "./api/context";
/**
* Enums
*/
export { OrderByType, PermissionType, LoginType, SendNotification } from "./types";
export type { User, Contact, Permission, NewPermission, PermissionTemplate, GrantedPermission, SharingNotification, FilterObject, FilterComparison, OrderBy, BazaarMessage, Link, Doc, AnyDoc, DeepPartial, SubscribeListener, BazaarOptions, } from "./types";
export { OrderByType, PermissionType, LoginType, SendNotification, GranteeType } from "./types";
export type { User, Contact, Team, Org, AnyPermission, UserPermission, GroupPermission, OrgPermission, Permission, NewPermission, PermissionTemplate, GrantedPermission, PermissionGroup, SharingNotification, FilterObject, FilterComparison, OrderBy, BazaarMessage, Link, Doc, AnyDoc, DeepPartial, SubscribeListener, BazaarOptions, CollectionOptions, ContextOptions, PermissionsQuery, LinksQuery, GrantedPermissionsQuery, } from "./types";
/**

@@ -50,2 +52,8 @@ * The primary class of the Bazaar JS SDK to help you more easily build web apps with Bazaar.

social: SocialAPI;
/**
* Access to the organizations API
* @alpha
*/
private orgs;
private bazaarUri;
constructor(options: BazaarOptions);

@@ -94,5 +102,6 @@ /**

* @param collectionName - The name of the collection to create the interface for.
* @param collectionOptions - An optional object for specifying a user ID & onCreate hook. Specify a user ID to operate on a collection owned by that user ID. Otherwise operates on a collection owned by the authenticated user. The onCreate hook sets up a collection when it is created (e.g., to set up permissions)
* @param collectionOptions - An optional object for specifying an onCreate hook. The onCreate hook sets up a collection when it is created (e.g., to set up permissions)
*/
collection<T extends Doc>(collectionName: string, collectionOptions?: CollectionOptions): CollectionAPI<T>;
createContext(options: ContextOptions): BazaarContext;
}

@@ -38,12 +38,30 @@ import { BazaarApp } from "..";

export type APIOptions = Omit<AuthOptions, "loginRedirectUri">;
/**
* Represents a complete permission object which includes both the `id` field and `userId` for user association.
*/
export type Permission = {
export declare enum GranteeType {
USER = "user",
ANY = "any",
GROUP = "group",
ORG = "org"
}
export type BasePermission = {
id: string;
collectionName: string;
userId: string;
types: PermissionType[];
filter?: FilterObject;
};
export type AnyPermission = BasePermission & {
granteeType: GranteeType.ANY;
};
export type UserPermission = BasePermission & {
granteeType: GranteeType.USER;
granteeId: string;
};
export type GroupPermission = BasePermission & {
granteeType: GranteeType.GROUP;
granteeId: string;
};
export type OrgPermission = BasePermission & {
granteeType: GranteeType.ORG;
granteeId: string;
};
export type Permission = AnyPermission | UserPermission | GroupPermission | OrgPermission;
/**

@@ -53,8 +71,8 @@ * Represents a permission object that is yet to be persisted.

*/
export type NewPermission = Omit<Permission, "id">;
export type NewPermission = Omit<AnyPermission, "id"> | Omit<UserPermission, "id"> | Omit<GroupPermission, "id"> | Omit<OrgPermission, "id">;
/**
* Represents the foundational structure of a permission template.
* It's derived from the {@link NewPermission} and does not include user association.
* It's derived from the {@link BasePermission} and does not include the ID.
*/
export type PermissionTemplate = Omit<NewPermission, "userId">;
export type PermissionTemplate = Omit<BasePermission, "id">;
/**

@@ -70,2 +88,11 @@ *

/**
*
*/
export type PermissionGroup = {
id: string;
label: string;
members: string[];
};
export type NewPermissionGroup = Omit<PermissionGroup, "id">;
/**
* Represents the options for sending notifications.

@@ -113,3 +140,3 @@ */

export type CreateNotification = {
userId: string;
recipientId: string;
sendMessage?: SendNotification;

@@ -296,17 +323,42 @@ message: string;

};
export type Org = {
id: string;
name: string;
handle: string;
primaryTeam: Team;
active: boolean;
admins: string[];
};
/**
*
*/
export type Team = {
id: string;
name: string;
ownerType: "user" | "org";
ownerId: string;
primary: boolean;
admins: string[];
members: string[];
};
export type CollectionOptions = {
onCreate?: () => Promise<void>;
userId?: string;
};
/**
* Options for several methods in {@link API}
* Options that helps identify the context. Used for several methods in {@link API}
* Currently the context is only determined by the ownerId
*/
export type CollectionCommonOptions = {
/** An optional user ID of the owner of the collection to read. Defaults to own ID. */
userId?: string;
export type ContextOptions = {
ownerId?: string;
};
/**
* Options for {@link API.collectionSubscribeAll} and {@link API.collectionDeleteAll}
*/
export type CollectionQueryOptions = ContextOptions & {
filter?: FilterObject;
};
/**
* Options for {@link API.collectionGetAll}
*/
export type CollectionGetAllOptions = {
export type CollectionGetAllOptions = CollectionQueryOptions & {
/** An optional start offset. Default is 0 (inclusive). */

@@ -317,13 +369,17 @@ startOffset?: number;

orderBy?: OrderBy;
filter?: FilterObject;
/** An optional user ID of the owner of the collection to read. Defaults to own ID. */
userId?: string;
};
/**
* Options for {@link API.collectionSubscribeAll} and {@link API.collectionDeleteAll}
*/
export type CollectionCommonAllOptions = {
filter?: FilterObject;
/** An optional user ID of the owner of the collection to read. Defaults to own ID. */
userId?: string;
export type PermissionsQuery = {
collectionName?: string;
granteeType?: GranteeType;
granteeId?: string;
type?: PermissionType;
};
export type LinksQuery = {
collectionName?: string;
type?: PermissionType;
};
export type GrantedPermissionsQuery = {
collectionName?: string;
ownerId?: string;
type?: PermissionType;
};

@@ -1,15 +0,15 @@

import type { Doc, SubscribeListener } from "../types";
import { type Doc, SendNotification, type SubscribeListener } from "../types";
/**
* Constant of all the error types
* @internal
*
*/
export declare const ErrorTypes: {
Unspecified: number;
NoPermission: number;
ReservedCollectionName: number;
CollectionDoesNotExist: number;
DatabaseDoesNotExist: number;
};
export declare enum ErrorTypes {
Unspecified = 1,
NoPermission = 2,
ReservedCollectionName = 3,
CollectionDoesNotExist = 4,
DatabaseDoesNotExist = 5
}
/**
* @internal
*
*/

@@ -46,1 +46,5 @@ export declare class BazaarError extends Error {

};
export declare const noSharingNotification: {
createNotification: boolean;
sendMessage: SendNotification;
};
{
"name": "@bzr/bazaar",
"version": "1.2.1",
"version": "1.3.0",
"description": "The Bazaar SDK. Conveniently use Bazaar with your app in the browser.",

@@ -5,0 +5,0 @@ "files": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc