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

@rcsb/rcsb-documentation

Package Overview
Dependencies
Maintainers
0
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rcsb/rcsb-documentation - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json
{
"name": "@rcsb/rcsb-documentation",
"private": false,
"version": "0.0.03",
"version": "0.0.04",
"main": "build/bundle.js",

@@ -6,0 +6,0 @@ "files": [

@@ -111,5 +111,12 @@ // Check if fetch is available; otherwise, use node-fetch

const item = await fetchItem(env, _id);
const imgPath = getImagePath(env, item, _id);
item.html = item.html.replace(/<IMG_PATH>/g, imgPath).replace(/https:\/\/www.rcsb.org/g, '');
item.lastUpdatedStr = new Date(item.lastUpdated).toLocaleDateString('en-US');
// Special case: Set attribute details if the URL matches
if (reqUrl === '/docs/search-and-browse/advanced-search/attribute-details') {
setAttributeDetails(req, item);
} else {
const imgPath = getImagePath(env, item, _id);
item.html = item.html.replace(/<IMG_PATH>/g, imgPath).replace(/https:\/\/www.rcsb.org/g, '');
item.lastUpdatedStr = new Date(item.lastUpdated).toLocaleDateString('en-US');
}
item.href = hrefMap[_id];

@@ -271,2 +278,92 @@ itemMap[_id] = item;

function setAttributeDetails(req, item) {
const metadata = req.app.locals.metadata
, UNITS = { // see definition in lib/js/search/src/constants.js
angstroms: 'Å'
, angstroms_cubed_per_dalton: 'ų/Da'
, angstroms_squared: 'Ų'
, kelvins: 'K'
, kilodaltons: 'kDa'
, kilojoule_per_mole: 'kJ/mol'
, megahertz: 'MHz'
, daltons: 'Da'
, degrees: '°'
, nanomole: 'nM'
, per_mole: 'M\u207B\u00B9' // unicode <sup>-1</sup> - TODO replace other unicode chars with unicode equivalent
}
, attributeDetails = {
schemas: [
{ schema_name: 'structure', headers: [] }
, { schema_name: 'chemical', headers: [] }
]
};
//u.logJson(metadata.structure, 'setAttributeDetails: metadata.structure')
attributeDetails.schemas.forEach(schema => {
const { headers, schema_name } = schema;
schema.display_name = u.ucFirst(schema_name) + ' Attributes';
const selectorItems = metadata[schema_name].selectorItems;
selectorItems.forEach(si => {
if (si.type === 'header') {
headers.push({ name: si.name, attributes: [] });
} else {
const attrObj = metadata[schema_name].uiAttrMap[si.attribute]; // attrObj from metadata, where 'name' is schema name
if (attrObj) {
const { attribute, description, type } = attrObj
, obj = { attribute, description, type };
obj.name = si.name;
if (si.type === 'item-nested') {
//if (si.attribute === 'rcsb_binding_affinity.value') u.logJson({ selectorItem: si, attrObj }, 'setAttributeDetails')
let { nested_attribute, nested_attribute_value, units, range } = si;
// assign values from selectorItem
obj.nested_attribute = nested_attribute;
if (units) obj.units = UNITS[units];
if (range) {
obj.min = range.min;
obj.max = range.max;
}
const { nestedAttribute } = attrObj
, context = nestedAttribute.contexts[nested_attribute_value]
, { detail, examples } = context;
// these values are not available in selectorItem, so assign from attrObj
if (detail) obj.detail = detail;
if (examples) obj.examples = examples;
} else {
const { units, examples, enumeration, is_iterable } = attrObj;
let { min, max } = attrObj;
if (units) obj.units = UNITS[units];
if (examples) obj.examples = examples;
if (enumeration) obj.enumeration = enumeration;
if (is_iterable) obj.is_iterable = is_iterable;
// check min, max for 0 otherwise they will not display in ui
if (typeof min !== 'undefined' && typeof max !== 'undefined') {
obj.min = '' + min;
obj.max = '' + max;
}
}
headers[headers.length - 1].attributes.push(obj);
}
}
});
});
item.attributeDetails = attributeDetails;
item.lastUpdatedStr = metadata['structure'].lastReleaseDate.long;
}
// Set parent group state for rendering

@@ -300,3 +397,4 @@ function setParentGroupState(groupMap, o) {

getMenuObj,
setAttributeDetails,
setParentGroupState,
};
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