New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@memberjunction/core

Package Overview
Dependencies
Maintainers
0
Versions
261
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 2.14.0 to 2.15.0

15

dist/generic/baseEntity.d.ts

@@ -170,4 +170,9 @@ import { EntityFieldInfo, EntityInfo, EntityFieldTSType, EntityPermissionType, RecordChange, ValidationResult, EntityRelationshipInfo } from './entityInfo';

private _resultHistory;
constructor(Entity: EntityInfo);
private _provider;
constructor(Entity: EntityInfo, Provider?: IEntityDataProvider | null);
/**
* Returns this provider to be used for a given instance of a BaseEntity derived subclass. If the provider is not set, the BaseEntity.Provider is returned.
*/
get ProviderToUse(): IEntityDataProvider;
/**
* This method can be used to register a callback for events that will be raised by the instance of the BaseEntity object. The callback will be called with a

@@ -399,2 +404,7 @@ * BaseEntityEvent object that contains the type of event and any payload that is associated with the event. Subclasses of the BaseEntity can define their

private static _globalProviderKey;
/**
* Static property to get/set the IEntityDataProvider that is used by all BaseEntity objects. This is a global setting that is used by all BaseEntity objects. It can be overriden for a given BaseEntity object instance by passing in a provider to the
* constructor of the BaseEntity object. Typically, a provider will pass itself into BaseEntity objects it creates to create a tight coupling between the provider and the BaseEntity objects it creates. This allows multiple concurrent
* connections to exist in the same process space without interfering with each other.
*/
static get Provider(): IEntityDataProvider;

@@ -409,6 +419,5 @@ static set Provider(value: IEntityDataProvider);

