Skip to content

Commit

Permalink
Merge pull request #91 from ExWeiv/dev
Browse files Browse the repository at this point in the history
BUG Fixes for Sync Plug-in
  • Loading branch information
loeiks authored Jul 18, 2024
2 parents 6fcd59b + 05a906f commit 6ad8d90
Show file tree
Hide file tree
Showing 119 changed files with 406 additions and 448 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ In this file you can find what's changed in each version. (Versions with -dev, -

---

### 4.5.1

- BUG Fixes and TS type fixes. For Wix Members sync plug-in.

### 4.5.0

- New plug-in, sync Wix Members collection into your MongoDB databae to perform lookups easily with your own custom collections.
Expand Down
4 changes: 2 additions & 2 deletions app/lib/Apps/wix_members.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function onMemberUpdated(event) {
(0, error_manager_1.kaptanLogar)("00024", "You didn't configure any database name to sync Wix apps data!");
}
const { readyFullData, readyPrivateData, readyPublicData } = await getMemberData(memberId);
const find = { "entityId": memberId };
const find = { "entityId": { $eq: memberId } };
Promise.all([
(await (0, native_1.native)(`${syncDatabase}/WixMembersPublicData`, true)).updateOne(find, readyPublicData, { retryWrites: true }),
(await (0, native_1.native)(`${syncDatabase}/WixMembersPrivateData`, true)).updateOne(find, readyPrivateData, { retryWrites: true }),
Expand All @@ -70,7 +70,7 @@ async function onMemberDeleted(event) {
if (!syncDatabase) {
(0, error_manager_1.kaptanLogar)("00024", "You didn't configure any database name to sync Wix apps data!");
}
const find = { "entityId": memberId };
const find = { "entityId": { $eq: memberId } };
Promise.all([
(await (0, native_1.native)(`${syncDatabase}/WixMembersPublicData`, true)).deleteMany(find, { retryWrites: true }),
(await (0, native_1.native)(`${syncDatabase}/WixMembersPrivateData`, true)).deleteMany(find, { retryWrites: true }),
Expand Down
4 changes: 2 additions & 2 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@exweiv/weiv-data",
"version": "4.5.0",
"version": "4.5.1",
"description": "Custom API Library for Wix sites to connect MongoDB. Designed to easily switch from wix-data APIs.",
"main": "./lib/index.js",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions app/src/Apps/wix_members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function onMemberUpdated(event: Document): Promise<void> {
}

const { readyFullData, readyPrivateData, readyPublicData } = await getMemberData(memberId);
const find = { "entityId": memberId };
const find = { "entityId": { $eq: memberId } };

// Insert to MongoDB (fire and forget)
Promise.all([
Expand Down Expand Up @@ -88,7 +88,7 @@ export async function onMemberDeleted(event: Document): Promise<void> {
kaptanLogar("00024", "You didn't configure any database name to sync Wix apps data!");
}

const find = { "entityId": memberId };
const find = { "entityId": { $eq: memberId } };

// Insert to MongoDB (fire and forget)
Promise.all([
Expand Down
103 changes: 50 additions & 53 deletions app/weivdata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,12 @@ declare module '@exweiv/weiv-data' {
*/
config: () => CustomOptions.WeivDataConfig;
}

/**@internal */
const WeivDataConfig: WeivDataConfig;

/**@internal */
const ConnectionOptions: ConnectionOptions;
}

namespace Errors {
Expand Down Expand Up @@ -2161,62 +2167,53 @@ declare module '@exweiv/weiv-data' {
}

/**
* @Plugin
* @description
*
* Plugins are helper functions/features.
* This plugin helps you to sync Wix application collections directly with your MongoDB database, in this way you can perform lookup operations easily.
*
* > Currently this feature is experimental and BUG fixes will be added in the future. And right now only available app is Wix Members.
*
* ### How it Works?
*
* For specific tasks you have pre-built functions that you can use to sync Wix app collections. For example for Wix Members you have created, updated and deleted events where you define it inside the events.js file.
* In this events.js file you will define these events but you will use pre-built functions from WeivData library to sync the data.
*
* Example code:
* ```js
* import { SyncWixApps } from '@exweiv/weiv-data';
* const { wixMembers } = SyncWixApps;
*
* export const wixMembers_onMemberCreated = (event) => wixMembers.onMemberCreated(event);
* ```
*
* In the example code above you can understand how it works with a single line of code. You can also add your own logic like this:
*
* ```js
* import { SyncWixApps } from '@exweiv/weiv-data';
* const { wixMembers } = SyncWixApps;
*
* export const wixMembers_onMemberCreated = (event) => {
* // Sync Data (no await needed because sync functions are void and doesn't return any value)
* wixMembers.onMemberCreated(event);
*
* // Your Own Logic
* }
* ```
*
* ### Logs of Sync Errors
*
* In case of an error you can find logs in `WeivDataWixAppsSyncLogs` database in your MongoDB cluster. In this database you will have multiple collections to collect logs about each individual application.
* You can find error logs and it's details there. Plugin only save unexpected error logs not any other logs.
*/
namespace Plugins {

/**
* @description
*
* This plugin helps you to sync Wix application collections directly with your MongoDB database, in this way you can perform lookup operations easily.
*
* > Currently this feature is experimental and BUG fixes will be added in the future. And right now only available app is Wix Members.
*
* ### How it Works?
*
* For specific tasks you have pre-built functions that you can use to sync Wix app collections. For example for Wix Members you have created, updated and deleted events where you define it inside the events.js file.
* In this events.js file you will define these events but you will use pre-built functions from WeivData library to sync the data.
*
* Example code:
* ```js
* import { SyncWixApps } from '@exweiv/weiv-data';
* const { wixMembers } = SyncWixApps;
*
* export const wixMembers_onMemberCreated = (event) => wixMembers.onMemberCreated(event);
* ```
*
* In the example code above you can understand how it works with a single line of code. You can also add your own logic like this:
*
* ```js
* import { SyncWixApps } from '@exweiv/weiv-data';
* const { wixMembers } = SyncWixApps;
*
* export const wixMembers_onMemberCreated = (event) => {
* // Sync Data (no await needed because sync functions are void and doesn't return any value)
* wixMembers.onMemberCreated(event);
*
* // Your Own Logic
* }
* ```
*
* ### Logs of Sync Errors
*
* In case of an error you can find logs in `WeivDataWixAppsSyncLogs` database in your MongoDB cluster. In this database you will have multiple collections to collect logs about each individual application.
* You can find error logs and it's details there. Plugin only save unexpected error logs not any other logs.
*/
namespace SyncWixApps {
/**
* @description
*
* Includes functions to sync Wix Members collections.
*/
interface wixMembers {
onMemberCreated: Function
onMemberUpdated: Function
onMemberDeleted: Function
}
namespace SyncWixApps {
interface wixMembers {
onMemberCreated(event: any): void;
onMemberUpdated(event: any): void;
onMemberDeleted(event: any): void;
}

/**@internal */
const wixMembers: wixMembers;
}
}
2 changes: 1 addition & 1 deletion docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6ad8d90

Please sign in to comment.