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

@rss/common

Package Overview
Dependencies
Maintainers
1
Versions
895
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rss/common - npm Package Compare versions

Comparing version 0.0.16 to 0.0.18

dist/model/chemical/inventory-reference.js

15

dist/helper/permission.helper.js

@@ -48,2 +48,10 @@ 'use strict';

module.exports.hasWriteAccessToInventory = function (inventoryId, user) {
return module.exports.isChemAdmin(user.campusCode, user) || (user.inventories || [{}]).filter(function (inventory) {
return inventory && inventory._id === inventoryId;
}).some(function (group) {
return group.roles.includes(ROLES.RESPONSIBLE_PERSON) || group.roles.includes(ROLES.DELEGATE) || group.roles.includes(ROLES.LAB_MANAGER);
});
};
module.exports.hasWriteAccessToGroupOwner = function (groupOwnerId, user) {

@@ -73,5 +81,6 @@ return module.exports.isChemAdmin(user.campusCode, user) || user.groups.filter(function (group) {

module.exports.hasWriteAccessToContainer = function (container, user) {
return user.groups.map(function (group) {
return group.id;
}).includes(container.group.id) || module.exports.isChemAdmin(container.group.owner.campusCode, user);
return (user.inventories || [{}]).map(function (inventory) {
return inventory._id;
}).includes(container.inventory._id) || // TODO: should use user.inventories
module.exports.isChemAdmin(container.inventory.campusCode, user);
};

@@ -78,0 +87,0 @@

12

dist/model/chemical/checkout.js

@@ -10,3 +10,3 @@ 'use strict';

var GroupReference = require('../core/group-reference');
var InventoryReference = require('./inventory-reference');
var PersonReference = require('../core/person-reference');

@@ -19,3 +19,3 @@

this.to = null;
this.group = null;
this.inventory = null;
this.status = null;

@@ -33,3 +33,3 @@ this.date = null;

this.to = new PersonReference(opt.to);
this.group = new GroupReference(opt.group);
this.inventory = new InventoryReference(opt.inventory);
this.status = opt.status;

@@ -48,7 +48,7 @@ this.date = opt.date ? new Date(opt.date) : new Date();

to: { type: ['object', 'null'] },
group: { type: ['object', 'null'] },
inventory: { type: ['object', 'null'] },
status: { type: ['string', 'null'] },
date: { type: ['object', 'null'] }
},
required: ['to', 'group', 'status', 'date']
required: ['to', 'inventory', 'status', 'date']
};

@@ -61,5 +61,5 @@ }

tv4.addSchema(GroupReference.schema());
tv4.addSchema(InventoryReference.schema());
tv4.addSchema(PersonReference.schema());
module.exports = Checkout;

@@ -14,3 +14,3 @@ 'use strict';

var FamilyReference = require('./family-reference');
var GroupReference = require('../core/group-reference');
var InventoryReference = require('./inventory-reference');
var Location = require('../core/location');

@@ -31,3 +31,3 @@

this.family = null;
this.group = null;
this.inventory = null;
this.location = null;

@@ -70,3 +70,3 @@ this.size = null;

this.family = new FamilyReference(opt.family);
this.group = new GroupReference(opt.group);
this.inventory = new InventoryReference(opt.inventory);
this.location = opt.location ? new Location(opt.location) : null;

@@ -107,3 +107,3 @@ this.size = opt.size ? parseFloat(opt.size, 10) : null;

value: function validate() {
var barcodePattern = Helper.getBarcodePattern(this.group.owner);
var barcodePattern = Helper.getBarcodePattern(this.inventory);
return tv4.validateMultiple(this, Container.schema(barcodePattern));

@@ -150,3 +150,3 @@ }

family: { $ref: 'family-reference.schema.json' },
group: { $ref: 'group-reference.schema.json' },
inventory: { $ref: 'inventory-reference.schema.json' },
location: { $ref: 'location.schema.json' },

@@ -179,6 +179,6 @@ size: { type: 'number' },

