# shex-methods

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

Latest version **0.2.14** (published 2023-09-28) · AGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install shex-methods
pnpm add shex-methods
yarn add shex-methods
bun add shex-methods
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.14 |
| Published | 2023-09-28 |
| First published | 2021-04-12 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 158.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ludwig Schubert |
| Maintainers | ludwigschubi |
| Keywords | shex, rdf, typescript |

## Links

- npm: https://www.npmjs.com/package/shex-methods
- Repository: https://github.com/ludwigschubi/shex-methods
- Homepage: https://ludwigschubi.github.io/shex-methods/
- Issues: https://github.com/ludwigschubi/shex-methods/issues
- npm.io page: https://npm.io/package/shex-methods

## Dependencies (11)

- [n3](https://npm.io/package/n3.md) ^1.16.3
- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [rdf-js](https://npm.io/package/rdf-js.md) ^4.0.2
- [rdflib](https://npm.io/package/rdflib.md) 2.2.12
- [camelcase](https://npm.io/package/camelcase.md) ^6.2.0
- [@shexjs/term](https://npm.io/package/@shexjs/term.md) ^1.0.0-alpha.25
- [@shexjs/util](https://npm.io/package/@shexjs/util.md) 1.0.0-alpha.25
- [own-namespace](https://npm.io/package/own-namespace.md) ^0.4.5
- [@shexjs/parser](https://npm.io/package/@shexjs/parser.md) 1.0.0-alpha.25
- [@shexjs/validator](https://npm.io/package/@shexjs/validator.md) 1.0.0-alpha.25
- [@shexjs/neighborhood-rdfjs](https://npm.io/package/@shexjs/neighborhood-rdfjs.md) ^1.0.0-alpha.25

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.2.14 (latest) — 2023-09-28
- 0.2.13 — 2023-09-28
- 0.2.12 — 2023-04-26
- 0.2.11 — 2023-04-22
- 0.2.10 — 2023-04-19
- 0.2.9 — 2023-04-19
- 0.2.8 — 2023-03-21
- 0.2.7 — 2023-03-21
- 0.2.4 — 2022-11-26
- 0.2.3 — 2022-07-30
- 0.2.2 — 2022-07-25
- 0.2.1 — 2022-07-24
- 0.2.0 — 2022-07-24
- 0.1.48 — 2022-07-23
- 0.1.47 — 2022-07-23
- … 43 more at https://npm.io/package/shex-methods/versions

## README

# shex-methods

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

[Examples](#examples) | [Usage](#usage) | [Features](#features) | [Contributing](#contributing)

## Examples

To create a shape object you can use the generated context and types from [shex-codegen](https://github.com/ludwigschubi/shex-codegen/).
```typescript
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.
```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;
```

## Usage

Install the package via your preferred node package manager:
`npm i shex-methods` or `yarn add shex-methods`

See the [auto-generated documentation](https://ludwigschubi.github.io/shex-methods/index.html) 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.

---
_Source: https://npm.io/package/shex-methods · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
