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.9.7 to 1.10.1

4

lib/builders/JsonDeserializer.js

@@ -47,3 +47,3 @@ "use strict";

if (resourceIdObj === void 0) { resourceIdObj = {}; }
var cachedModel = this.dc.getCachedModel(data);
var cachedModel = this.dc.getCachedModel(data, resourceIdObj);
if (cachedModel) {

@@ -53,3 +53,3 @@ return cachedModel;

var model = this.pm.createModel(data.type);
this.dc.handleModel(model, data); // should be called before this.pm.setRelationships(model, relationships);
this.dc.handleModel(model, data, resourceIdObj); // should be called before this.pm.setRelationships(model, relationships);
if (model) {

@@ -56,0 +56,0 @@ this.pm.setId(model, data.id);

@@ -5,5 +5,5 @@ import { IDeserializeCache, TAnyKeyValueObject } from './JsonaTypes';

protected cachedModels: {};
getCachedModel(data: any): any;
handleModel(model: any, data: any): void;
createCacheKey(data: any): string;
getCachedModel(data: any, resourceIdObject: any): any;
handleModel(model: any, data: any, resourceIdObject: any): void;
createCacheKey(data: any, resourceIdObject: any): string;
}

@@ -20,8 +20,8 @@ "use strict";

}
DeserializeCache.prototype.getCachedModel = function (data) {
var entityKey = this.createCacheKey(data);
DeserializeCache.prototype.getCachedModel = function (data, resourceIdObject) {
var entityKey = this.createCacheKey(data, resourceIdObject);
return this.cachedModels[entityKey] || null;
};
DeserializeCache.prototype.handleModel = function (model, data) {
var entityKey = this.createCacheKey(data);
DeserializeCache.prototype.handleModel = function (model, data, resourceIdObject) {
var entityKey = this.createCacheKey(data, resourceIdObject);
var dataWithPayload = data.attributes || data.relationships;

@@ -32,11 +32,13 @@ if (entityKey && dataWithPayload) {

};
DeserializeCache.prototype.createCacheKey = function (data) {
if (data.type && data.id && !data.meta) {
return data.type + "-" + data.id;
DeserializeCache.prototype.createCacheKey = function (data, resourceIdObject) {
// resourceIdObject.meta sets to model in simplePropertyMappers.ts, so it should be used here too
// cache in this case probably will be redundant
if (!data.id || !data.type || resourceIdObject.meta) {
return;
}
if (data.type && data.id && data.meta) {
var meta = jsonStringify(data.meta);
return data.type + "-" + data.id + "-" + meta;
var resourcePart = resourceIdObject.type + "-" + resourceIdObject.id;
if (data.meta) {
return data.type + "-" + data.id + "-" + jsonStringify(data.meta) + "-" + resourcePart;
}
return '';
return data.type + "-" + data.id + "-" + resourcePart;
};

@@ -43,0 +45,0 @@ return DeserializeCache;

@@ -25,5 +25,5 @@ declare type AtLeastOneProperty<T, U = {

export interface IDeserializeCache {
getCachedModel(data: TJsonApiData): TJsonaModel | null;
handleModel(model: TJsonaModel, data: TJsonApiData): void;
createCacheKey(data: TJsonApiData): string;
getCachedModel(data: TJsonApiData, resourceIdObject: TResourceIdObj): TJsonaModel | null;
handleModel(model: TJsonaModel, data: TJsonApiData, resourceIdObject: TResourceIdObj): void;
createCacheKey(data: TJsonApiData, resourceIdObject: TResourceIdObj): string;
}

@@ -134,2 +134,7 @@ export interface IDeserializeCacheConstructor {

export declare type TResourceIdObj = {
id?: string | number;
type?: string;
meta?: {
[propertyName: string]: any;
};
[propertyName: string]: any;

@@ -136,0 +141,0 @@ };

{
"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.9.7",
"version": "1.10.1",
"keywords": [

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

Sorry, the diff of this file is not supported yet

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