@ldo/connected-nextgraph 1.0.0-alpha.2 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -3
- package/dist/NextGraphConnectedPlugin.d.ts +1 -0
- package/dist/NextGraphConnectedPlugin.js +1 -5
- package/dist/NextGraphConnectedPlugin.js.map +1 -1
- package/dist/notifications/NextGraphNotificationSubscription.js +1 -5
- package/dist/notifications/NextGraphNotificationSubscription.js.map +1 -1
- package/dist/resources/NextGraphResource.js +2 -3
- package/dist/resources/NextGraphResource.js.map +1 -1
- package/package.json +7 -7
- package/src/NextGraphConnectedPlugin.ts +4 -2
- package/src/notifications/NextGraphNotificationSubscription.ts +1 -2
- package/src/resources/NextGraphResource.ts +2 -3
package/README.md
CHANGED
|
@@ -7,7 +7,16 @@ The `@ldo/connected-nextgraph` library allows you to integrate [NextGraph](https
|
|
|
7
7
|
First, install the required libraries:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install
|
|
10
|
+
npm install @ldo/connected-nextgraph
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Also install a version of next-graph you wish to use
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# For applications on NodeJS
|
|
17
|
+
npm install nextgraph
|
|
18
|
+
# For applications running in the web browser
|
|
19
|
+
npm install nextgraphweb
|
|
11
20
|
```
|
|
12
21
|
|
|
13
22
|
## Usage:
|
|
@@ -26,7 +35,7 @@ const ldoDataset = createNextGraphLdoDataset();
|
|
|
26
35
|
Before you can create or access resources, you need an active session:
|
|
27
36
|
|
|
28
37
|
```ts
|
|
29
|
-
import ng from "nextgraph"
|
|
38
|
+
import ng from "nextgraph" // or `import ng from "nextgraphweb"` for the browser
|
|
30
39
|
|
|
31
40
|
// Open your nextgraph wallet
|
|
32
41
|
const openedWallet = await ng.wallet_open_with_mnemonic_words(
|
|
@@ -45,9 +54,9 @@ const session = await ng.session_in_memory_start(
|
|
|
45
54
|
---
|
|
46
55
|
|
|
47
56
|
### 3. Link Your Dataset to the NextGraph Session
|
|
48
|
-
|
|
49
57
|
```ts
|
|
50
58
|
ldoDataset.setContext("nextgraph", {
|
|
59
|
+
ng,
|
|
51
60
|
sessionId: session.session_id
|
|
52
61
|
});
|
|
53
62
|
```
|
|
@@ -114,6 +123,59 @@ await resource.update({
|
|
|
114
123
|
});
|
|
115
124
|
```
|
|
116
125
|
|
|
126
|
+
## Using NextGraph with React
|
|
127
|
+
|
|
128
|
+
You can also use the `@ldo/react` library with `@ldo/connected-nextgraph`.
|
|
129
|
+
|
|
130
|
+
### 1. Create the react methods
|
|
131
|
+
|
|
132
|
+
First, we initialize some methods to use with the `@ldo/connected-nextgraph` and
|
|
133
|
+
`@ldo/react` libraries.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// ./reactMethods.ts
|
|
137
|
+
import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph";
|
|
138
|
+
import { createLdoReactMethods } from "@ldo/react";
|
|
139
|
+
import ng from "nextgraphweb";
|
|
140
|
+
|
|
141
|
+
export const {
|
|
142
|
+
dataset,
|
|
143
|
+
useLdo,
|
|
144
|
+
useMatchObject,
|
|
145
|
+
useMatchSubject,
|
|
146
|
+
useResource,
|
|
147
|
+
useSubject,
|
|
148
|
+
useSubscribeToResource,
|
|
149
|
+
} = createLdoReactMethods([nextGraphConnectedPlugin]);
|
|
150
|
+
|
|
151
|
+
// Set NG on the data. When the sessionId is retrieved, `setContext` can be
|
|
152
|
+
// called at any time to set that as well.
|
|
153
|
+
dataset.setContext("nextgraph", {
|
|
154
|
+
ng,
|
|
155
|
+
sessionId: "SOME_ID"
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 2. Use the methods in your React components
|
|
160
|
+
|
|
161
|
+
From there, you can import these created methods in your React component and use
|
|
162
|
+
them as you would use any of the methods in the [@ldo/react-solid](https://ldo.js.org/latest/guides/solid_react/)
|
|
163
|
+
library.
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { FunctionComponent } from "react";
|
|
167
|
+
import { PostShShapeType } from "./.ldo/post.shapeTypes";
|
|
168
|
+
import { useResource, useSubject } from "./reactMethods";
|
|
169
|
+
|
|
170
|
+
export const UseSubjectTest: FunctionComponent = () => {
|
|
171
|
+
useResource("did:ng:SOME_URI");
|
|
172
|
+
const post = useSubject(PostShShapeType, `SomeOtherUri`);
|
|
173
|
+
|
|
174
|
+
return <p role="article">{post.articleBody}</p>;
|
|
175
|
+
};
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
|
|
117
179
|
## Sponsorship
|
|
118
180
|
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/).
|
|
119
181
|
|
|
@@ -2,6 +2,7 @@ import type { ConnectedContext, ConnectedPlugin } from "@ldo/connected";
|
|
|
2
2
|
import type { NextGraphUri } from "./types";
|
|
3
3
|
import { NextGraphResource } from "./resources/NextGraphResource";
|
|
4
4
|
export interface NextGraphConnectedContext {
|
|
5
|
+
ng?: any;
|
|
5
6
|
sessionId?: string;
|
|
6
7
|
protectedStoreId?: string;
|
|
7
8
|
privateStoreId?: string;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.nextGraphConnectedPlugin = void 0;
|
|
7
4
|
const NextGraphResource_1 = require("./resources/NextGraphResource");
|
|
8
|
-
const nextgraph_1 = __importDefault(require("nextgraph"));
|
|
9
5
|
const isNextGraphUri_1 = require("./util/isNextGraphUri");
|
|
10
6
|
exports.nextGraphConnectedPlugin = {
|
|
11
7
|
name: "nextgraph",
|
|
@@ -22,7 +18,7 @@ exports.nextGraphConnectedPlugin = {
|
|
|
22
18
|
: storeType === "private"
|
|
23
19
|
? context.nextgraph.privateStoreId
|
|
24
20
|
: undefined);
|
|
25
|
-
const nuri = await
|
|
21
|
+
const nuri = await context.nextgraph.ng.doc_create(context.nextgraph.sessionId, "Graph", "data:graph", "store", storeType, storeRepo);
|
|
26
22
|
const newResource = new NextGraphResource_1.NextGraphResource(nuri, context);
|
|
27
23
|
await newResource.read();
|
|
28
24
|
return newResource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphConnectedPlugin.js","sourceRoot":"","sources":["../src/NextGraphConnectedPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NextGraphConnectedPlugin.js","sourceRoot":"","sources":["../src/NextGraphConnectedPlugin.ts"],"names":[],"mappings":";;;AAEA,qEAAkE;AAClE,0DAAuD;AAiC1C,QAAA,wBAAwB,GAA6B;IAChE,IAAI,EAAE,WAAW;IAEjB,WAAW,EAAE,UACX,GAAiB,EACjB,OAAqD;QAErD,OAAO,IAAI,qCAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,cAAc,EAAE,KAAK,WACnB,OAAqD,EACrD,OAAwC;QAExC,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,CAAC;QACrC,MAAM,SAAS,GACb,OAAO,EAAE,SAAS;YAClB,CAAC,SAAS,KAAK,WAAW;gBACxB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB;gBACpC,CAAC,CAAC,SAAS,KAAK,QAAQ;oBACxB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa;oBACjC,CAAC,CAAC,SAAS,KAAK,SAAS;wBACzB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc;wBAClC,CAAC,CAAC,SAAS,CAAC,CAAC;QAEjB,MAAM,IAAI,GAAiB,MAAM,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,UAAU,CAC9D,OAAO,CAAC,SAAS,CAAC,SAAS,EAC3B,OAAO,EACP,YAAY,EACZ,OAAO,EACP,SAAS,EACT,SAAS,CACV,CAAC;QACF,MAAM,WAAW,GAAG,IAAI,qCAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzD,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,UAAU,EAAE,UAAU,GAAW;QAC/B,OAAO,IAAA,+BAAc,EAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,cAAc,EAAE;QACd,SAAS,EAAE,SAAS;KACrB;IAGD,KAAK,EAAE,EAAE;CACV,CAAC"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.NextGraphNotificationSubscription = void 0;
|
|
7
4
|
const connected_1 = require("@ldo/connected");
|
|
8
|
-
const nextgraph_1 = __importDefault(require("nextgraph"));
|
|
9
5
|
class NextGraphNotificationSubscription extends connected_1.NotificationSubscription {
|
|
10
6
|
async open() {
|
|
11
7
|
console.log("THIS WAS OPENED AND IT SHOULDNT BE");
|
|
12
|
-
this.unsub = await
|
|
8
|
+
this.unsub = await this.context.nextgraph.ng.doc_subscribe(this.resource.uri, this.context.nextgraph.sessionId, this.onNotification.bind(this));
|
|
13
9
|
}
|
|
14
10
|
async close() {
|
|
15
11
|
this.unsub?.();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphNotificationSubscription.js","sourceRoot":"","sources":["../../src/notifications/NextGraphNotificationSubscription.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NextGraphNotificationSubscription.js","sourceRoot":"","sources":["../../src/notifications/NextGraphNotificationSubscription.ts"],"names":[],"mappings":";;;AAAA,8CAA0D;AAI1D,MAAa,iCAAkC,SAAQ,oCAGtD;IAGW,KAAK,CAAC,IAAI;QAClB,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,aAAa,CACxD,IAAI,CAAC,QAAQ,CAAC,GAAG,EACjB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,EAChC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAC/B,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,KAAK;QACnB,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF;AAnBD,8EAmBC"}
|
|
@@ -7,7 +7,6 @@ exports.NextGraphResource = void 0;
|
|
|
7
7
|
const connected_1 = require("@ldo/connected");
|
|
8
8
|
const connected_2 = require("@ldo/connected");
|
|
9
9
|
const events_1 = __importDefault(require("events"));
|
|
10
|
-
const nextgraph_1 = __importDefault(require("nextgraph"));
|
|
11
10
|
const rdf_utils_1 = require("@ldo/rdf-utils");
|
|
12
11
|
const data_model_1 = require("@rdfjs/data-model");
|
|
13
12
|
const NextGraphReadSuccess_1 = require("../results/NextGraphReadSuccess");
|
|
@@ -70,7 +69,7 @@ class NextGraphResource extends events_1.default {
|
|
|
70
69
|
await new Promise(async (resolve, reject) => {
|
|
71
70
|
let unsub;
|
|
72
71
|
try {
|
|
73
|
-
unsub = await
|
|
72
|
+
unsub = await this.context.nextgraph.ng.doc_subscribe(this.uri, this.context.nextgraph.sessionId, async (response) => {
|
|
74
73
|
if (response.V0.State) {
|
|
75
74
|
unsub();
|
|
76
75
|
await this.onNotification(response);
|
|
@@ -114,7 +113,7 @@ class NextGraphResource extends events_1.default {
|
|
|
114
113
|
this.emit("update");
|
|
115
114
|
this.context.dataset.bulk(datasetChanges);
|
|
116
115
|
try {
|
|
117
|
-
await
|
|
116
|
+
await this.context.nextgraph.ng.sparql_update(this.context.nextgraph.sessionId, await (0, rdf_utils_1.changesToSparqlUpdate)(datasetChanges), this.uri);
|
|
118
117
|
return new connected_1.UpdateSuccess(this);
|
|
119
118
|
}
|
|
120
119
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphResource.js","sourceRoot":"","sources":["../../src/resources/NextGraphResource.ts"],"names":[],"mappings":";;;;;;AAKA,8CAAwE;AACxE,8CAKwB;AAExB,oDAAkC;AAElC,
|
|
1
|
+
{"version":3,"file":"NextGraphResource.js","sourceRoot":"","sources":["../../src/resources/NextGraphResource.ts"],"names":[],"mappings":";;;;;;AAKA,8CAAwE;AACxE,8CAKwB;AAExB,oDAAkC;AAElC,8CAA4E;AAG5E,kDAAkE;AAClE,0EAAuE;AACvE,0GAAuG;AACvG,kCAAoC;AAEpC,0CAA6C;AAE7C,MAAa,iBACX,SAAS,gBAA+C;IAsBxD,YACE,GAAiB,EACjB,OAAqD;QAErD,KAAK,EAAE,CAAC;QAtBM,SAAI,GAAG,mBAA4B,CAAC;QACpC,YAAO,GAAG,KAAc,CAAC;QAIjC,YAAO,GAAY,KAAK,CAAC;QACzB,YAAO,GAAY,KAAK,CAAC;QACzB,YAAO,GAAwB,SAAS,CAAC;QAgB/C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,wBAAwB,GAAG,IAAI,qEAAiC,CACnE,IAAI,EACJ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAC9B,IAAI,CAAC,OAAO,CACb,CAAC;IACJ,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,SAAS;QACP,OAAO,IA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EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAChC,CAAC;YACF,MAAM,aAAa,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAC5C,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAChC,CAAC;YAEF,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CACxC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBAC/C,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YACvC,CAAC,CAAC,CACH,CAAC;YAEF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;gBACxB,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,KAAK,CAAC,wBAAwB,CAC5B,SAA+D;QAE/D,OAAO,MAAM,IAAI,CAAC,wBAAwB,CAAC,wBAAwB,CACjE,SAAS,CACV,CAAC;IACJ,CAAC;IAED,4BAA4B,CAAC,cAAsB;QACjD,OAAO,IAAI,CAAC,wBAAwB,CAAC,2BAA2B,CAC9D,cAAc,CACf,CAAC;IACJ,CAAC;IAED,+BAA+B;QAC7B,OAAO,IAAI,CAAC,wBAAwB,CAAC,+BAA+B,EAAE,CAAC;IACzE,CAAC;CACF;AAxPD,8CAwPC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/connected-nextgraph",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"description": "A plugin for @ldo/connected to work with the Solid ecosystem.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"homepage": "https://github.com/o-development/ldobjects/tree/main/packages/solid#readme",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@inrupt/solid-client-authn-core": "^2.2.6",
|
|
29
|
-
"@ldo/cli": "^1.0.0-alpha.
|
|
29
|
+
"@ldo/cli": "^1.0.0-alpha.3",
|
|
30
30
|
"@rdfjs/data-model": "^1.2.0",
|
|
31
31
|
"@rdfjs/types": "^1.0.1",
|
|
32
32
|
"@solid-notifications/types": "^0.1.2",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"cross-env": "^7.0.3",
|
|
35
35
|
"dotenv": "^16.3.1",
|
|
36
36
|
"jest-rdf": "^1.8.0",
|
|
37
|
+
"nextgraph": "^0.1.1-alpha.7",
|
|
37
38
|
"start-server-and-test": "^2.0.11",
|
|
38
39
|
"ts-node": "^10.9.1",
|
|
39
40
|
"typed-emitter": "^2.1.0",
|
|
@@ -41,13 +42,12 @@
|
|
|
41
42
|
"typedoc-plugin-markdown": "^3.17.1"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@ldo/dataset": "^1.0.0-alpha.
|
|
45
|
-
"@ldo/ldo": "^1.0.0-alpha.
|
|
46
|
-
"@ldo/rdf-utils": "^1.0.0-alpha.
|
|
45
|
+
"@ldo/dataset": "^1.0.0-alpha.3",
|
|
46
|
+
"@ldo/ldo": "^1.0.0-alpha.3",
|
|
47
|
+
"@ldo/rdf-utils": "^1.0.0-alpha.3",
|
|
47
48
|
"@solid-notifications/subscription": "^0.1.2",
|
|
48
49
|
"cross-fetch": "^3.1.6",
|
|
49
50
|
"http-link-header": "^1.1.1",
|
|
50
|
-
"nextgraph": "^0.1.1-alpha.7",
|
|
51
51
|
"ws": "^8.18.0"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "e1995e01e769d2ba37e419c661171606e1941c3c"
|
|
61
61
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ConnectedContext, ConnectedPlugin } from "@ldo/connected";
|
|
2
2
|
import type { NextGraphUri } from "./types";
|
|
3
3
|
import { NextGraphResource } from "./resources/NextGraphResource";
|
|
4
|
-
import ng from "nextgraph";
|
|
5
4
|
import { isNextGraphUri } from "./util/isNextGraphUri";
|
|
6
5
|
|
|
7
6
|
export interface NextGraphConnectedContext {
|
|
7
|
+
// NG does not have a type definition
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
ng?: any;
|
|
8
10
|
sessionId?: string;
|
|
9
11
|
protectedStoreId?: string;
|
|
10
12
|
privateStoreId?: string;
|
|
@@ -57,7 +59,7 @@ export const nextGraphConnectedPlugin: NextGraphConnectedPlugin = {
|
|
|
57
59
|
? context.nextgraph.privateStoreId
|
|
58
60
|
: undefined);
|
|
59
61
|
|
|
60
|
-
const nuri: NextGraphUri = await ng.doc_create(
|
|
62
|
+
const nuri: NextGraphUri = await context.nextgraph.ng.doc_create(
|
|
61
63
|
context.nextgraph.sessionId,
|
|
62
64
|
"Graph",
|
|
63
65
|
"data:graph",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { NotificationSubscription } from "@ldo/connected";
|
|
2
2
|
import type { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin";
|
|
3
3
|
import type { NextGraphNotificationMessage } from "./NextGraphNotificationMessage";
|
|
4
|
-
import ng from "nextgraph";
|
|
5
4
|
|
|
6
5
|
export class NextGraphNotificationSubscription extends NotificationSubscription<
|
|
7
6
|
NextGraphConnectedPlugin,
|
|
@@ -11,7 +10,7 @@ export class NextGraphNotificationSubscription extends NotificationSubscription<
|
|
|
11
10
|
|
|
12
11
|
protected async open(): Promise<void> {
|
|
13
12
|
console.log("THIS WAS OPENED AND IT SHOULDNT BE");
|
|
14
|
-
this.unsub = await ng.doc_subscribe(
|
|
13
|
+
this.unsub = await this.context.nextgraph.ng.doc_subscribe(
|
|
15
14
|
this.resource.uri,
|
|
16
15
|
this.context.nextgraph.sessionId,
|
|
17
16
|
this.onNotification.bind(this),
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import type { NextGraphUri } from "../types";
|
|
14
14
|
import EventEmitter from "events";
|
|
15
15
|
import type { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin";
|
|
16
|
-
import ng from "nextgraph";
|
|
17
16
|
import { changesToSparqlUpdate, type DatasetChanges } from "@ldo/rdf-utils";
|
|
18
17
|
import type { NextGraphNotificationMessage } from "../notifications/NextGraphNotificationMessage";
|
|
19
18
|
import type { Dataset, Quad } from "@rdfjs/types";
|
|
@@ -127,7 +126,7 @@ export class NextGraphResource
|
|
|
127
126
|
await new Promise<void>(async (resolve, reject) => {
|
|
128
127
|
let unsub: () => void;
|
|
129
128
|
try {
|
|
130
|
-
unsub = await ng.doc_subscribe(
|
|
129
|
+
unsub = await this.context.nextgraph.ng.doc_subscribe(
|
|
131
130
|
this.uri,
|
|
132
131
|
this.context.nextgraph.sessionId,
|
|
133
132
|
async (response: NextGraphNotificationMessage) => {
|
|
@@ -188,7 +187,7 @@ export class NextGraphResource
|
|
|
188
187
|
|
|
189
188
|
try {
|
|
190
189
|
// Perform Update with remote
|
|
191
|
-
await ng.sparql_update(
|
|
190
|
+
await this.context.nextgraph.ng.sparql_update(
|
|
192
191
|
this.context.nextgraph.sessionId,
|
|
193
192
|
await changesToSparqlUpdate(datasetChanges),
|
|
194
193
|
this.uri,
|