concentrationUnits: { type: ['string', 'null'] },
checkout: { anyOf: [{ type: ['null'] }, { $ref: 'checkout.schema.json' }] }
checkout: { anyOf: [{ $ref: 'checkout.schema.json' }, { type: ['null'] }] }
},
required: Object.keys(this)
required: Object.keys(new Container())
};

@@ -192,3 +192,3 @@ }

tv4.addSchema(FamilyReference.schema());
tv4.addSchema(GroupReference.schema());
tv4.addSchema(InventoryReference.schema());
tv4.addSchema(Location.schema());

@@ -195,0 +195,0 @@ tv4.addSchema(Checkout.schema());

@@ -21,3 +21,3 @@ 'use strict';

this.familyId = null;
this.groupId = null;
this.inventoryId = null;

@@ -36,3 +36,3 @@ if (opt) {

this.familyId = new ObjectId(opt.familyId);
this.groupId = opt.groupId;
this.inventoryId = new ObjectId(opt.inventoryId) || '';
}

@@ -56,3 +56,3 @@ }, {

familyId: { type: 'object' },
groupId: { type: 'string' }
inventoryId: { type: 'string' }
},

@@ -59,0 +59,0 @@ required: Object.keys(this)

@@ -21,3 +21,3 @@ 'use strict';

var SubstanceReference = require('./substance-reference');
var GroupReference = require('../core/group-reference');
var InventoryReference = require('./inventory-reference');
var FileReference = require('../procedure/file-reference');

@@ -55,3 +55,3 @@

this.ghs = [];
this.group = null;
this.inventory = null;
this.healthSymptoms = new HealthSymptoms();

@@ -149,3 +149,3 @@ this.inChi = null;

}) : [];
this.group = opt.group ? new GroupReference(opt.group) : null;
this.inventory = opt.inventory ? new InventoryReference(opt.inventory) : null;
this.hash = this.hash || this._id.toString();

@@ -216,6 +216,6 @@ this.healthSymptoms = new HealthSymptoms(opt.healthSymptoms);

ghs: { type: 'array', item: { $ref: 'ghs.schema.json' } },
group: { anyOf: [{ type: ['null'] }, { $ref: 'group-reference.schema.json' }] },
healthSymptoms: { $ref: 'health-symptoms.schema.json' },
inChi: { type: ['string', 'null'] },
inChiKey: { type: ['string', 'null'] },
inventory: { anyOf: [{ type: ['null'] }, { $ref: 'inventory-reference.schema.json' }] },
isDataVerified: { type: 'boolean' },

@@ -302,4 +302,4 @@ isFamilyVerified: { type: 'boolean' },

tv4.addSchema(Ghs.schema());
tv4.addSchema(GroupReference.schema());
tv4.addSchema(HealthSymptoms.schema());
tv4.addSchema(InventoryReference.schema());
tv4.addSchema(Nfpa.schema());

@@ -306,0 +306,0 @@ tv4.addSchema(Storage.schema());

@@ -13,11 +13,11 @@ 'use strict';

this.buildingId = null;
this.floorId = null;
this.roomId = null;
this.sublocationId = null;
this.buildingId = '';
this.floorId = '';
this.roomId = '';
this.sublocationId = '';
this.buildingName = null;
this.floorName = null;
this.roomNumber = null;
this.sublocationName = null;
this.buildingName = '';
this.floorName = '';
this.roomNumber = '';
this.sublocationName = '';

@@ -32,11 +32,11 @@ if (opt) {

value: function fillObject(opt) {
this.buildingId = opt.buildingId;
this.floorId = opt.floorId;
this.roomId = opt.roomId;
this.sublocationId = opt.sublocationId;
this.buildingId = opt.buildingId || '';
this.floorId = opt.floorId || '';
this.roomId = opt.roomId || '';
this.sublocationId = opt.sublocationId || '';
this.buildingName = opt.buildingName;
this.floorName = opt.floorName;
this.roomNumber = opt.roomNumber;
this.sublocationName = opt.sublocationName;
this.buildingName = opt.buildingName || '';
this.floorName = opt.floorName || '';
this.roomNumber = opt.roomNumber || '';
this.sublocationName = opt.sublocationName || '';
}

@@ -43,0 +43,0 @@ }, {

@@ -7,2 +7,3 @@ 'use strict';

var ObjectId = require('bson').ObjectID;
var tv4 = require('tv4');

@@ -17,4 +18,4 @@

this.tenantCode = null;
this.groupId = null;
this.groupName = null;
this.inventoryId = null;
this.inventoryName = null;
this.types = [];

@@ -33,4 +34,4 @@

this.tenantCode = opt.tenantCode || null;
this.groupId = opt.groupId || null;
this.groupName = opt.groupName || null;
this.inventoryId = ObjectId.isValid(opt.inventoryId) ? new ObjectId(opt.inventoryId) : null;
this.inventoryName = opt.inventoryName || null;
this.types = opt.types ? opt.types : [];

@@ -55,4 +56,4 @@ }

