UNPKG

single-source-of-truth

Version:
46 lines 1.72 kB
import { id, unique } from '../symbols.js'; import { TruthRelationUtil } from './relation.js'; export var TruthShapeUtil; (function (TruthShapeUtil) { function isAttributesKey(key) { return key === id || key === unique; } TruthShapeUtil.isAttributesKey = isAttributesKey; function extractAttributesShape(shape) { return Object.entries(shape).reduce((shape, [k, v]) => { if (!isAttributesKey(k)) return shape; Reflect.set(shape, k, v); return shape; }, {}); } TruthShapeUtil.extractAttributesShape = extractAttributesShape; function normaliseAttributesShape(shape) { return Object.entries(shape).reduce((shape, [k, v]) => { Reflect.set(shape, k.trimStart(), v); return shape; }, {}); } TruthShapeUtil.normaliseAttributesShape = normaliseAttributesShape; function extractRelationsShape(shape) { return Object.entries(shape).reduce((shape, [k, v]) => { if (!TruthRelationUtil.isAnyRelation(v)) return shape; Reflect.set(shape, k, v); return shape; }, {}); } TruthShapeUtil.extractRelationsShape = extractRelationsShape; function extractZodShape(shape) { return Object.entries(shape).reduce((shape, [k, v]) => { if (isAttributesKey(k)) return shape; if (TruthRelationUtil.isAnyRelation(v)) return shape; Reflect.set(shape, k, v); return shape; }, {}); } TruthShapeUtil.extractZodShape = extractZodShape; })(TruthShapeUtil || (TruthShapeUtil = {})); //# sourceMappingURL=shape.js.map