Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

data-prism

Package Overview
Dependencies
Maintainers
1
Versions
42
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
+1
-1
dist/mappers.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,KAAK,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC;AAC/C,KAAK,eAAe,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC5D,KAAK,YAAY,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAC;AAErD,wBAAgB,eAAe,CAAC,UAAU,KAAA,EAAE,QAAQ,KAAA,EAAE,OAAO,SAAO,OAUnE;AAED,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAClC,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,YAAiB,GAC7B,cAAc,CAuChB;AAED,wBAAgB,oBAAoB,CACnC,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EACzC,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,YAAiB,GAC7B,KAAK,CAyCP"}
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,KAAK,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC;AAC/C,KAAK,eAAe,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC5D,KAAK,YAAY,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAC;AAErD,wBAAgB,eAAe,CAAC,UAAU,KAAA,EAAE,QAAQ,KAAA,EAAE,OAAO,SAAO,OAUnE;AAED,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAClC,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,YAAiB,GAC7B,cAAc,CAyChB;AAED,wBAAgB,oBAAoB,CACnC,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EACzC,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,YAAiB,GAC7B,KAAK,CAyCP"}

@@ -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