tenantCode: { type: ['string', 'null'] },
groupId: { type: ['string', 'null'] },
groupName: { type: ['string', 'null'] },
inventoryId: { type: ['string', 'null'] },
inventoryName: { type: ['string', 'null'] },
types: { type: 'array', item: { type: 'string' } }

@@ -59,0 +60,0 @@ },

@@ -15,3 +15,3 @@ 'use strict';

this._id = null;
this.userId = null;
this.inventoryId = null;
this.buildingId = null;

@@ -40,3 +40,3 @@ this.floorId = null;

this._id = new ObjectId(opt._id);
this.userId = opt.userId;
this.inventoryId = ObjectId.isValid(opt.inventoryId) ? new ObjectId(opt.inventoryId) : null;
this.buildingId = opt.buildingId;

@@ -78,3 +78,3 @@ this.floorId = opt.floorId;

_id: { type: 'object' },
userId: { type: 'string' },
inventoryId: { type: 'object' },
buildingId: { type: 'string' },

@@ -81,0 +81,0 @@ floorId: { type: 'string' },

@@ -70,2 +70,4 @@ // constant - core

exports.HealthSymptoms = require('./dist/model/chemical/health-symptoms');
exports.Inventory = require('./dist/model/chemical/inventory');
exports.InventoryReference = require('./dist/model/chemical/inventory-reference');
exports.Nfpa = require('./dist/model/chemical/nfpa');

@@ -72,0 +74,0 @@ exports.Product = require('./dist/model/chemical/product');

{
"name": "@rss/common",
"version": "0.0.16",
"version": "0.0.18",
"description": "common constant, classes, & helper",

@@ -5,0 +5,0 @@ "author": "Risk & Safety Solution",

@@ -42,2 +42,13 @@ const ROLES = require('../constant/core/roles.constant');

module.exports.hasWriteAccessToInventory = (inventoryId, user) =>
module.exports.isChemAdmin(user.campusCode, user) ||
(user.inventories || [{}])
.filter((inventory) => inventory && inventory._id === inventoryId)
.some(
(group) =>
group.roles.includes(ROLES.RESPONSIBLE_PERSON) ||
group.roles.includes(ROLES.DELEGATE) ||
group.roles.includes(ROLES.LAB_MANAGER),
);
module.exports.hasWriteAccessToGroupOwner = (groupOwnerId, user) =>

@@ -71,4 +82,4 @@ module.exports.isChemAdmin(user.campusCode, user) ||

module.exports.hasWriteAccessToContainer = (container, user) =>
user.groups.map((group) => group.id).includes(container.group.id) ||
module.exports.isChemAdmin(container.group.owner.campusCode, user);
(user.inventories || [{}]).map((inventory) => inventory._id).includes(container.inventory._id) || // TODO: should use user.inventories
module.exports.isChemAdmin(container.inventory.campusCode, user);

@@ -75,0 +86,0 @@ // procedures

const clone = require('clone');
const tv4 = require('tv4');
const GroupReference = require('../core/group-reference');
const InventoryReference = require('./inventory-reference');
const PersonReference = require('../core/person-reference');

@@ -10,3 +10,3 @@

this.to = null;
this.group = null;
this.inventory = null;
this.status = null;

@@ -22,3 +22,3 @@ this.date = null;

this.to = new PersonReference(opt.to);
this.group = new GroupReference(opt.group);
this.inventory = new InventoryReference(opt.inventory);
this.status = opt.status;

@@ -36,7 +36,7 @@ this.date = opt.date ? new Date(opt.date) : new Date();

to: { type: ['object', 'null'] },
group: { type: ['object', 'null'] },
inventory: { type: ['object', 'null'] },
status: { type: ['string', 'null'] },
date: { type: ['object', 'null'] },
},
required: ['to', 'group', 'status', 'date'],
required: ['to', 'inventory', 'status', 'date'],
};

