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

jsona

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsona - npm Package Compare versions

Comparing version 1.1.9 to 1.1.10

50

lib/builders/JsonDeserializer.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createEntityKey(data) {
if (data.type && data.id) {
return data.type + "-" + data.id;
}
return '';
}
var JsonDeserializer = /** @class */ (function () {

@@ -35,24 +41,30 @@ function JsonDeserializer(propertiesMapper) {

JsonDeserializer.prototype.buildModelByData = function (data) {
// checks for built model in cachedModels is a protection from creating models on recursive relationships
var entityKey = data.type + "-" + data.id;
var model = this.cachedModels[entityKey];
if (!model) {
model = this.pm.createModel(data.type);
var entityKey = createEntityKey(data);
var model;
if (entityKey) {
// checks for built model in cachedModels is a protection from creating models on recursive relationships
model = this.cachedModels[entityKey];
if (model) {
return model;
}
}
model = this.pm.createModel(data.type);
if (model) {
if (entityKey) {
this.cachedModels[entityKey] = model;
this.pm.setId(model, data.id);
if (data.attributes) {
this.pm.setAttributes(model, data.attributes);
}
if (data.meta && this.pm.setMeta) {
this.pm.setMeta(model, data.meta);
}
if (data.links && this.pm.setLinks) {
this.pm.setLinks(model, data.links);
}
var relationships = this.buildRelationsByData(data, model);
if (relationships) {
this.pm.setRelationships(model, relationships);
}
}
this.pm.setId(model, data.id);
if (data.attributes) {
this.pm.setAttributes(model, data.attributes);
}
if (data.meta && this.pm.setMeta) {
this.pm.setMeta(model, data.meta);
}
if (data.links && this.pm.setLinks) {
this.pm.setLinks(model, data.links);
}
var relationships = this.buildRelationsByData(data, model);
if (relationships) {
this.pm.setRelationships(model, relationships);
}
}

@@ -59,0 +71,0 @@ return model;

{
"name": "jsona",
"description": "Provide data formatters (data model builder & json builder) to work with JSON API specification v1.0 in your JavaScript / TypeScript code",
"version": "1.1.9",
"version": "1.1.10",
"keywords": [

@@ -6,0 +6,0 @@ "json-api",

@@ -10,2 +10,10 @@ import {

function createEntityKey(data: TJsonApiData) {
if (data.type && data.id) {
return `${data.type}-${data.id}`;
}
return '';
}
class JsonDeserializer implements IJsonaModelBuilder {

@@ -56,32 +64,40 @@

// checks for built model in cachedModels is a protection from creating models on recursive relationships
const entityKey = `${data.type}-${data.id}`;
let model = this.cachedModels[entityKey];
const entityKey = createEntityKey(data);
if (!model) {
model = this.pm.createModel(data.type);
let model;
if (entityKey) {
// checks for built model in cachedModels is a protection from creating models on recursive relationships
model = this.cachedModels[entityKey];
if (model) {
return model;
}
}
model = this.pm.createModel(data.type);
if (model) {
if (entityKey) {
this.cachedModels[entityKey] = model;
}
this.pm.setId(model, data.id);
this.pm.setId(model, data.id);
if (data.attributes) {
this.pm.setAttributes(model, data.attributes);
}
if (data.attributes) {
this.pm.setAttributes(model, data.attributes);
}
if (data.meta && this.pm.setMeta) {
this.pm.setMeta(model, data.meta);
}
if (data.meta && this.pm.setMeta) {
this.pm.setMeta(model, data.meta);
}
if (data.links && this.pm.setLinks) {
this.pm.setLinks(model, data.links);
}
if (data.links && this.pm.setLinks) {
this.pm.setLinks(model, data.links);
}
const relationships: null | TJsonaRelationships = this.buildRelationsByData(data, model);
const relationships: null | TJsonaRelationships = this.buildRelationsByData(data, model);
if (relationships) {
this.pm.setRelationships(model, relationships);
}
if (relationships) {
this.pm.setRelationships(model, relationships);
}

@@ -88,0 +104,0 @@ }

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