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

@oddnetworks/oddworks

Package Overview
Dependencies
Maintainers
4
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oddnetworks/oddworks - npm Package Compare versions

Comparing version 3.2.2 to 3.3.0

9

CHANGELOG.md
# Changelog
## 3.2.2 Unstanb
## 3.3.0
- Handle special case of [JSON API links in config](https://github.com/oddnetworks/oddworks/commit/f67ae7f61010d740099d26909e1b78bd6449b218) response
- Fixes JSON API response middleware bugs
- Limit attributes [assigned to resource object meta](https://github.com/oddnetworks/oddworks/commit/12c113766e3e2433235e5c03d73dc94e9567ffe5)
- Fixes the include=foo query parameter in CatalogListController and CatalogItemController
## 3.2.2 Unstable
- Adds a type and id property to config objects for JSON API readiness.

@@ -6,0 +13,0 @@

48

lib/middleware/response-json-api.js

@@ -27,5 +27,11 @@ 'use strict';

resource.relationships = data.relationships || {};
resource.links = {
self: `${baseUrl}/${resource.type}s/${resource.id}`
};
if (resource.type === 'config') {
resource.links = {
self: `${baseUrl}/config`
};
} else {
resource.links = {
self: `${baseUrl}/${resource.type}s/${resource.id}`
};
}
resource.meta = data.meta || {};

@@ -41,14 +47,26 @@ }

function inIncluded(item, key) {
const foundIndex = _.findIndex(included, {type: item.type, id: item.id});
if (foundIndex < 0) {
bus.broadcast({level: 'warn', event: 'json-api-missing-relationship'}, {
message: `id:${data.id}, key:${key}, fk:${item.id}`
});
return false;
}
return true;
}
// Remove relationship references that were not found.
Object.keys(relationships).forEach(key => {
const rel = relationships[key].data || [];
rel.slice().forEach((item, i) => {
const foundIndex = _.findIndex(included, {type: item.type, id: item.id});
if (foundIndex < 0) {
bus.broadcast({level: 'warn', event: 'json-api-missing-relationship'}, {
message: `id:${data.id}, key:${key}, fk:${item.id}`
});
rel.splice(i, 1);
}
});
const rel = relationships[key].data || {};
if (Array.isArray(rel)) {
rel.slice().forEach((item, i) => {
if (!inIncluded(item, key)) {
rel.splice(i, 1);
}
});
} else if (!inIncluded(rel, key)) {
delete relationships[key];
}
});

@@ -97,3 +115,3 @@

res.body.data = format(data, baseUrl);
res.body.links = data.links;
res.body.links = res.body.data.links;
}

@@ -108,3 +126,3 @@

if (req.identity.platform) {
res.body.meta.channel = req.identity.platform.id;
res.body.meta.platform = req.identity.platform.platformType;
}

@@ -111,0 +129,0 @@ }

@@ -19,6 +19,9 @@ 'use strict';

platform: req.identity.platform,
user: req.identity.user,
include: req.query.include.split(',')
user: req.identity.user
};
if (req.query.include) {
args.include = req.query.include.split(',');
}
this.bus

@@ -25,0 +28,0 @@ .query({role: 'catalog', cmd: 'fetchItem'}, args)

@@ -19,6 +19,9 @@ 'use strict';

user: req.identity.user,
include: req.query.include.split(','),
limit: req.query.limit
};
if (req.query.include) {
args.include = req.query.include.split(',');
}
this.bus

@@ -25,0 +28,0 @@ .query({role: 'catalog', cmd: 'fetchItemList'}, args)

@@ -6,3 +6,11 @@ 'use strict';

const RESOURCE_FEATURES = [
'ads',
'player',
'sharing',
'overlay'
];
// service.options.updateFrequency - Number > 0 < 1 *default === 1*
// service.options.resourceFeatures - Array of Strings
module.exports = function (service) {

@@ -12,6 +20,8 @@ const queries = Object.create(null);

const options = _.defaults({}, service.options, {
updateFrequency: 1
updateFrequency: 1,
resourceFeatures: RESOURCE_FEATURES
});
const UPDATE_FREQ = options.updateFrequency;
const FEATURES = options.resourceFeatures;

@@ -74,3 +84,12 @@ // args.channel - Object *required*

// https://github.com/oddnetworks/oddworks/issues/95
resource.meta = _.merge({}, meta, resource.meta);
const config = _.merge({}, meta, resource.meta);
resource.meta = assignObjectMeta(config);
// Assign meta to included entities
if (resource.included && resource.included.length) {
resource.included = resource.included.map(res => {
res.meta = assignObjectMeta(_.merge({}, meta, res.meta));
return res;
});
}
return resource;

@@ -82,2 +101,13 @@ });

function assignObjectMeta(config) {
return {
user: config.user,
features: _.pick(config.features, FEATURES),
maxAge: config.maxAge,
staleWhileRevalidate: config.staleWhileRevalidate,
updatedAt: config.updatedAt,
source: config.source
};
}
function checkCache(object) {

@@ -84,0 +114,0 @@ const now = _.now();

{
"name": "@oddnetworks/oddworks",
"version": "3.2.2",
"version": "3.3.0",
"description": "An extensible media platform for OTT devices.",

@@ -5,0 +5,0 @@ "main": "./lib/oddworks.js",

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