@@ -46,5 +46,5 @@ }

tv4.addSchema(GroupReference.schema());
tv4.addSchema(InventoryReference.schema());
tv4.addSchema(PersonReference.schema());
module.exports = Checkout;

@@ -8,3 +8,3 @@ const ObjectId = require('bson').ObjectID;

const FamilyReference = require('./family-reference');
const GroupReference = require('../core/group-reference');
const InventoryReference = require('./inventory-reference');
const Location = require('../core/location');

@@ -23,3 +23,3 @@

this.family = null;
this.group = null;
this.inventory = null;
this.location = null;

@@ -58,3 +58,3 @@ this.size = null;

this.family = new FamilyReference(opt.family);
this.group = new GroupReference(opt.group);
this.inventory = new InventoryReference(opt.inventory);
this.location = opt.location ? new Location(opt.location) : null;

@@ -90,3 +90,3 @@ this.size = opt.size ? parseFloat(opt.size, 10) : null;

validate() {
const barcodePattern = Helper.getBarcodePattern(this.group.owner);
const barcodePattern = Helper.getBarcodePattern(this.inventory);
return tv4.validateMultiple(this, Container.schema(barcodePattern));

@@ -131,3 +131,3 @@ }

family: { $ref: 'family-reference.schema.json' },
group: { $ref: 'group-reference.schema.json' },
inventory: { $ref: 'inventory-reference.schema.json' },
location: { $ref: 'location.schema.json' },

@@ -158,6 +158,6 @@ size: { type: 'number' },

concentrationUnits: { type: ['string', 'null'] },
checkout: { anyOf: [{ type: ['null'] }, { $ref: 'checkout.schema.json' }] },
checkout: { anyOf: [{ $ref: 'checkout.schema.json' }, { type: ['null'] }] },
},
required: Object.keys(this),
required: Object.keys(new Container()),
};

@@ -168,3 +168,3 @@ }

tv4.addSchema(FamilyReference.schema());
tv4.addSchema(GroupReference.schema());
tv4.addSchema(InventoryReference.schema());
tv4.addSchema(Location.schema());

@@ -171,0 +171,0 @@ tv4.addSchema(Checkout.schema());

@@ -13,3 +13,3 @@ const ObjectId = require('bson').ObjectID;

this.familyId = null;
this.groupId = null;
this.inventoryId = null;

@@ -26,3 +26,3 @@ if (opt) {

this.familyId = new ObjectId(opt.familyId);
this.groupId = opt.groupId;
this.inventoryId = new ObjectId(opt.inventoryId) || '';
}

@@ -44,3 +44,3 @@

familyId: { type: 'object' },
groupId: { type: 'string' },
inventoryId: { type: 'string' },
},

@@ -47,0 +47,0 @@ required: Object.keys(this),

@@ -15,3 +15,3 @@ const ObjectId = require('bson').ObjectID;

const SubstanceReference = require('./substance-reference');
const GroupReference = require('../core/group-reference');
const InventoryReference = require('./inventory-reference');
const FileReference = require('../procedure/file-reference');

@@ -47,3 +47,3 @@

this.ghs = [];
this.group = null;
this.inventory = null;
this.healthSymptoms = new HealthSymptoms();

@@ -131,3 +131,3 @@ this.inChi = null;

this.ghs = Array.isArray(opt.ghs) ? opt.ghs.map((item) => new Ghs(item)) : [];
this.group = opt.group ? new GroupReference(opt.group) : null;
this.inventory = opt.inventory ? new InventoryReference(opt.inventory) : null;
this.hash = this.hash || this._id.toString();

