GitHub image
cambria
⌘K
Exports
Functions
14
updateSchema
Docs
Import
Tests
3
References
2
function updateSchema(schema: JSONSchema7, lens: LensSource): any
schemaForLens
Docs
Import
Tests
3
References
2
function schemaForLens(lens: LensSource): any
compile
Docs
Import
Tests
3
References
2
function compile(lensSource: LensSource): { right: CompiledLens, left: CompiledLens }
applyLensToPatch
Docs
Import
Tests
3
References
2
function applyLensToPatch(
lensSource: LensSource,
patch: Patch,
patchSchema: JSONSchema7
): Patch
applyLensToDoc
Docs
Import
Tests
3
References
2

applyLensToDoc - converts a full document through a lens. Under the hood, we convert your input doc into a big patch and the apply it to the targetDoc. This allows merging data back and forth with other omitted values. @property lensSource: the lens specification to apply to the document @property inputDoc: the Plain Old Javascript Object to convert @property inputSchema: (default: inferred from inputDoc) a JSON schema defining the input @property targetDoc: (default: {}) a document to apply the contents of this document to as a patch

function applyLensToDoc(
lensSource: LensSource,
inputDoc: any,
inputSchema?: JSONSchema7,
targetDoc?: any
): any
importDoc
Docs
Import
Tests
3
References
2

importDoc - convert any Plain Old Javascript Object into an implied JSON Schema and a JSON Patch that sets every value in that document.

function importDoc(

a document to convert into a big JSON patch describing its full contents

inputDoc: any
): [any, Patch]
defaultObjectForSchema
Docs
Import
Tests
3
References
2
function defaultObjectForSchema(schema: JSONSchema7): any
reverseLens
Docs
Import
Tests
3
References
2
function reverseLens(lens: LensSource): LensSource
initLensGraph
Docs
Import
Tests
3
References
2
function initLensGraph(): LensGraph
registerLens
Docs
Import
Tests
3
References
2
function registerLens(
from: string,
to: string,
lenses: LensSource
): LensGraph
lensGraphSchema
Docs
Import
Tests
3
References
2
function lensGraphSchema(_: LensGraph, schema: string): any
lensFromTo
Docs
Import
Tests
3
References
2
function lensFromTo(_: LensGraph, from: string, to: string): LensSource
addProperty
Docs
Import
Tests
3
References
2
function addProperty(property: Property): AddProperty
removeProperty
Docs
Import
Tests
3
References
2
function removeProperty(property: Property): RemoveProperty
Type Aliases
4
Patch
Docs
Import
Tests
3
References
2
type Patch = any[]
CompiledLens
Docs
Import
Tests
3
References
2
type CompiledLens = (patch: Patch, targetDoc: any) => Patch
LensSource
Docs
Import
Tests
3
References
2
type LensSource = LensOp[]
Interfaces
2
Property
Docs
Import
Tests
3
References
2
interface Property {
name?: string
type: any
default?: any
required?: boolean
items?: Property
}
LensGraph
Docs
Import
Tests
3
References
2
interface LensGraph {
graph: Graph
}
Description
Cambria is a Javascript/Typescript library for converting JSON data between related schemas.
Install
yarn add cambria
Copy
Details
MIT License
6 Dependencies
Native TypeScript Package
Links
Metrics
Weekly Downloads
Keywords