Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@edenjs/audit

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edenjs/audit - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

71

bundles/audit/controllers/admin.js

@@ -72,3 +72,3 @@ /**

name : 'Audits',
grid : await this._grid(req).render(fauxReq),
grid : await (await this._grid(req)).render(fauxReq),
class : blockModel.get('class') || null,

@@ -113,3 +113,3 @@ title : blockModel.get('title') || '',

res.render('audit/admin', {
grid : await this._grid(req).render(req),
grid : await (await this._grid(req)).render(req),
});

@@ -303,5 +303,5 @@ }

*/
gridAction(req, res) {
async gridAction(req, res) {
// Return post grid request
return this._grid(req).post(req, res);
return (await this._grid(req)).post(req, res);
}

@@ -316,3 +316,3 @@

*/
_grid(req) {
async _grid(req) {
// Create new grid

@@ -334,35 +334,54 @@ const auditGrid = new Grid();

},
}).column('subject', {
sort : true,
title : 'Subject',
format : async (col, row) => {
return `${row.get('subject.model')} #${row.get('subject.id')}${col ? '' : ' <i>Removed</i>'}`;
},
}).column('by', {
sort : true,
title : 'By',
format : async (col, row) => {
// return name
return col ? `<a href="/admin/user/${col.get('_id').toString()}/update">${col.name()}</a>` : `user #${row.get('by.id')} <i>Removed</i>`;
},
}).column('updates', {
sort : true,
title : 'Updates',
format : async (col, row) => {
// return name
return col && Object.keys(col || {}).length ? Object.keys(col || {}).join(', ') : '<i>N/A</i>';
},
});
// audit fields
config.get('audit.fields').slice(0).filter(field => field.grid).forEach((field) => {
// get form
const form = await formHelper.get('edenjs.audit');
// branch fields
await Promise.all((form.get('_id') ? form.get('fields') : config.get('audit.fields').slice(0)).map(async (field, i) => {
// set found
const found = config.get('audit.fields').find(f => f.name === field.name);
// add config field
auditGrid.column(field.name, {
sort : true,
title : field.label,
format : field.format ? field.format : (col) => {
return col ? col.toString() : '<i>N/A</i>';
},
});
});
if (found.grid) {
// add column
await formHelper.column(req, form, auditGrid, field, {
priority : 100 - i,
});
}
}));
auditGrid.column('updated_at', {
tag : 'grid-date',
sort : true,
title : 'Updated',
format : (col) => {
return col.toLocaleDateString('en-GB', {
day : 'numeric',
month : 'short',
year : 'numeric',
});
return col.toISOString();
},
}).column('created_at', {
tag : 'grid-date',
sort : true,
title : 'Created',
format : (col) => {
return col.toLocaleDateString('en-GB', {
day : 'numeric',
month : 'short',
year : 'numeric',
});
return col.toISOString();
},

@@ -401,3 +420,3 @@ })

// Set default sort order
auditGrid.sort('created_at', 1);
auditGrid.sort('created_at', -1);

@@ -404,0 +423,0 @@ // Return grid

@@ -26,3 +26,3 @@

// get audit models
const models = (config.get('audit.models') || Object.keys(cache('models'))).filter((m) => m !== 'audit');
const models = (config.get('audit.models') || Object.keys(cache('models'))).filter(m => m !== 'audit');

@@ -40,3 +40,2 @@ // add hook

const createMonitor = (way, type) => {
// return function

@@ -51,3 +50,3 @@ return (subject, { by, updates }) => {

updates : {},
message : `${(way === 'create' ? 'Created' : (way === 'update' ? 'Updated' : 'Removed'))} ${subject.constructor.name}`
message : `${(way === 'create' ? 'Created' : (way === 'update' ? 'Updated' : 'Removed'))} ${subject.constructor.name}`,
});

@@ -77,3 +76,2 @@

});
}

@@ -80,0 +78,0 @@ }

@@ -9,41 +9,11 @@ // create config object

name : 'by',
grid : true,
grid : false,
type : 'user',
label : 'By',
format : (col) => {
// return name
return col ? `<a href="/admin/user/${col.get('_id').toString()}/update">${col.name()}</a>` : '<i>N/A</i>';
},
filter : async (param, grid) => {
// require dependencies
const User = model('user');
const escapeRegex = require('escape-string-regexp');
// get users
const users = await User.or({
username : new RegExp(escapeRegex(param.toString().toLowerCase()), 'i'),
}, {
email : new RegExp(escapeRegex(param.toString().toLowerCase()), 'i'),
}).find();
// map user
grid.in('by.id', users.map(user => user.get('_id').toString()));
},
},
{
name : 'subject',
grid : true,
grid : false,
type : 'text',
label : 'Subject',
format : (col) => {
// return name
return col ? `${col.constructor.name} #${col.get('_id').toString()}` : '<i>N/A</i>';
},
filter : async (param, grid) => {
// require dependencies
const escapeRegex = require('escape-string-regexp');
// map user
grid.match('subject.id', new RegExp(escapeRegex(param.toString().toLowerCase()), 'i'));
},
},

@@ -63,13 +33,6 @@ {

{
name : 'message',
grid : true,
type : 'text',
label : 'Message',
format : (col, row) => {
// add append
const append = row.get('way') === 'update' ? ` fields "${Object.keys(row.get('updates')).join(', ')}"` : '';
// return name
return col ? `${col.toString()}${append}` : '<i>N/A</i>';
},
name : 'message',
grid : true,
type : 'text',
label : 'Message',
},

@@ -76,0 +39,0 @@ ],

{
"name": "@edenjs/audit",
"description": "nothing yet",
"version": "1.0.1",
"version": "1.0.2",
"dependencies": {},

@@ -6,0 +6,0 @@ "engines": {

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