@@ -194,6 +194,6 @@ this.healthSymptoms = new HealthSymptoms(opt.healthSymptoms);

ghs: { type: 'array', item: { $ref: 'ghs.schema.json' } },
group: { anyOf: [{ type: ['null'] }, { $ref: 'group-reference.schema.json' }] },
healthSymptoms: { $ref: 'health-symptoms.schema.json' },
inChi: { type: ['string', 'null'] },
inChiKey: { type: ['string', 'null'] },
inventory: { anyOf: [{ type: ['null'] }, { $ref: 'inventory-reference.schema.json' }] },
isDataVerified: { type: 'boolean' },

@@ -277,4 +277,4 @@ isFamilyVerified: { type: 'boolean' },

tv4.addSchema(Ghs.schema());
tv4.addSchema(GroupReference.schema());
tv4.addSchema(HealthSymptoms.schema());
tv4.addSchema(InventoryReference.schema());
tv4.addSchema(Nfpa.schema());

@@ -281,0 +281,0 @@ tv4.addSchema(Storage.schema());

@@ -5,11 +5,11 @@ const tv4 = require('tv4');

constructor(opt) {
this.buildingId = null;
this.floorId = null;
this.roomId = null;
this.sublocationId = null;
this.buildingId = '';
this.floorId = '';
this.roomId = '';
this.sublocationId = '';
this.buildingName = null;
this.floorName = null;
this.roomNumber = null;
this.sublocationName = null;
this.buildingName = '';
this.floorName = '';
this.roomNumber = '';
this.sublocationName = '';

@@ -22,11 +22,11 @@ if (opt) {

fillObject(opt) {
this.buildingId = opt.buildingId;
this.floorId = opt.floorId;
this.roomId = opt.roomId;
this.sublocationId = opt.sublocationId;
this.buildingId = opt.buildingId || '';
this.floorId = opt.floorId || '';
this.roomId = opt.roomId || '';
this.sublocationId = opt.sublocationId || '';
this.buildingName = opt.buildingName;
this.floorName = opt.floorName;
this.roomNumber = opt.roomNumber;
this.sublocationName = opt.sublocationName;
this.buildingName = opt.buildingName || '';
this.floorName = opt.floorName || '';
this.roomNumber = opt.roomNumber || '';
this.sublocationName = opt.sublocationName || '';
}

@@ -33,0 +33,0 @@

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

const ObjectId = require('bson').ObjectID;
const tv4 = require('tv4');

@@ -8,4 +9,4 @@

this.tenantCode = null;
this.groupId = null;
this.groupName = null;
this.inventoryId = null;
this.inventoryName = null;
this.types = [];

@@ -22,4 +23,4 @@

this.tenantCode = opt.tenantCode || null;
this.groupId = opt.groupId || null;
this.groupName = opt.groupName || null;
this.inventoryId = ObjectId.isValid(opt.inventoryId) ? new ObjectId(opt.inventoryId) : null;
this.inventoryName = opt.inventoryName || null;
this.types = opt.types ? opt.types : [];

@@ -42,4 +43,4 @@ }

tenantCode: { type: ['string', 'null'] },
groupId: { type: ['string', 'null'] },
groupName: { type: ['string', 'null'] },
inventoryId: { type: ['string', 'null'] },
inventoryName: { type: ['string', 'null'] },
types: { type: 'array', item: { type: 'string' } },

@@ -46,0 +47,0 @@ },

@@ -7,3 +7,3 @@ const ObjectId = require('bson').ObjectID;

this._id = null;
this.userId = null;
this.inventoryId = null;
this.buildingId = null;

@@ -28,3 +28,3 @@ this.floorId = null;

this._id = new ObjectId(opt._id);
this.userId = opt.userId;
this.inventoryId = ObjectId.isValid(opt.inventoryId) ? new ObjectId(opt.inventoryId) : null;
this.buildingId = opt.buildingId;

@@ -60,3 +60,3 @@ this.floorId = opt.floorId;

_id: { type: 'object' },
userId: { type: 'string' },
inventoryId: { type: 'object' },
buildingId: { type: 'string' },

@@ -63,0 +63,0 @@ floorId: { type: 'string' },

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