* @param entityName
* @param KeyValuePair
* @returns
*/
static GetRecordChanges(entityName: string, CompositeKey: CompositeKey): Promise<RecordChange[]>;
static GetRecordChanges(entityName: string, primaryKey: CompositeKey, provider?: IEntityDataProvider | null): Promise<RecordChange[]>;
/**

@@ -415,0 +424,0 @@ * Strongly-typed wrapper for the {@link SetMany} method.

52

dist/generic/baseEntity.js

@@ -287,3 +287,3 @@ "use strict";

class BaseEntity {
constructor(Entity) {
constructor(Entity, Provider = null) {
this._Fields = [];

@@ -294,8 +294,16 @@ this._recordLoaded = false;

this._resultHistory = [];
this._provider = null;
this._compositeKey = null;
this._eventSubject = new rxjs_1.Subject();
this._EntityInfo = Entity;
this._provider = Provider;
this.init();
}
/**
* Returns this provider to be used for a given instance of a BaseEntity derived subclass. If the provider is not set, the BaseEntity.Provider is returned.
*/
get ProviderToUse() {
return this._provider || BaseEntity.Provider;
}
/**
* This method can be used to register a callback for events that will be raised by the instance of the BaseEntity object. The callback will be called with a

@@ -342,3 +350,3 @@ * BaseEntityEvent object that contains the type of event and any payload that is associated with the event. Subclasses of the BaseEntity can define their

// this next call is to MJGlobal to let everyone who cares knows that we had an event on an entity object
// at the moment we only broadcast save/delete not the others
// at the moment we only broadcast save/delete not the others
if (type === 'save' || type === 'delete') {

@@ -585,7 +593,7 @@ const event = new BaseEntityEvent();

// pre now has the param that matches the related entity (re) that we are looking at
// we are now here because either the caller didn't provide a list of entities to include
// we are now here because either the caller didn't provide a list of entities to include
// (which means to include all of 'em), or they did and this entity is in the list
const reData = await this.GetRelatedEntityDataExt(re, pre.filter, pre.maxRecords);
if (reData) {
obj[re.RelatedEntity] = reData; // got some data (or an empty array) back, add it to the object
obj[re.RelatedEntity] = reData; // got some data (or an empty array) back, add it to the object
if (pre.maxRecords > 0) {

@@ -706,3 +714,3 @@ // add a note to the object to let the caller know that only the first X records are returned so

if (_options.IgnoreDirtyState || this.Dirty || _options.ReplayOnly) {
if (BaseEntity.Provider == null) {
if (!this.ProviderToUse) {
throw new Error('No provider set');

@@ -719,3 +727,3 @@ }

if (valResult.Success) {
const data = await BaseEntity.Provider.Save(this, this.ActiveUser, _options);
const data = await this.ProviderToUse.Save(this, this.ActiveUser, _options);
if (data) {

@@ -743,3 +751,3 @@ this.init(); // wipe out the current data to flush out the DIRTY flags, load the ID as part of this too

if (currentResultCount === this.ResultHistory.length) {
// this means that NO new results were added to the history anywhere
// this means that NO new results were added to the history anywhere
// so we need to add a new result to the history here

@@ -831,3 +839,3 @@ newResult.Success = false;

ThrowPermissionError(u, type, additionalInfoMessage) {
throw new Error(`User: ${u.Name} (ID: ${u.ID}, Email: ${u.Email})
throw new Error(`User: ${u.Name} (ID: ${u.ID}, Email: ${u.Email})
Does NOT have permission to ${entityInfo_1.EntityPermissionType[type]} ${this.EntityInfo.Name} records.

@@ -858,7 +866,6 @@ If you believe this is an error, please contact your system administrator.${additionalInfoMessage ? '\nAdditional Information: ' + additionalInfoMessage : ''}}`);

async InnerLoad(CompositeKey, EntityRelationshipsToLoad = null) {
if (BaseEntity.Provider == null) {
if (!this.ProviderToUse) {
throw new Error('No provider set');
}
else {
const start = new Date().getTime();
const valResult = CompositeKey.Validate();

@@ -871,3 +878,3 @@ if (!valResult || !valResult.IsValid)

}
const data = await BaseEntity.Provider.Load(this, CompositeKey, EntityRelationshipsToLoad, this.ActiveUser);
const data = await this.ProviderToUse.Load(this, CompositeKey, EntityRelationshipsToLoad, this.ActiveUser);
if (!data) {

@@ -932,3 +939,3 @@ (0, logging_1.LogError)(`Error in BaseEntity.Load(${this.EntityInfo.Name}, Key: ${CompositeKey.ToString()}`);

try {
if (BaseEntity.Provider == null) {
if (!this.ProviderToUse) {
throw new Error('No provider set');

@@ -938,3 +945,3 @@ }

this.CheckPermissions(entityInfo_1.EntityPermissionType.Delete, true); // this will throw an error and exit out if we don't have permission
if (await BaseEntity.Provider.Delete(this, options, this.ActiveUser)) {
if (await this.ProviderToUse.Delete(this, options, this.ActiveUser)) {
// record deleted correctly

@@ -952,3 +959,3 @@ // wipe out the current data to flush out the DIRTY flags by calling NewRecord()

if (currentResultCount === this.ResultHistory.length) {
// this means that NO new results were added to the history anywhere
// this means that NO new results were added to the history anywhere
// so we need to add a new result to the history here

@@ -979,2 +986,7 @@ newResult.Success = false;

}
/**
* Static property to get/set the IEntityDataProvider that is used by all BaseEntity objects. This is a global setting that is used by all BaseEntity objects. It can be overriden for a given BaseEntity object instance by passing in a provider to the
* constructor of the BaseEntity object. Typically, a provider will pass itself into BaseEntity objects it creates to create a tight coupling between the provider and the BaseEntity objects it creates. This allows multiple concurrent
* connections to exist in the same process space without interfering with each other.
*/
static get Provider() {

@@ -999,3 +1011,3 @@ const g = global_1.MJGlobal.Instance.GetGlobalObjectStore();

if (this.IsSaved) {
return BaseEntity.GetRecordChanges(this.EntityInfo.Name, this.PrimaryKey);
return BaseEntity.GetRecordChanges(this.EntityInfo.Name, this.PrimaryKey, this.ProviderToUse);
}

@@ -1009,11 +1021,11 @@ else {

* @param entityName
* @param KeyValuePair
* @returns
*/
static async GetRecordChanges(entityName, CompositeKey) {
if (BaseEntity.Provider === null) {
throw new Error('No provider set');
static async GetRecordChanges(entityName, primaryKey, provider = null) {
const providerToUse = provider || BaseEntity.Provider;
if (!providerToUse) {
throw new Error('No provider set or passed in');
}
else {
const results = await BaseEntity.Provider.GetRecordChanges(entityName, CompositeKey);
const results = await providerToUse.GetRecordChanges(entityName, primaryKey);
if (results) {

@@ -1020,0 +1032,0 @@ const changes = [];

@@ -109,2 +109,3 @@ "use strict";

// check to see if the MJ Core schema is already in the list, if not add it
// TODO: The logic here doesn't match the comment above
if (includeSchemaList && includeSchemaList.length > 0 && includeSchemaList.indexOf(mjcSchema) === -1)

@@ -276,3 +277,3 @@ includeSchemaList.push(mjcSchema);

try {
const newObject = global_1.MJGlobal.Instance.ClassFactory.CreateInstance(baseEntity_1.BaseEntity, entityName, entity);
const newObject = global_1.MJGlobal.Instance.ClassFactory.CreateInstance(baseEntity_1.BaseEntity, entityName, entity, this);
await newObject.Config(contextUser);

@@ -279,0 +280,0 @@ return newObject;

@@ -10,2 +10,8 @@ import { IRunQueryProvider, RunQueryResult } from './interfaces';

export declare class RunQuery {
private _provider;
/**
* Optionally, you can pass in a provider to use for running the query. If not provided, the static provider will be used.
*/
constructor(provider?: IRunQueryProvider | null);
get ProviderToUse(): IRunQueryProvider;
RunQuery(params: RunQueryParams, contextUser?: UserInfo): Promise<RunQueryResult>;

@@ -12,0 +18,0 @@ private static _globalProviderKey;

@@ -9,4 +9,13 @@ "use strict";

class RunQuery {
/**
* Optionally, you can pass in a provider to use for running the query. If not provided, the static provider will be used.
*/
constructor(provider = null) {
this._provider = provider;
}
get ProviderToUse() {
return this._provider || RunQuery.Provider;
}
async RunQuery(params, contextUser) {
return RunQuery.Provider.RunQuery(params, contextUser);
return this.ProviderToUse.RunQuery(params, contextUser);
}

@@ -13,0 +22,0 @@ static get Provider() {

@@ -10,2 +10,12 @@ import { IRunReportProvider, RunReportResult } from './interfaces';

export declare class RunReport {
private _provider;
/**
* Optionally, you can pass in a provider to use for running the report. If you dont pass in a provider, the static provider will be used.
* @param provider
*/
constructor(provider?: IRunReportProvider | null);
/**
* Returns the provider to be used for this instance, if one was passed in. Otherwise, it returns the static provider.
*/
get ProviderToUse(): IRunReportProvider;
RunReport(params: RunReportParams, contextUser?: UserInfo): Promise<RunReportResult>;

@@ -12,0 +22,0 @@ private static _globalProviderKey;

@@ -9,5 +9,17 @@ "use strict";

class RunReport {
//private static _Provider: IRunViewProvider;
/**
* Optionally, you can pass in a provider to use for running the report. If you dont pass in a provider, the static provider will be used.
* @param provider
*/
constructor(provider = null) {
this._provider = provider;
}
/**
* Returns the provider to be used for this instance, if one was passed in. Otherwise, it returns the static provider.
*/
get ProviderToUse() {
return this._provider || RunReport.Provider;
}
async RunReport(params, contextUser) {
return RunReport.Provider.RunReport(params, contextUser);
return this.ProviderToUse.RunReport(params, contextUser);
}

@@ -14,0 +26,0 @@ static get Provider() {

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

const metadata_1 = require("./generic/metadata");
const runQuery_1 = require("./generic/runQuery");
const runReport_1 = require("./generic/runReport");

@@ -45,4 +46,5 @@ const runView_1 = require("./views/runView");

runReport_1.RunReport.Provider = provider;
runQuery_1.RunQuery.Provider = provider;
}
exports.SetProvider = SetProvider;
//# sourceMappingURL=index.js.map

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

import { IRunViewProvider, RunViewResult } from '../generic/interfaces';
import { IMetadataProvider, IRunViewProvider, RunViewResult } from '../generic/interfaces';
import { UserInfo } from '../generic/securityInfo';

@@ -107,6 +107,18 @@ import { BaseEntity } from '../generic/baseEntity';

* Class for running views in a generic, tier-independent manner - uses a provider model for
* implementation transparently from the viewpoint of the consumer of the class.
* implementation transparently from the viewpoint of the consumer of the class. By default the RunView class you create will
* connect to the DEFAULT provider. If you want your RunView to connect to a different provider, you can pass in the provider
* to the constructor.
*/
export declare class RunView {
private _provider;
/**
* Optionally, you can pass in a provider to the constructor. If you do not, the static RunView.Provider property is used.
* @param Provider
*/
constructor(Provider?: IRunViewProvider | null);
/**
* This property is used to get the IRunViewProvider implementation that is used by this instance of the RunView class. If a provider was specified to the constructor, that provider is used, otherwise the static RunView.Provider property is used.
*/
get ProviderToUse(): IRunViewProvider;
/**
* Runs a view based on the provided parameters, see documentation for RunViewParams for more

@@ -127,2 +139,6 @@ * @param params

private static _globalProviderKey;
/**
* This is the static provider property that is used to get/set the IRunViewProvider implementation that is used by the RunView class.
* This property can be overridden on a per-instance basis by passing in the optional Provider parameter to the RunView constructor.
*/
static get Provider(): IRunViewProvider;

@@ -135,4 +151,4 @@ static set Provider(value: IRunViewProvider);

*/
static GetEntityNameFromRunViewParams(params: RunViewParams): Promise<string>;
static GetEntityNameFromRunViewParams(params: RunViewParams, provider?: IMetadataProvider | null): Promise<string>;
}
//# sourceMappingURL=runView.d.ts.map

@@ -5,9 +5,25 @@ "use strict";

const global_1 = require("@memberjunction/global");
const metadata_1 = require("../generic/metadata");
/**
* Class for running views in a generic, tier-independent manner - uses a provider model for
* implementation transparently from the viewpoint of the consumer of the class.
* implementation transparently from the viewpoint of the consumer of the class. By default the RunView class you create will
* connect to the DEFAULT provider. If you want your RunView to connect to a different provider, you can pass in the provider
* to the constructor.
*/
class RunView {
/**
* Optionally, you can pass in a provider to the constructor. If you do not, the static RunView.Provider property is used.
* @param Provider
*/
constructor(Provider = null) {
this._provider = null;
if (Provider)
this._provider = Provider;
}
/**
* This property is used to get the IRunViewProvider implementation that is used by this instance of the RunView class. If a provider was specified to the constructor, that provider is used, otherwise the static RunView.Provider property is used.
*/
get ProviderToUse() {
return this._provider || RunView.Provider;
}
/**
* Runs a view based on the provided parameters, see documentation for RunViewParams for more

@@ -23,4 +39,4 @@ * @param params

// we need to get the entity definition and then get all the fields for it
const md = new metadata_1.Metadata();
const entity = md.Entities.find(e => e.Name.trim().toLowerCase() === params.EntityName.trim().toLowerCase());
const p = this.ProviderToUse;
const entity = p.Entities.find(e => e.Name.trim().toLowerCase() === params.EntityName.trim().toLowerCase());
if (!entity)

@@ -31,3 +47,3 @@ throw new Error(`Entity ${params.EntityName} not found in metadata`);

// Run the view
const result = await RunView.Provider.RunView(params, contextUser);
const result = await this.ProviderToUse.RunView(params, contextUser);
// Transform the result set into BaseEntity-derived objects, if needed

@@ -45,3 +61,3 @@ await this.TransformSimpleObjectToEntityObject(params, result, contextUser);

if (params && params.length > 0) {
const md = new metadata_1.Metadata();
const p = this.ProviderToUse;
for (const param of params) {

@@ -52,3 +68,3 @@ // FIRST, if the resultType is entity_object, we need to run the view with ALL fields in the entity

// we need to get the entity definition and then get all the fields for it
const entity = md.Entities.find(e => e.Name.trim().toLowerCase() === param.EntityName.trim().toLowerCase());
const entity = p.Entities.find(e => e.Name.trim().toLowerCase() === param.EntityName.trim().toLowerCase());
if (!entity) {

@@ -61,3 +77,3 @@ throw new Error(`Entity ${param.EntityName} not found in metadata`);

// NOW, run the view
const results = await RunView.Provider.RunViews(params, contextUser);
const results = await this.ProviderToUse.RunViews(params, contextUser);
for (const [index, result] of results.entries()) {

@@ -76,6 +92,6 @@ await this.TransformSimpleObjectToEntityObject(params[index], result, contextUser);

// we need to transform each of the items in the result set into a BaseEntity-derived object
const md = new metadata_1.Metadata();
const p = this.ProviderToUse;
const newItems = [];
for (const item of result.Results) {
const entity = await md.GetEntityObject(param.EntityName, contextUser);
const entity = await p.GetEntityObject(param.EntityName, contextUser);
entity.LoadFromData(item);

@@ -87,2 +103,6 @@ newItems.push(entity);

}
/**
* This is the static provider property that is used to get/set the IRunViewProvider implementation that is used by the RunView class.
* This property can be overridden on a per-instance basis by passing in the optional Provider parameter to the RunView constructor.
*/
static get Provider() {

@@ -107,3 +127,4 @@ const g = global_1.MJGlobal.Instance.GetGlobalObjectStore();

*/
static async GetEntityNameFromRunViewParams(params) {
static async GetEntityNameFromRunViewParams(params, provider = null) {
const p = provider ? provider : RunView.Provider;
if (params.EntityName)

@@ -113,4 +134,3 @@ return params.EntityName;

const entityID = params.ViewEntity.Get('EntityID'); // using weak typing because this is MJCore and we don't want to use the sub-classes from core-entities as that would create a circular dependency
const md = new metadata_1.Metadata();
const entity = md.Entities.find(e => e.ID === entityID);
const entity = p.Entities.find(e => e.ID === entityID);
if (entity)

@@ -121,3 +141,3 @@ return entity.Name;

// we don't have a view entity loaded, so load it up now
const rv = new RunView();
const rv = new RunView(p);
const result = await rv.RunView({

@@ -124,0 +144,0 @@ EntityName: "User Views",

{
"name": "@memberjunction/core",
"version": "2.14.0",
"version": "2.15.0",
"description": "MemberJunction: Core Library including Metadata, Application, Entity Retrieval and Manipulation, and Utilities",

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

"dependencies": {
"@memberjunction/global": "2.14.0",
"@memberjunction/global": "2.15.0",
"rxjs": "^7.8.1",

@@ -25,0 +25,0 @@ "zod": "^3.23.8"

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

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

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