A library to read, create, update or delete rdf nodes that fit a given shape expression.
npm install shex-methodsA library to read, create, update or delete rdf nodes that fit a given shape expression.
Examples | Usage | Features | Contributing
To create a shape object you can use the generated context and types from shex-codegen.
``typescript
import { Shape } from "shex-methods";
import {
chatShex,
ChatShape,
ChatShapeType,
ChatShapeContext,
} from "../resources/shex"; // generated by shex-codegen
const chat = new Shape
id: "https://shaperepo.com/schemas/longChat#ChatShape",
shape: chatShex,
context: ChatShapeContext,
type: ChatShapeType,
});
`
Then you can use the shape object to create nodes of this shape using plain javascript-objects for specifying data. The id of the input data will be used as the node iri of the shape so make sure to pass a valid url.
`typescript`
const newChat = await chat.create({
doc: testDoc,
data: {
id: firstChatIri,
type: ChatShapeType.LongChat,
title: "Test Chat",
author: webId,
created: new Date(),
},
});
const { data, errors } = newChat;
Install the package via your preferred node package manager:
npm i shex-methods or yarn add shex-methods
See the auto-generated documentation to learn about all methods.
Current features:
* Can read, create, update and delete a single shape in remote resources
* Can read multiple shapes in remote resources
* User can specify data as primitive type or rdf node
Planned features:
* Can do all operations on a local graph
* Can create, update and delete many nodes at once
* Can publish a shape to an index of shapes
* Can subscribe to an index of shapes
Run yarn to install dependencies and generate shape types.
Use yarn develop` to start the build process in watch mode and run the tests on file changes.