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.0 to 1.2.1

4

dist/api/collection.d.ts

@@ -29,6 +29,2 @@ import { API } from "./raw";

/**
* @alpha
*/
private mirrorAll;
/**
* @returns The doc ID

@@ -35,0 +31,0 @@ */

150

dist/bazaar.esm.js

@@ -89,2 +89,64 @@ import io from 'socket.io-client';

}
function arrayMirrorSubscribeListener(data, listener) {
return {
onInitial: (doc) => {
data.push(doc);
if (listener && listener.onInitial) {
listener.onAdd(doc);
}
},
onAdd: (doc) => {
data.push(doc);
if (listener && listener.onAdd) {
listener.onAdd(doc);
}
},
onChange: (oldDoc, newDoc) => {
const idx = data.findIndex((d) => d.id === oldDoc.id);
if (idx > -1) {
data[idx] = newDoc;
}
else {
// It is missing for some reason, add it.
data.push(newDoc);
}
if (listener && listener.onChange) {
listener.onChange(oldDoc, newDoc);
}
},
onDelete: (doc) => {
const idx = data.findIndex((d) => d.id === doc.id);
if (idx > -1) {
data.splice(idx, 1);
}
if (listener && listener.onDelete) {
listener.onDelete(doc);
}
},
};
}
function objectMirrorSubscribeListener(data, listener) {
return {
onInitial: (doc) => {
if (listener && listener.onInitial) {
listener.onAdd(doc);
}
},
onAdd: (doc) => {
if (listener && listener.onAdd) {
listener.onAdd(doc);
}
},
onChange: (oldDoc, newDoc) => {
if (listener && listener.onChange) {
listener.onChange(oldDoc, newDoc);
}
},
onDelete: (doc) => {
if (listener && listener.onDelete) {
listener.onDelete(doc);
}
},
};
}

@@ -724,2 +786,8 @@ /**

return __awaiter(this, void 0, void 0, function* () {
if (listener.onInitial) {
const doc = yield this.getOne(docId);
if (doc) {
listener.onInitial(doc);
}
}
return this.withCollection(() => this.api.collectionSubscribeOne(this.collectionName, docId, this.collectionOptions, listener));

@@ -733,50 +801,9 @@ });

return __awaiter(this, void 0, void 0, function* () {
return this.withCollection(() => this.api.collectionSubscribeAll(this.collectionName, Object.assign({ filter }, this.collectionOptions), listener));
});
}
/**
* @alpha
*/
mirrorAll(filter, data, listener = {}) {
return __awaiter(this, void 0, void 0, function* () {
const docs = yield this.getAll(filter);
data.push(...docs);
if (listener.onAdd) {
if (listener.onInitial) {
const docs = yield this.getAll(filter);
for (const doc of docs) {
listener.onAdd(doc);
listener.onInitial(doc);
}
}
return yield this.subscribeAll(filter, {
onAdd: (doc) => {
data.push(doc);
if (listener.onAdd) {
listener.onAdd(doc);
}
return;
},
onDelete: (doc) => {
const idx = data.findIndex((d) => d.id === doc.id);
if (idx > -1) {
data.splice(idx, 1);
}
if (listener.onDelete) {
listener.onDelete(doc);
}
return;
},
onChange: (oldDoc, newDoc) => {
const idx = data.findIndex((d) => d.id === oldDoc.id);
if (idx > -1) {
data[idx] = newDoc;
}
else {
// It is missing for some reason, add it.
data.push(newDoc);
}
if (listener.onChange) {
listener.onChange(oldDoc, newDoc);
}
return;
},
});
return this.withCollection(() => this.api.collectionSubscribeAll(this.collectionName, Object.assign({ filter }, this.collectionOptions), listener));
});

@@ -896,11 +923,12 @@ }

/**
* Send an invitation if the target user does not use the app
* Send an notification if the target user does not use the app.
* This is akin to inviting the target user to use the app.
*/
SendNotification["INVITE_ONLY"] = "invite-only";
/**
* Always send an invitation to the target user
* Always send an notification to the target user
*/
SendNotification["ALWAYS"] = "always";
/**
* Never send an invitation to the target user
* Never send an notification to the target user
*/

@@ -970,2 +998,8 @@ SendNotification["NEVER"] = "never";

subscribe: (options = {}, listener) => __awaiter(this, void 0, void 0, function* () {
if (listener.onInitial) {
const links = yield this.links.list(options);
for (const link of links) {
listener.onInitial(Object.assign({ url: this.linkUri + link.id }, link));
}
}
const newListener = {};

@@ -1008,2 +1042,8 @@ if (listener.onAdd) {

subscribe: (options = {}, listener) => __awaiter(this, void 0, void 0, function* () {
if (listener.onInitial) {
const permissions = yield this.granted.list(options);
for (const permission of permissions) {
listener.onInitial(permission);
}
}
return this.api.grantedPermissionsSubscribe(options, listener);

@@ -1070,2 +1110,8 @@ }),

subscribe: (listener) => __awaiter(this, void 0, void 0, function* () {
if (listener.onInitial) {
const contacts = yield this.contacts.list();
for (const contact of contacts) {
listener.onInitial(contact);
}
}
return this.api.contactsSubscribe(listener);

@@ -1410,2 +1456,8 @@ }),

return __awaiter(this, void 0, void 0, function* () {
if (listener.onInitial) {
const notifications = yield this.list(options);
for (const notification of notifications) {
listener.onInitial(notification);
}
}
return this.api.notificationsSubscribe(options, listener);

@@ -1551,2 +1603,2 @@ });

export { BazaarApp, BazaarError, CollectionAPI, CollectionsAPI, ErrorTypes, LoginType, OrderByType, PermissionType, PermissionsAPI, SendNotification, SocialAPI, isNoAppUserError, isNoPermissionError };
export { BazaarApp, BazaarError, CollectionAPI, CollectionsAPI, ErrorTypes, LoginType, OrderByType, PermissionType, PermissionsAPI, SendNotification, SocialAPI, arrayMirrorSubscribeListener, isNoAppUserError, isNoPermissionError, objectMirrorSubscribeListener };

@@ -9,3 +9,3 @@ import { CollectionAPI } from "./api/collection";

*/
export { ErrorTypes, BazaarError, isNoAppUserError, isNoPermissionError } from "./utils";
export { ErrorTypes, BazaarError, isNoAppUserError, isNoPermissionError, arrayMirrorSubscribeListener, objectMirrorSubscribeListener, } from "./utils";
export { CollectionAPI } from "./api/collection";

@@ -12,0 +12,0 @@ export { CollectionsAPI } from "./api/collections";

@@ -72,11 +72,12 @@ import { BazaarApp } from "..";

/**
* Send an invitation if the target user does not use the app
* Send an notification if the target user does not use the app.
* This is akin to inviting the target user to use the app.
*/
INVITE_ONLY = "invite-only",
/**
* Always send an invitation to the target user
* Always send an notification to the target user
*/
ALWAYS = "always",
/**
* Never send an invitation to the target user
* Never send an notification to the target user
*/

@@ -184,2 +185,3 @@ NEVER = "never"

onDelete?: (doc: T) => void;
onInitial?: (doc: T) => void;
};

@@ -186,0 +188,0 @@ /**

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

import type { Doc, SubscribeListener } from "../types";
/**

@@ -33,1 +34,13 @@ * Constant of all the error types

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;
};
{
"name": "@bzr/bazaar",
"version": "1.2.0",
"version": "1.2.1",
"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

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