Socket
Socket
Sign inDemoInstall

@memberjunction/core

Package Overview
Dependencies
Maintainers
4
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@memberjunction/core - npm Package Compare versions

Comparing version 1.7.0 to 1.7.1

19

dist/generic/baseEntity.d.ts

@@ -135,3 +135,6 @@ import { EntityFieldInfo, EntityInfo, EntityFieldTSType, EntityPermissionType, RecordChange, ValidationResult, EntityRelationshipInfo } from './entityInfo';

export declare class BaseEntityEvent {
type: 'new_record' | 'save' | 'delete' | 'other';
/**
* The type of event that is being raised. transaction_ready is used to indicate that a transaction is ready to be submitted for execution. The TransactionGroup class uses this to know that all async preprocessing is done and it can now submit the transaction.
*/
type: 'new_record' | 'save' | 'delete' | 'transaction_ready' | 'other';
payload: any;

@@ -161,5 +164,17 @@ baseEntity: BaseEntity;

/**
* If the entity object has a TransactionGroup associated with it, the TransactionGroup will be notified that we are doing some transaction pre-processing so that the TransactionGroup can
* properly wait for those pre-processing steps to complete before submitting the transaction. This method should generally NOT be called by anyone other than a provider that is handling
* the tier-specific processing for the entity object.
*/
RegisterTransactionPreprocessing(): void;
/**
* Raises the transaction_ready event. This is used to indicate that the entity object is ready to be submitted for transaction processing. This is used by the TransactionGroup class to know when all async preprocessing is
* done and it can submit the transaction. This is an internal method and shouldn't be used by sub-classes or external callers in most cases. It is primarily used by Provider classes who are handling the tier-specific processing
* for the entity object.
*/
RaiseReadyForTransaction(): void;
/**
* Used for raising events within the BaseEntity and can be used by sub-classes to raise events that are specific to the entity.
*/
protected RaiseEvent(type: 'new_record' | 'save' | 'delete' | 'other', payload: any): void;
protected RaiseEvent(type: 'new_record' | 'save' | 'delete' | 'transaction_ready' | 'other', payload: any): void;
/**

@@ -166,0 +181,0 @@ * This method MUST be called right after the class is instantiated to provide an async/await pair for any asynchronous operations a given entity needs to do when it is first

@@ -283,2 +283,20 @@ "use strict";

/**
* If the entity object has a TransactionGroup associated with it, the TransactionGroup will be notified that we are doing some transaction pre-processing so that the TransactionGroup can
* properly wait for those pre-processing steps to complete before submitting the transaction. This method should generally NOT be called by anyone other than a provider that is handling
* the tier-specific processing for the entity object.
*/
RegisterTransactionPreprocessing() {
if (this.TransactionGroup) {
this.TransactionGroup.RegisterPreprocessing(this);
}
}
/**
* Raises the transaction_ready event. This is used to indicate that the entity object is ready to be submitted for transaction processing. This is used by the TransactionGroup class to know when all async preprocessing is
* done and it can submit the transaction. This is an internal method and shouldn't be used by sub-classes or external callers in most cases. It is primarily used by Provider classes who are handling the tier-specific processing
* for the entity object.
*/
RaiseReadyForTransaction() {
this.RaiseEvent('transaction_ready', null);
}
/**
* Used for raising events within the BaseEntity and can be used by sub-classes to raise events that are specific to the entity.

@@ -285,0 +303,0 @@ */

@@ -31,2 +31,11 @@ import { BaseEntity } from "./baseEntity";

/**
* Used internally within the transaction group to manage the preprocessing of entities before a transaction is submitted
*/
export declare class TransactionPreprocessingItem {
entity: BaseEntity;
complete: boolean;
completionPromise: Promise<void>;
constructor(entity: BaseEntity, completionPromise: Promise<void>);
}
/**
* TransactionGroup is a class that handles the bundling of multiple transactions into a single request. The provider handles

@@ -49,3 +58,20 @@ * the implementation details. If a transaction group is provided to the baseEntity object before either Save() or Delete() is called

protected PendingTransactions(): TransactionItem[];
private _preprocessingItems;
/**
* If an entity object needs to conduct any type of asynchronous preprocessing before a transaction is submitted, it must notify its transaction group
* that it is doing so with this method. This causes the TransactionGroup to wait for all preprocessing to be completed before submitting the transaction.
* This method checks to see if an the entity has already been registered for preprocessing and if so, does nothing.
* @param entity
*/
RegisterPreprocessing(entity: BaseEntity): void;
/**
* Indicates whether all of the entities that have registered with this transaction group have completed their preprocessing
* @returns
*/
PreprocessingComplete(): boolean;
/**
* Waits for all preprocessing to be complete.
*/
protected waitForPreprocessing(): Promise<void>;
/**
* This is used by the BaseEntity/Provider objects to manage transactions on your behalf. Do not directly interact with this method. Instead use the TransactionGroup property on

@@ -52,0 +78,0 @@ * the @BaseEntity class to make an entity object part of a transaction group.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionGroupBase = exports.TransactionResult = exports.TransactionItem = void 0;
exports.TransactionGroupBase = exports.TransactionPreprocessingItem = exports.TransactionResult = exports.TransactionItem = void 0;
const logging_1 = require("./logging");
/**

@@ -44,2 +45,13 @@ * Internal class used by TransactionGroupBase and sub-classes to manage individual transactions

/**
* Used internally within the transaction group to manage the preprocessing of entities before a transaction is submitted
*/
class TransactionPreprocessingItem {
constructor(entity, completionPromise) {
this.complete = false;
this.entity = entity;
this.completionPromise = completionPromise;
}
}
exports.TransactionPreprocessingItem = TransactionPreprocessingItem;
/**
* TransactionGroup is a class that handles the bundling of multiple transactions into a single request. The provider handles

@@ -62,2 +74,3 @@ * the implementation details. If a transaction group is provided to the baseEntity object before either Save() or Delete() is called

this._pendingTransactions = [];
this._preprocessingItems = [];
}

@@ -68,2 +81,48 @@ PendingTransactions() {

/**
* If an entity object needs to conduct any type of asynchronous preprocessing before a transaction is submitted, it must notify its transaction group
* that it is doing so with this method. This causes the TransactionGroup to wait for all preprocessing to be completed before submitting the transaction.
* This method checks to see if an the entity has already been registered for preprocessing and if so, does nothing.
* @param entity
*/
RegisterPreprocessing(entity) {
const existingEntry = this._preprocessingItems.find((i) => i.entity === entity);
if (!existingEntry) {
const preprocessingPromise = new Promise((resolve) => {
entity.RegisterEventHandler((e) => {
if (e.type === 'transaction_ready' && e.baseEntity === entity) {
const found = this._preprocessingItems.find((i) => i.entity === entity);
if (found) {
found.complete = true;
resolve();
}
}
});
});
const newItem = new TransactionPreprocessingItem(entity, preprocessingPromise);
this._preprocessingItems.push(newItem);
}
}
/**
* Indicates whether all of the entities that have registered with this transaction group have completed their preprocessing
* @returns
*/
PreprocessingComplete() {
if (this._preprocessingItems.length === 0)
return true;
else
return this._preprocessingItems.every((i) => i.complete);
}
/**
* Waits for all preprocessing to be complete.
*/
async waitForPreprocessing() {
try {
await Promise.all(this._preprocessingItems.map(item => item.completionPromise));
this._preprocessingItems = []; // clear out the preprocessing items
}
catch (e) {
(0, logging_1.LogError)(`Error during preprocessing TransactionGroupBase. Error: ${e.message}`);
}
}
/**
* This is used by the BaseEntity/Provider objects to manage transactions on your behalf. Do not directly interact with this method. Instead use the TransactionGroup property on

@@ -83,2 +142,4 @@ * the @BaseEntity class to make an entity object part of a transaction group.

try {
// Wait for all preprocessing to be complete
await this.waitForPreprocessing();
if (this._pendingTransactions.length > 0) {

@@ -85,0 +146,0 @@ // subclass handles the actual submit implementation whatever that does

4

package.json
{
"name": "@memberjunction/core",
"version": "1.7.0",
"version": "1.7.1",
"description": "MemberJunction: Core Library including Metadata, Application, Entity Retrieval and Manipulation, and Utilities",

@@ -22,5 +22,5 @@ "main": "dist/index.js",

"dependencies": {
"@memberjunction/global": "1.7.0",
"@memberjunction/global": "1.7.1",
"rxjs": "^7.8.1"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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