Coder Social home page Coder Social logo

shex-methods's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.