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

@memberjunction/core-entities

Package Overview
Dependencies
Maintainers
0
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@memberjunction/core-entities - npm Package Compare versions

Comparing version 2.8.0 to 2.9.0

dist/custom/ResourcePermissions/ResourcePermissionSubclass.d.ts

10

dist/custom/ResourcePermissions/ResourcePermissionEngine.d.ts

@@ -52,3 +52,13 @@ import { BaseEngine, UserInfo } from "@memberjunction/core";

GetUserAvailableResources(user: UserInfo, ResourceTypeID?: string): ResourcePermissionEntity[];
/**
* This method will use the MJ metadata to find the fields names for the fields that represent the OwnerID and the Name of the resource in the given resource type.
* Often, these fields are simply named OwnerID and Name in the underlying entity that represents the resource, but this method uses metadata lookups to find the first
* foreign key to the Users entity from the resource type's entity and looks for the field that is consider the "Name Field" for the entity and returns those values.
*/
GetResourceTypeInfoFields(ResourceTypeID: string): {
OwnerIDFieldName: string;
NameFieldName: string;
PrimaryKeyFieldName: string;
};
}
//# sourceMappingURL=ResourcePermissionEngine.d.ts.map

@@ -139,4 +139,28 @@ "use strict";

}
/**
* This method will use the MJ metadata to find the fields names for the fields that represent the OwnerID and the Name of the resource in the given resource type.
* Often, these fields are simply named OwnerID and Name in the underlying entity that represents the resource, but this method uses metadata lookups to find the first
* foreign key to the Users entity from the resource type's entity and looks for the field that is consider the "Name Field" for the entity and returns those values.
*/
GetResourceTypeInfoFields(ResourceTypeID) {
const md = new core_1.Metadata();
const rt = this.ResourceTypes.find((rt) => rt.ID === ResourceTypeID);
if (!rt)
throw new Error(`Resource Type ${ResourceTypeID} not found`);
const entity = md.EntityByID(rt.EntityID);
if (!entity)
throw new Error(`Entity ${rt.EntityID} not found`);
const usersEntity = md.EntityByName('Users');
if (!usersEntity)
throw new Error(`Entity Users not found`);
const ownerIDField = entity.Fields.find((f) => f.RelatedEntityID === usersEntity.ID);
const nameField = entity.NameField;
return {
OwnerIDFieldName: ownerIDField?.Name,
NameFieldName: nameField?.Name,
PrimaryKeyFieldName: entity.FirstPrimaryKey.Name
};
}
}
exports.ResourcePermissionEngine = ResourcePermissionEngine;
//# sourceMappingURL=ResourcePermissionEngine.js.map

@@ -42,2 +42,8 @@ import { BaseInfo, EntityInfo, EntityFieldInfo, UserInfo, EntitySaveOptions } from "@memberjunction/core";

/**
* This property determines if the specified user can view the view at all.
*/
get UserCanView(): boolean;
private CalculateUserCanView;
private _cachedCanUserView;
/**
* This property determines if the specified user can delete the view object. All of the below assumes the user has base Delete permissions on the "User Views" entity.

@@ -44,0 +50,0 @@ * The flow of the logic is:

30

dist/custom/UserViewEntity.js

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

this._cachedCanUserEdit = null;
this._cachedCanUserView = null;
this._cachedUserCanDelete = null;

@@ -133,2 +134,29 @@ this._ViewResourceTypeID = null;

/**
* This property determines if the specified user can view the view at all.
*/
get UserCanView() {
if (this._cachedCanUserView === null) {
this._cachedCanUserView = this.CalculateUserCanView();
}
return this._cachedCanUserView;
}
CalculateUserCanView() {
const md = new core_1.Metadata();
const bOwner = this.UserID === md.CurrentUser.ID;
if (bOwner) {
return true;
}
else {
// not the owner, let's see if the user has permissions or not
const rt = ResourcePermissionEngine_1.ResourcePermissionEngine.Instance.ResourceTypes.find((rt) => rt.Name === 'User Views');
if (!rt)
throw new Error('Resource Type User Views not found');
const permLevel = ResourcePermissionEngine_1.ResourcePermissionEngine.Instance.GetUserResourcePermissionLevel(rt.ID, this.ID, md.CurrentUser);
if (permLevel) // any permission level allows view access
return true;
else // perm level not found so return false
return false;
}
}
/**
* This property determines if the specified user can delete the view object. All of the below assumes the user has base Delete permissions on the "User Views" entity.

@@ -250,3 +278,3 @@ * The flow of the logic is:

// now call our superclass to do the actual save()
if (super.Save(options)) {
if (await super.Save(options)) {
this.ResetCachedCanUserSettings();

@@ -253,0 +281,0 @@ return true;

@@ -9,2 +9,3 @@ export * from './generated/entity_subclasses';

export * from './custom/ResourcePermissions/ResourcePermissionEngine';
export * from './custom/ResourcePermissions/ResourcePermissionSubclass';
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./custom/ResourcePermissions/ResourcePermissionEngine"), exports);
__exportStar(require("./custom/ResourcePermissions/ResourcePermissionSubclass"), exports);
//# sourceMappingURL=index.js.map

6

package.json
{
"name": "@memberjunction/core-entities",
"version": "2.8.0",
"version": "2.9.0",
"description": "Entity subclasses for the metadata layer of MemberJunction defined in the MJ_CORE schema (usually 'admin'), distributed as part of each release of MemberJunction",

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

"dependencies": {
"@memberjunction/core": "2.8.0",
"@memberjunction/global": "2.8.0",
"@memberjunction/core": "2.9.0",
"@memberjunction/global": "2.9.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 too big to display

Sorry, the diff of this file is not supported yet

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

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