data-prism
Advanced tools
Comparing version 0.0.4 to 0.0.5
export { linkInverses, emptyGraph, mergeGraphs } from "./graph.js"; | ||
export { flattenResource, normalizeResource, normalizeResources, } from "./mappers.js"; | ||
export { flattenResource, normalizeResource, createGraphFromTrees, } from "./mappers.js"; | ||
export { createQueryGraph, queryGraph } from "./graph/query.js"; | ||
@@ -4,0 +4,0 @@ export { forEachQuery, mapQuery, reduceQuery, forEachSchemalessQuery, mapSchemalessQuery, reduceSchemalessQuery, } from "./query.js"; |
export { linkInverses, emptyGraph, mergeGraphs } from "./graph.js"; | ||
export { flattenResource, normalizeResource, normalizeResources, } from "./mappers.js"; | ||
export { flattenResource, normalizeResource, createGraphFromTrees, } from "./mappers.js"; | ||
export { createQueryGraph, queryGraph } from "./graph/query.js"; | ||
export { forEachQuery, mapQuery, reduceQuery, forEachSchemalessQuery, mapSchemalessQuery, reduceSchemalessQuery, } from "./query.js"; | ||
export { createStore } from "./store.js"; |
@@ -83,6 +83,6 @@ # Helper Functions | ||
### `normalizeResources` | ||
### `createGraphFromTrees` | ||
```javascript | ||
normalizeResources(resourceType, flatResources, schema, graphMappers = {}); | ||
createGraphFromTrees(resourceType, flatResources, schema, graphMappers = {}); | ||
``` | ||
@@ -111,3 +111,3 @@ | ||
const normalBear = normalizeResources("bears", [bearAPIData], careBearSchema); | ||
const normalBear = createGraphFromTrees("bears", [bearAPIData], careBearSchema); | ||
``` | ||
@@ -182,3 +182,3 @@ | ||
To deal with these, we can use mappers. Recall that `normalizeResource` and `normalizeResources` take in an optional mapper argument. These have the form: | ||
To deal with these, we can use mappers. Recall that `normalizeResource` and `createGraphFromTrees` take in an optional mapper argument. These have the form: | ||
@@ -185,0 +185,0 @@ ```javascript |
{ | ||
"name": "data-prism", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -5,3 +5,3 @@ export { linkInverses, emptyGraph, mergeGraphs } from "./graph.js"; | ||
normalizeResource, | ||
normalizeResources, | ||
createGraphFromTrees, | ||
} from "./mappers.js"; | ||
@@ -8,0 +8,0 @@ export { createQueryGraph, queryGraph } from "./graph/query.js"; |
@@ -65,3 +65,3 @@ import { mapValues } from "lodash-es"; | ||
export function normalizeResources( | ||
export function createGraphFromTrees( | ||
rootResourceType: string, | ||
@@ -68,0 +68,0 @@ rootResources: { [k: string]: unknown }[], |
@@ -8,3 +8,3 @@ import { Schema } from "./schema.js"; | ||
} from "./graph.js"; | ||
import { normalizeResources } from "./mappers.js"; | ||
import { createGraphFromTrees } from "./mappers.js"; | ||
export { createQueryGraph, queryGraph } from "./graph/query.js"; | ||
@@ -49,3 +49,3 @@ | ||
) => { | ||
const graph = normalizeResources(resourceType, trees, schema, mappers); | ||
const graph = createGraphFromTrees(resourceType, trees, schema, mappers); | ||
merge(graph); | ||
@@ -52,0 +52,0 @@ }; |
@@ -6,3 +6,3 @@ import { expect, it, describe } from "vitest"; | ||
normalizeResource, | ||
normalizeResources, | ||
createGraphFromTrees, | ||
flattenResource, | ||
@@ -175,7 +175,7 @@ } from "../src/mappers.js"; | ||
describe("normalizeResources", () => { | ||
describe("createGraphFromTrees", () => { | ||
it("makes a graph from a single resource", () => { | ||
const resource = flatCareBearData.bears[0]; | ||
const graph = normalizeResources("bears", [resource], careBearSchema); | ||
const graph = createGraphFromTrees("bears", [resource], careBearSchema); | ||
@@ -192,3 +192,3 @@ expect(graph).toEqual({ | ||
const graph = normalizeResources("bears", resources, careBearSchema); | ||
const graph = createGraphFromTrees("bears", resources, careBearSchema); | ||
@@ -211,3 +211,3 @@ expect(graph).toEqual({ | ||
const graph = normalizeResources( | ||
const graph = createGraphFromTrees( | ||
"bears", | ||
@@ -234,3 +234,3 @@ [resource], | ||
const graph = normalizeResources("bears", [resource], careBearSchema); | ||
const graph = createGraphFromTrees("bears", [resource], careBearSchema); | ||
@@ -250,3 +250,3 @@ expect(graph).toEqual({ | ||
const graph = normalizeResources("bears", [resource], careBearSchema); | ||
const graph = createGraphFromTrees("bears", [resource], careBearSchema); | ||
@@ -253,0 +253,0 @@ expect(graph).toEqual({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
211686
34
2413