🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@data-prism/utils

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@data-prism/utils - npm Package Compare versions

Comparing version
0.0.2
to
0.0.3
+2
dist/tree.d.ts
export declare function tabularize(schema: any, query: any, tree: any): any[];
//# sourceMappingURL=tree.d.ts.map
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AA6CA,wBAAgB,UAAU,CAAC,MAAM,KAAA,EAAE,KAAK,KAAA,EAAE,IAAI,KAAA,SAI7C"}
import { pick } from "lodash-es";
function walk(schema, rootQuery, rootTree) {
const output = [];
const go = (query, tree, type, path, ancestors) => {
const resDef = schema.resources[type];
const propProps = pick(query.properties, Object.keys(resDef.properties));
const relProps = pick(query.properties, Object.keys(resDef.relationships));
const relKeys = Object.keys(relProps);
const resProps = {};
Object.keys(propProps).forEach((propName) => {
resProps[[...path, propName].join(".")] = tree[propName];
});
// hit the bottom
if (relKeys.length === 0) {
output.push({ ...ancestors, ...resProps });
return;
}
Object.entries(relProps).forEach(([propName, propQuery]) => {
const relDef = resDef.relationships[propName];
if (relDef.cardinality === "one") {
go(propQuery, tree[propName], relDef.resource, [...path, propName], {
...ancestors,
...resProps,
});
}
else {
tree[propName].forEach((subTree) => {
go(propQuery, subTree, relDef.resource, [...path, propName], {
...ancestors,
...resProps,
});
});
}
});
};
go(rootQuery, rootTree, rootQuery.type, [], {});
return output;
}
export function tabularize(schema, query, tree) {
return Array.isArray(tree)
? tree.flatMap((t) => walk(schema, query, t))
: walk(schema, query, tree);
}
export declare function applyOrMap(itemItemsOrNull: any, fn: any): any;
export declare function pipeThru(init: any, fns: any): any;
//# sourceMappingURL=utils.d.ts.map
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,eAAe,KAAA,EAAE,EAAE,KAAA,OAI7C;AAED,wBAAgB,QAAQ,CAAC,IAAI,KAAA,EAAE,GAAG,KAAA,OAKjC"}
// export { tabularize } from "./tree.js";
export function applyOrMap(itemItemsOrNull, fn) {
if (itemItemsOrNull == null)
return itemItemsOrNull;
return Array.isArray(itemItemsOrNull) ? itemItemsOrNull.map(fn) : fn(itemItemsOrNull);
}
export function pipeThru(init, fns) {
return fns.reduce((onion, fn) => (val) => fn(onion(val)), (val) => val)(init);
}

Sorry, the diff of this file is not supported yet

+1
-1
{
"name": "@data-prism/utils",
"version": "0.0.2",
"version": "0.0.3",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./src/utils.js",

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

export { tabularize } from "./tree.js";
// export { tabularize } from "./tree.js";

@@ -3,0 +3,0 @@ export function applyOrMap(itemItemsOrNull, fn) {

{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"composite": true,
"outDir": "./dist",
"rootDir": "./src"
"esModuleInterop": true
},
"include": ["src"]
}
"include": [
"./src"
]
}