shex-methods
TypeScript icon, indicating that this package has built-in type declarations

0.2.14 • Public • Published

shex-methods

A library to read, create, update or delete rdf nodes that fit a given shape expression.

Examples | Usage | Features | Contributing

Examples

To create a shape object you can use the generated context and types from shex-codegen.

import { Shape } from "shex-methods";
import {
  chatShex,
  ChatShape,
  ChatShapeType,
  ChatShapeContext,
} from "../resources/shex"; // generated by shex-codegen

const chat = new Shape<ChatShape>({
  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.

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;

Usage

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.

Features

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

Contributing

Run yarn to install dependencies and generate shape types.

Configure Environment

Make a copy of example.env and add the required environment variables for running tests that involve authentication/authorization.

Use yarn develop to start the build process in watch mode and run the tests on file changes.

Readme

Keywords

Package Sidebar

Install

npm i shex-methods

Weekly Downloads

0

Version

0.2.14

License

AGPL-3.0

Unpacked Size

162 kB

Total Files

83

Last publish

Collaborators

  • ludwigschubi