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

data-prism

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-prism - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

4

dist/mappers.js

@@ -13,3 +13,3 @@ import { mapValues } from "lodash-es";

const resSchema = schema.resources[resourceType];
const resourceMappers = graphMappers[resourceType];
const resourceMappers = graphMappers[resourceType] ?? {};
const attributes = mapValues(resSchema.attributes, (_, attr) => {

@@ -34,2 +34,4 @@ const mapper = resourceMappers[attr];

: resource[rel];
if (relVal === undefined)
return undefined;
return applyOrMap(relVal ?? emptyRel, (relRes) => typeof relRes === "object"

@@ -36,0 +38,0 @@ ? { type: relSchema.type, id: relRes[relIdField] }

{
"name": "data-prism",
"version": "0.0.10",
"version": "0.0.11",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -29,3 +29,3 @@ import { mapValues } from "lodash-es";

const resSchema = schema.resources[resourceType];
const resourceMappers = graphMappers[resourceType];
const resourceMappers = graphMappers[resourceType] ?? {};

@@ -56,2 +56,4 @@ const attributes = mapValues(resSchema.attributes, (_, attr) => {

if (relVal === undefined) return undefined;
return applyOrMap(relVal ?? emptyRel, (relRes) =>

@@ -58,0 +60,0 @@ typeof relRes === "object"

@@ -67,7 +67,3 @@ import { expect, it, describe } from "vitest";

...careBearData.bears[1],
relationships: {
home: null,
bestFriend: null,
powers: [],
},
relationships: {},
});

@@ -86,4 +82,2 @@ });

home: { type: "homes", id: "1" },
bestFriend: null,
powers: [],
},

@@ -102,4 +96,2 @@ });

relationships: {
home: null,
bestFriend: null,
powers: [{ type: "powers", id: "careBearStare" }],

@@ -118,3 +110,5 @@ },

const resource = normalizeResource("bears", base, careBearSchema, {
name: "nombre",
bears: {
name: "nombre",
},
});

@@ -135,3 +129,5 @@

const resource = normalizeResource("bears", base, careBearSchema, {
home: "casa",
bears: {
home: "casa",
},
});

@@ -148,2 +144,35 @@

it("formats with a relationship renaming and a nonstandard id", () => {
const powaz = {
...flatCareBearData.powers.map((p) => ({
...p,
powerId: undefined,
powaId: p.powerId,
})),
};
const base = {
...flatCareBearData.bears[0],
powers: undefined,
powaz: [powaz[0]],
};
const resource = normalizeResource("bears", base, careBearSchema, {
bears: {
powers: "powaz",
},
powers: {
id: "powaId",
},
});
expect(resource).toEqual({
...careBearData.bears[1],
relationships: {
...careBearData.bears[1].relationships,
powers: [{ type: "powers", id: "careBearStare" }],
},
});
});
it("formats with a function", () => {

@@ -156,3 +185,5 @@ const base = {

const resource = normalizeResource("bears", base, careBearSchema, {
name: (res) => `${res.name} a.k.a. ${res.nombre}`,
bears: {
name: (res) => `${res.name} a.k.a. ${res.nombre}`,
},
});

@@ -179,2 +210,17 @@

});
it("keeps undefined relationships undefined", () => {
const base = omit(flatCareBearData.bears[0], ["home", "powers"]);
const resource = normalizeResource("bears", base, careBearSchema);
expect(resource).toEqual({
...careBearData.bears[1],
relationships: {
bestFriend: null,
home: undefined,
powers: undefined,
},
});
});
});

@@ -181,0 +227,0 @@

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