This project was made possible by a grant from NGI Zero Entrust via nlnet. Learn more on the [NLnet project page](https://nlnet.nl/project/SolidUsableApps/).
- [Detecting a the graph of specific information](#detecting-a-the-graph-of-specific-information)
For the most part, a JSONLD Dataset Proxy has parity with JavaScript Object Literals. However, there are a few differences to highlight. This section details how you would do different tasks.
For the most part, you can think of a JSONLD Dataset Proxy as a JavaScript Object Literal with "Sets" instead of arrays.
### Defining a Context and Type
The first step to getting a JSONLD Dataset Proxy is defining the JSONLD Context and TypeScript Typings. This can either be done through a [generator](https://github.com/o-development/shexj2typeandcontext) or defining them manually.
The first step to getting a JSONLD Dataset Proxy is defining the JSONLD Context and TypeScript Typings. This can either be done through a [generator](https://ldo.js.org/api/cli/build/) or defining them manually.
In this example typescript typing `IPerson` is an interface that represents a person. Notice the `@id` and `@context` fields. Be sure to include them in your interfaces if you wish to use those properties.
```typescript
import { ContextDefinition } from "jsonld";
import { LdoJsonldContext, LdSet } from "@ldo/jsonld-dataset-proxy";
reduce<U>(callbackfn: (previousValue: U, currentValue: T, array: LdSet<T>) => U, initialValue: U): U;
toArray(): T[];
toJSON(): T[];
difference(other: Set<T>): LdSet<T>;
intersection(other: Set<T>): LdSet<T>;
isDisjointFrom(other: Set<T>): boolean;
isSubsetOf(other: Set<T>): boolean;
isSupersetOf(other: Set<T>): boolean;
symmetricDifference(other: Set<T>): LdSet<T>;
union(other: Set<T>): LdSet<T>;
}
```
### Overwriting an Object
If an object literal is set and the id is equivalent to an existing id, that node will be overwritten. All triples from the previous object are removed and replaced with triples from the new object.
@ -390,7 +430,7 @@ const person = jsonldDatasetProxy(
You can rename an object by setting its `@id` field. This will update all triples that reference the id to the new id.
You can rename an object by setting its `@id` field. This will update all triples that reference the id to the new id. Setting the `@id` field to `undefined` will turn it into a blank node.
Removing one triple can be done by setting a property to `undefined`;
Removing a connection between nodes can be done by setting a field to `undefined` or using the `delete` operator. Values can be removed from a set by using the `delete` method or the `clear` method to remove all connections.
```typescript
const dataset = await serializedToDataset(`
@ -445,41 +485,16 @@ const person = jsonldDatasetProxy(
@ -641,10 +656,10 @@ The graph of specific information can be detected using the `graphOf(subject, pr
- `subject`: A Jsonld Dataset Proxy that represents the subject of a quad.
- `predicate`: A string key
- `object?`: An optional parameter that represents the direct object of a statement. This could be a Jsonld Dataset Proxy or a number to indicate the location in an array. This argument can be left blank if the given field is not an array.
- `object?`: A representation of the direct object of the triple in question. This could be a jsonld-dataset-proxy or simply and object with an `@id` field.
If you already have generated ShapeTypes, you may install the `@ldo/ldo` library independently.
```
npm i @ldo/ldo
```
</details>
## Simple Example
Below is a simple example of LDO in a real use-case (changing the name on a Solid Pod). Assume that a ShapeType was previously generated and placed at `./.ldo/foafProfile.shapeTypes`.
```typescript
import { parseRdf, startTransaction, toSparqlUpdate, toTurtle } from "@ldo/ldo";
import {
parseRdf,
startTransaction,
toSparqlUpdate,
toTurtle,
set,
} from "@ldo/ldo";
import { FoafProfileShapeType } from "./.ldo/foafProfile.shapeTypes";
`@ldo/solid-react` provides tool and hooks for easily building Solid applications using react.
// TODO: Write readme
## Guide
A full walkthrough for using the `@ldo/solid` library can be found in the [For Solid + React Guide](https://ldo.js.org/guides/solid_react/)
## Installation
Navigate into your project's root folder and run the following command:
```
cd my_project/
npx run @ldo/cli init
```
Now install the @ldo/solid library
```
npm i @ldo/solid@ldo/solid-react
```
<details>
<summary>
Manual Installation
</summary>
If you already have generated ShapeTypes, you may install the `@ldo/ldo` and `@ldo/solid` libraries independently.
```
npm i @ldo/ldo@ldo/solid@ldo/solid-react
```
</details>
## Simple Example
Below is a simple example of @ldo/solid-react in a real use-case. Assume that a ShapeType was previously generated and placed at `./.ldo/solidProfile.shapeTypess`.
```typescript
import type { FunctionComponent } from "react";
import React, { useCallback } from "react";
import {
BrowserSolidLdoProvider,
useResource,
useSolidAuth,
useSubject,
} from "@ldo/solid-react";
import { SolidProfileShapeShapeType } from "./.ldo/solidProfile.shapeTypes";
import { changeData, commitData } from "@ldo/solid";
// The base component for the app
const App: FunctionComponent = () => {
return (
/* The application should be surrounded with the BrowserSolidLdoProvider
this will set up all the underlying infrastructure for the application */
<BrowserSolidLdoProvider>
<Login/>
</BrowserSolidLdoProvider>
);
};
// A component that handles login
const Login: FunctionComponent = () => {
// Get login information using the "useSolidAuth" hook
This project was made possible by a grant from NGI Zero Entrust via nlnet. Learn more on the [NLnet project page](https://nlnet.nl/project/SolidUsableApps/).
@ -11,4 +135,4 @@ This project was made possible by a grant from NGI Zero Entrust via nlnet. Learn
[<img src="https://nlnet.nl/image/logos/NGI0Entrust_tag.svg" alt="NGI Zero Entrust Logo" width="300" />](https://nlnet.nl/)