@ldo/connected-nextgraph 1.0.0-alpha.36 → 1.0.0-alpha.43
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 +11 -9
- package/dist/NextGraphConnectedPlugin.cjs +6 -9
- package/dist/NextGraphConnectedPlugin.d.cts +0 -2
- package/dist/NextGraphConnectedPlugin.d.cts.map +1 -1
- package/dist/{NextGraphConnectedPlugin.d.ts → NextGraphConnectedPlugin.d.mts} +4 -6
- package/dist/NextGraphConnectedPlugin.d.mts.map +1 -0
- package/dist/{NextGraphConnectedPlugin.js → NextGraphConnectedPlugin.mjs} +5 -7
- package/dist/NextGraphConnectedPlugin.mjs.map +1 -0
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +2 -9
- package/dist/createNextGraphLdoDataset.cjs +7 -10
- package/dist/createNextGraphLdoDataset.d.cts +0 -2
- package/dist/createNextGraphLdoDataset.d.cts.map +1 -1
- package/dist/{createNextGraphLdoDataset.d.ts → createNextGraphLdoDataset.d.mts} +2 -4
- package/dist/createNextGraphLdoDataset.d.mts.map +1 -0
- package/dist/{createNextGraphLdoDataset.js → createNextGraphLdoDataset.mjs} +4 -6
- package/dist/createNextGraphLdoDataset.mjs.map +1 -0
- package/dist/index.cjs +11 -11
- package/dist/index.d.mts +7 -0
- package/dist/{index.js → index.mjs} +6 -7
- package/dist/notifications/NextGraphNotificationMessage.d.cts +0 -1
- package/dist/notifications/NextGraphNotificationMessage.d.cts.map +1 -1
- package/dist/notifications/{NextGraphNotificationMessage.d.ts → NextGraphNotificationMessage.d.mts} +1 -2
- package/dist/notifications/NextGraphNotificationMessage.d.mts.map +1 -0
- package/dist/notifications/NextGraphNotificationSubscription.cjs +4 -7
- package/dist/notifications/{NextGraphNotificationSubscription.js → NextGraphNotificationSubscription.mjs} +2 -4
- package/dist/notifications/NextGraphNotificationSubscription.mjs.map +1 -0
- package/dist/resources/NextGraphResource.cjs +28 -38
- package/dist/resources/NextGraphResource.d.cts.map +1 -1
- package/dist/resources/{NextGraphResource.d.ts → NextGraphResource.d.mts} +6 -6
- package/dist/resources/NextGraphResource.d.mts.map +1 -0
- package/dist/resources/{NextGraphResource.js → NextGraphResource.mjs} +10 -20
- package/dist/resources/NextGraphResource.mjs.map +1 -0
- package/dist/results/NextGraphReadSuccess.cjs +8 -7
- package/dist/results/NextGraphReadSuccess.d.cts +0 -2
- package/dist/results/NextGraphReadSuccess.d.cts.map +1 -1
- package/dist/results/NextGraphReadSuccess.d.mts +10 -0
- package/dist/results/NextGraphReadSuccess.d.mts.map +1 -0
- package/dist/results/{NextGraphReadSuccess.js → NextGraphReadSuccess.mjs} +6 -4
- package/dist/results/NextGraphReadSuccess.mjs.map +1 -0
- package/dist/types.d.cts +0 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/{types.d.ts → types.d.mts} +1 -2
- package/dist/types.d.mts.map +1 -0
- package/dist/util/isNextGraphUri.cjs +1 -3
- package/dist/util/isNextGraphUri.d.cts +0 -2
- package/dist/util/isNextGraphUri.d.cts.map +1 -1
- package/dist/util/{isNextGraphUri.d.ts → isNextGraphUri.d.mts} +3 -5
- package/dist/util/isNextGraphUri.d.mts.map +1 -0
- package/dist/util/{isNextGraphUri.js → isNextGraphUri.mjs} +2 -2
- package/dist/util/isNextGraphUri.mjs.map +1 -0
- package/package.json +14 -13
- package/dist/NextGraphConnectedPlugin.d.ts.map +0 -1
- package/dist/NextGraphConnectedPlugin.js.map +0 -1
- package/dist/createNextGraphLdoDataset.d.ts.map +0 -1
- package/dist/createNextGraphLdoDataset.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/notifications/NextGraphNotificationMessage.d.ts.map +0 -1
- package/dist/notifications/NextGraphNotificationSubscription.js.map +0 -1
- package/dist/resources/NextGraphResource.d.ts.map +0 -1
- package/dist/resources/NextGraphResource.js.map +0 -1
- package/dist/results/NextGraphReadSuccess.d.ts +0 -12
- package/dist/results/NextGraphReadSuccess.d.ts.map +0 -1
- package/dist/results/NextGraphReadSuccess.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/util/isNextGraphUri.d.ts.map +0 -1
- package/dist/util/isNextGraphUri.js.map +0 -1
package/README.md
CHANGED
|
@@ -35,29 +35,30 @@ const ldoDataset = createNextGraphLdoDataset();
|
|
|
35
35
|
Before you can create or access resources, you need an active session:
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
|
-
import ng from "nextgraph" // or `import ng from "nextgraphweb"` for the browser
|
|
38
|
+
import ng from "nextgraph"; // or `import ng from "nextgraphweb"` for the browser
|
|
39
39
|
|
|
40
40
|
// Open your nextgraph wallet
|
|
41
41
|
const openedWallet = await ng.wallet_open_with_mnemonic_words(
|
|
42
42
|
walletBinary,
|
|
43
43
|
mnemonic,
|
|
44
|
-
[1, 2, 3, 4]
|
|
44
|
+
[1, 2, 3, 4],
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
// Start a session
|
|
48
48
|
const session = await ng.session_in_memory_start(
|
|
49
49
|
openedWallet.V0.wallet_id,
|
|
50
|
-
openedWallet.V0.personal_site
|
|
50
|
+
openedWallet.V0.personal_site,
|
|
51
51
|
);
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
56
56
|
### 3. Link Your Dataset to the NextGraph Session
|
|
57
|
+
|
|
57
58
|
```ts
|
|
58
59
|
ldoDataset.setContext("nextgraph", {
|
|
59
60
|
ng,
|
|
60
|
-
sessionId: session.session_id
|
|
61
|
+
sessionId: session.session_id,
|
|
61
62
|
});
|
|
62
63
|
```
|
|
63
64
|
|
|
@@ -72,7 +73,7 @@ if (!resource.isError) {
|
|
|
72
73
|
}
|
|
73
74
|
```
|
|
74
75
|
|
|
75
|
-
### 5. Read and Monitor a Resource
|
|
76
|
+
### 5. Read and Monitor a Resource\*\*
|
|
76
77
|
|
|
77
78
|
#### Read Existing Resource
|
|
78
79
|
|
|
@@ -119,7 +120,7 @@ const triples = await parseRdf(ttlData);
|
|
|
119
120
|
|
|
120
121
|
await resource.update({
|
|
121
122
|
added: triples,
|
|
122
|
-
removed: undefined
|
|
123
|
+
removed: undefined,
|
|
123
124
|
});
|
|
124
125
|
```
|
|
125
126
|
|
|
@@ -152,7 +153,7 @@ export const {
|
|
|
152
153
|
// called at any time to set that as well.
|
|
153
154
|
dataset.setContext("nextgraph", {
|
|
154
155
|
ng,
|
|
155
|
-
sessionId: "SOME_ID"
|
|
156
|
+
sessionId: "SOME_ID",
|
|
156
157
|
});
|
|
157
158
|
```
|
|
158
159
|
|
|
@@ -164,7 +165,7 @@ library.
|
|
|
164
165
|
|
|
165
166
|
```typescript
|
|
166
167
|
import { FunctionComponent } from "react";
|
|
167
|
-
import { PostShShapeType } from "
|
|
168
|
+
import { PostShShapeType } from "./_ldo/post.shapeTypes.js";
|
|
168
169
|
import { useResource, useSubject } from "./reactMethods.js";
|
|
169
170
|
|
|
170
171
|
export const UseSubjectTest: FunctionComponent = () => {
|
|
@@ -175,12 +176,13 @@ export const UseSubjectTest: FunctionComponent = () => {
|
|
|
175
176
|
};
|
|
176
177
|
```
|
|
177
178
|
|
|
178
|
-
|
|
179
179
|
## Sponsorship
|
|
180
|
+
|
|
180
181
|
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/).
|
|
181
182
|
|
|
182
183
|
[<img src="https://nlnet.nl/logo/banner.png" alt="nlnet foundation logo" width="300" />](https://nlnet.nl/)
|
|
183
184
|
[<img src="https://nlnet.nl/image/logos/NGI0Entrust_tag.svg" alt="NGI Zero Entrust Logo" width="300" />](https://nlnet.nl/)
|
|
184
185
|
|
|
185
186
|
## Liscense
|
|
187
|
+
|
|
186
188
|
MIT
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
const require_NextGraphResource = require("./resources/NextGraphResource.cjs");
|
|
2
|
+
const require_isNextGraphUri = require("./util/isNextGraphUri.cjs");
|
|
4
3
|
//#region src/NextGraphConnectedPlugin.ts
|
|
5
4
|
const nextGraphConnectedPlugin = {
|
|
6
5
|
name: "nextgraph",
|
|
7
6
|
getResource: function(uri, context) {
|
|
8
|
-
return new
|
|
7
|
+
return new require_NextGraphResource.NextGraphResource(uri, context);
|
|
9
8
|
},
|
|
10
9
|
createResource: async function(context, options) {
|
|
11
10
|
const storeType = options?.storeType;
|
|
12
11
|
const storeRepo = options?.storeRepo ?? (storeType === "protected" ? context.nextgraph.protectedStoreId : storeType === "public" ? context.nextgraph.publicStoreId : storeType === "private" ? context.nextgraph.privateStoreId : void 0);
|
|
13
12
|
const primaryClass = options?.primaryClass ?? "data:graph";
|
|
14
|
-
const
|
|
15
|
-
const newResource = new require__Users_jacksonmorgan_O_ldo_packages_connected_nextgraph_src_resources_NextGraphResource.NextGraphResource(nuri, context);
|
|
13
|
+
const newResource = new require_NextGraphResource.NextGraphResource(await context.nextgraph.ng.doc_create(context.nextgraph.sessionId, "Graph", primaryClass, "store", storeType, storeRepo), context);
|
|
16
14
|
await newResource.read();
|
|
17
15
|
return newResource;
|
|
18
16
|
},
|
|
19
17
|
isUriValid: function(uri) {
|
|
20
|
-
return
|
|
18
|
+
return require_isNextGraphUri.isNextGraphUri(uri);
|
|
21
19
|
},
|
|
22
20
|
initialContext: { sessionId: void 0 },
|
|
23
21
|
types: {}
|
|
24
22
|
};
|
|
25
|
-
|
|
26
23
|
//#endregion
|
|
27
|
-
exports.nextGraphConnectedPlugin = nextGraphConnectedPlugin;
|
|
24
|
+
exports.nextGraphConnectedPlugin = nextGraphConnectedPlugin;
|
|
@@ -21,8 +21,6 @@ interface NextGraphConnectedPlugin extends ConnectedPlugin<"nextgraph", NextGrap
|
|
|
21
21
|
createResource(context: ConnectedContext<this[]>): Promise<NextGraphResource>;
|
|
22
22
|
}
|
|
23
23
|
declare const nextGraphConnectedPlugin: NextGraphConnectedPlugin;
|
|
24
|
-
//# sourceMappingURL=NextGraphConnectedPlugin.d.ts.map
|
|
25
|
-
|
|
26
24
|
//#endregion
|
|
27
25
|
export { NextGraphConnectedContext, NextGraphConnectedPlugin, NextGraphCreateResourceOptions, nextGraphConnectedPlugin };
|
|
28
26
|
//# sourceMappingURL=NextGraphConnectedPlugin.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphConnectedPlugin.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"NextGraphConnectedPlugin.d.cts","names":[],"sources":["../src/NextGraphConnectedPlugin.ts"],"mappings":";;;;;UAKiB,yBAAA;EAGf,EAAA;EACA,SAAA;EACA,gBAAA;EACA,cAAA;EACA,aAAA;AAAA;AAAA,UAGe,8BAAA;EACf,SAAA;EACA,SAAA;EACA,YAAA;AAAA;AAAA,UAGe,wBAAA,SACP,eAAA,cAEN,YAAA,EACA,iBAAA,EACA,yBAAA,EACA,8BAAA;EAEF,IAAA;EACA,WAAA,GACE,GAAA,EAAK,YAAA,EACL,OAAA,EAAS,gBAAA,aACN,iBAAA;EACL,cAAA,CAAe,OAAA,EAAS,gBAAA,WAA2B,OAAA,CAAQ,iBAAA;AAAA;AAAA,cAGhD,wBAAA,EAA0B,wBAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NextGraphUri } from "./types.
|
|
2
|
-
import { NextGraphResource
|
|
1
|
+
import { NextGraphUri } from "./types.mjs";
|
|
2
|
+
import { NextGraphResource } from "./resources/NextGraphResource.mjs";
|
|
3
3
|
import { ConnectedContext, ConnectedPlugin } from "@ldo/connected";
|
|
4
4
|
|
|
5
5
|
//#region src/NextGraphConnectedPlugin.d.ts
|
|
@@ -21,8 +21,6 @@ interface NextGraphConnectedPlugin extends ConnectedPlugin<"nextgraph", NextGrap
|
|
|
21
21
|
createResource(context: ConnectedContext<this[]>): Promise<NextGraphResource>;
|
|
22
22
|
}
|
|
23
23
|
declare const nextGraphConnectedPlugin: NextGraphConnectedPlugin;
|
|
24
|
-
//# sourceMappingURL=NextGraphConnectedPlugin.d.ts.map
|
|
25
|
-
|
|
26
24
|
//#endregion
|
|
27
|
-
export { NextGraphConnectedContext, NextGraphConnectedPlugin, NextGraphCreateResourceOptions, nextGraphConnectedPlugin
|
|
28
|
-
//# sourceMappingURL=NextGraphConnectedPlugin.d.
|
|
25
|
+
export { NextGraphConnectedContext, NextGraphConnectedPlugin, NextGraphCreateResourceOptions, nextGraphConnectedPlugin };
|
|
26
|
+
//# sourceMappingURL=NextGraphConnectedPlugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphConnectedPlugin.d.mts","names":[],"sources":["../src/NextGraphConnectedPlugin.ts"],"mappings":";;;;;UAKiB,yBAAA;EAGf,EAAA;EACA,SAAA;EACA,gBAAA;EACA,cAAA;EACA,aAAA;AAAA;AAAA,UAGe,8BAAA;EACf,SAAA;EACA,SAAA;EACA,YAAA;AAAA;AAAA,UAGe,wBAAA,SACP,eAAA,cAEN,YAAA,EACA,iBAAA,EACA,yBAAA,EACA,8BAAA;EAEF,IAAA;EACA,WAAA,GACE,GAAA,EAAK,YAAA,EACL,OAAA,EAAS,gBAAA,aACN,iBAAA;EACL,cAAA,CAAe,OAAA,EAAS,gBAAA,WAA2B,OAAA,CAAQ,iBAAA;AAAA;AAAA,cAGhD,wBAAA,EAA0B,wBAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { NextGraphResource } from "./resources/NextGraphResource.
|
|
2
|
-
import { isNextGraphUri } from "./util/isNextGraphUri.
|
|
3
|
-
|
|
1
|
+
import { NextGraphResource } from "./resources/NextGraphResource.mjs";
|
|
2
|
+
import { isNextGraphUri } from "./util/isNextGraphUri.mjs";
|
|
4
3
|
//#region src/NextGraphConnectedPlugin.ts
|
|
5
4
|
const nextGraphConnectedPlugin = {
|
|
6
5
|
name: "nextgraph",
|
|
@@ -11,8 +10,7 @@ const nextGraphConnectedPlugin = {
|
|
|
11
10
|
const storeType = options?.storeType;
|
|
12
11
|
const storeRepo = options?.storeRepo ?? (storeType === "protected" ? context.nextgraph.protectedStoreId : storeType === "public" ? context.nextgraph.publicStoreId : storeType === "private" ? context.nextgraph.privateStoreId : void 0);
|
|
13
12
|
const primaryClass = options?.primaryClass ?? "data:graph";
|
|
14
|
-
const
|
|
15
|
-
const newResource = new NextGraphResource(nuri, context);
|
|
13
|
+
const newResource = new NextGraphResource(await context.nextgraph.ng.doc_create(context.nextgraph.sessionId, "Graph", primaryClass, "store", storeType, storeRepo), context);
|
|
16
14
|
await newResource.read();
|
|
17
15
|
return newResource;
|
|
18
16
|
},
|
|
@@ -22,7 +20,7 @@ const nextGraphConnectedPlugin = {
|
|
|
22
20
|
initialContext: { sessionId: void 0 },
|
|
23
21
|
types: {}
|
|
24
22
|
};
|
|
25
|
-
|
|
26
23
|
//#endregion
|
|
27
24
|
export { nextGraphConnectedPlugin };
|
|
28
|
-
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=NextGraphConnectedPlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphConnectedPlugin.mjs","names":[],"sources":["../src/NextGraphConnectedPlugin.ts"],"sourcesContent":["import type { ConnectedContext, ConnectedPlugin } from \"@ldo/connected\";\nimport type { NextGraphUri } from \"./types\";\nimport { NextGraphResource } from \"./resources/NextGraphResource\";\nimport { isNextGraphUri } from \"./util/isNextGraphUri\";\n\nexport interface NextGraphConnectedContext {\n // NG does not have a type definition\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ng?: any;\n sessionId?: string;\n protectedStoreId?: string;\n privateStoreId?: string;\n publicStoreId?: string;\n}\n\nexport interface NextGraphCreateResourceOptions {\n storeType?: \"public\" | \"protected\" | \"private\" | \"group\" | \"dialog\";\n storeRepo?: string;\n primaryClass?: string;\n}\n\nexport interface NextGraphConnectedPlugin\n extends ConnectedPlugin<\n \"nextgraph\",\n NextGraphUri,\n NextGraphResource,\n NextGraphConnectedContext,\n NextGraphCreateResourceOptions\n > {\n name: \"nextgraph\";\n getResource: (\n uri: NextGraphUri,\n context: ConnectedContext<this[]>,\n ) => NextGraphResource;\n createResource(context: ConnectedContext<this[]>): Promise<NextGraphResource>;\n}\n\nexport const nextGraphConnectedPlugin: NextGraphConnectedPlugin = {\n name: \"nextgraph\",\n\n getResource: function (\n uri: NextGraphUri,\n context: ConnectedContext<NextGraphConnectedPlugin[]>,\n ): NextGraphResource {\n return new NextGraphResource(uri, context);\n },\n\n createResource: async function (\n context: ConnectedContext<NextGraphConnectedPlugin[]>,\n options?: NextGraphCreateResourceOptions,\n ): Promise<NextGraphResource> {\n const storeType = options?.storeType;\n const storeRepo =\n options?.storeRepo ??\n (storeType === \"protected\"\n ? context.nextgraph.protectedStoreId\n : storeType === \"public\"\n ? context.nextgraph.publicStoreId\n : storeType === \"private\"\n ? context.nextgraph.privateStoreId\n : undefined);\n const primaryClass = options?.primaryClass ?? \"data:graph\";\n\n const nuri: NextGraphUri = await context.nextgraph.ng.doc_create(\n context.nextgraph.sessionId,\n \"Graph\",\n primaryClass,\n \"store\",\n storeType,\n storeRepo,\n );\n const newResource = new NextGraphResource(nuri, context);\n await newResource.read();\n return newResource;\n },\n\n isUriValid: function (uri: string): uri is NextGraphUri {\n return isNextGraphUri(uri);\n },\n\n initialContext: {\n sessionId: undefined,\n },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore \"Types\" only exists for the typing system\n types: {},\n};\n"],"mappings":";;;AAqCA,MAAa,2BAAqD;CAChE,MAAM;CAEN,aAAa,SACX,KACA,SACmB;AACnB,SAAO,IAAI,kBAAkB,KAAK,QAAQ;;CAG5C,gBAAgB,eACd,SACA,SAC4B;EAC5B,MAAM,YAAY,SAAS;EAC3B,MAAM,YACJ,SAAS,cACR,cAAc,cACX,QAAQ,UAAU,mBAClB,cAAc,WACd,QAAQ,UAAU,gBAClB,cAAc,YACd,QAAQ,UAAU,iBAClB,KAAA;EACN,MAAM,eAAe,SAAS,gBAAgB;EAU9C,MAAM,cAAc,IAAI,kBARG,MAAM,QAAQ,UAAU,GAAG,WACpD,QAAQ,UAAU,WAClB,SACA,cACA,SACA,WACA,UACD,EAC+C,QAAQ;AACxD,QAAM,YAAY,MAAM;AACxB,SAAO;;CAGT,YAAY,SAAU,KAAkC;AACtD,SAAO,eAAe,IAAI;;CAG5B,gBAAgB,EACd,WAAW,KAAA,GACZ;CAGD,OAAO,EAAE;CACV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -19,12 +19,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
|
-
|
|
23
22
|
//#endregion
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(exports, '__toESM', {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return __toESM;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
23
|
+
exports.__toESM = __toESM;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_NextGraphConnectedPlugin = require("./NextGraphConnectedPlugin.cjs");
|
|
3
|
+
let _ldo_connected = require("@ldo/connected");
|
|
4
|
+
let _ldo_dataset = require("@ldo/dataset");
|
|
5
|
+
let _ldo_subscribable_dataset = require("@ldo/subscribable-dataset");
|
|
7
6
|
//#region src/createNextGraphLdoDataset.ts
|
|
8
7
|
function createNextGraphLdoDataset() {
|
|
9
|
-
|
|
10
|
-
return nextGraphLdoDataset;
|
|
8
|
+
return new _ldo_connected.ConnectedLdoDataset([require_NextGraphConnectedPlugin.nextGraphConnectedPlugin], (0, _ldo_dataset.createDatasetFactory)(), (0, _ldo_subscribable_dataset.createTransactionDatasetFactory)());
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
//#endregion
|
|
14
|
-
exports.createNextGraphLdoDataset = createNextGraphLdoDataset;
|
|
11
|
+
exports.createNextGraphLdoDataset = createNextGraphLdoDataset;
|
|
@@ -2,8 +2,6 @@ import { ConnectedLdoDataset } from "@ldo/connected";
|
|
|
2
2
|
|
|
3
3
|
//#region src/createNextGraphLdoDataset.d.ts
|
|
4
4
|
declare function createNextGraphLdoDataset(): ConnectedLdoDataset<any[]>;
|
|
5
|
-
//# sourceMappingURL=createNextGraphLdoDataset.d.ts.map
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
6
|
export { createNextGraphLdoDataset };
|
|
9
7
|
//# sourceMappingURL=createNextGraphLdoDataset.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNextGraphLdoDataset.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"createNextGraphLdoDataset.d.cts","names":[],"sources":["../src/createNextGraphLdoDataset.ts"],"mappings":";;;iBAKgB,yBAAA,CAAA,GAAyB,mBAAA"}
|
|
@@ -2,8 +2,6 @@ import { ConnectedLdoDataset } from "@ldo/connected";
|
|
|
2
2
|
|
|
3
3
|
//#region src/createNextGraphLdoDataset.d.ts
|
|
4
4
|
declare function createNextGraphLdoDataset(): ConnectedLdoDataset<any[]>;
|
|
5
|
-
//# sourceMappingURL=createNextGraphLdoDataset.d.ts.map
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
|
-
export { createNextGraphLdoDataset
|
|
9
|
-
//# sourceMappingURL=createNextGraphLdoDataset.d.
|
|
6
|
+
export { createNextGraphLdoDataset };
|
|
7
|
+
//# sourceMappingURL=createNextGraphLdoDataset.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNextGraphLdoDataset.d.mts","names":[],"sources":["../src/createNextGraphLdoDataset.ts"],"mappings":";;;iBAKgB,yBAAA,CAAA,GAAyB,mBAAA"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin.
|
|
1
|
+
import { nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin.mjs";
|
|
2
2
|
import { ConnectedLdoDataset } from "@ldo/connected";
|
|
3
3
|
import { createDatasetFactory } from "@ldo/dataset";
|
|
4
4
|
import { createTransactionDatasetFactory } from "@ldo/subscribable-dataset";
|
|
5
|
-
|
|
6
5
|
//#region src/createNextGraphLdoDataset.ts
|
|
7
6
|
function createNextGraphLdoDataset() {
|
|
8
|
-
|
|
9
|
-
return nextGraphLdoDataset;
|
|
7
|
+
return new ConnectedLdoDataset([nextGraphConnectedPlugin], createDatasetFactory(), createTransactionDatasetFactory());
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
//#endregion
|
|
13
10
|
export { createNextGraphLdoDataset };
|
|
14
|
-
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=createNextGraphLdoDataset.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNextGraphLdoDataset.mjs","names":[],"sources":["../src/createNextGraphLdoDataset.ts"],"sourcesContent":["import { ConnectedLdoDataset } from \"@ldo/connected\";\nimport { nextGraphConnectedPlugin } from \"./NextGraphConnectedPlugin\";\nimport { createDatasetFactory } from \"@ldo/dataset\";\nimport { createTransactionDatasetFactory } from \"@ldo/subscribable-dataset\";\n\nexport function createNextGraphLdoDataset() {\n const nextGraphLdoDataset = new ConnectedLdoDataset(\n [nextGraphConnectedPlugin],\n createDatasetFactory(),\n createTransactionDatasetFactory(),\n );\n return nextGraphLdoDataset;\n}\n"],"mappings":";;;;;AAKA,SAAgB,4BAA4B;AAM1C,QAL4B,IAAI,oBAC9B,CAAC,yBAAyB,EAC1B,sBAAsB,EACtB,iCAAiC,CAClC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
exports.NextGraphReadSuccess =
|
|
8
|
-
exports.NextGraphResource =
|
|
9
|
-
exports.createNextGraphLdoDataset =
|
|
10
|
-
exports.isNextGraphUri =
|
|
11
|
-
exports.nextGraphConnectedPlugin =
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_NextGraphReadSuccess = require("./results/NextGraphReadSuccess.cjs");
|
|
3
|
+
const require_NextGraphResource = require("./resources/NextGraphResource.cjs");
|
|
4
|
+
const require_isNextGraphUri = require("./util/isNextGraphUri.cjs");
|
|
5
|
+
const require_NextGraphConnectedPlugin = require("./NextGraphConnectedPlugin.cjs");
|
|
6
|
+
const require_createNextGraphLdoDataset = require("./createNextGraphLdoDataset.cjs");
|
|
7
|
+
exports.NextGraphReadSuccess = require_NextGraphReadSuccess.NextGraphReadSuccess;
|
|
8
|
+
exports.NextGraphResource = require_NextGraphResource.NextGraphResource;
|
|
9
|
+
exports.createNextGraphLdoDataset = require_createNextGraphLdoDataset.createNextGraphLdoDataset;
|
|
10
|
+
exports.isNextGraphUri = require_isNextGraphUri.isNextGraphUri;
|
|
11
|
+
exports.nextGraphConnectedPlugin = require_NextGraphConnectedPlugin.nextGraphConnectedPlugin;
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NextGraphUri, NextGraphUriPrefix } from "./types.mjs";
|
|
2
|
+
import { NextGraphReadSuccess } from "./results/NextGraphReadSuccess.mjs";
|
|
3
|
+
import { NextGraphResource } from "./resources/NextGraphResource.mjs";
|
|
4
|
+
import { NextGraphConnectedContext, NextGraphConnectedPlugin, NextGraphCreateResourceOptions, nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin.mjs";
|
|
5
|
+
import { isNextGraphUri } from "./util/isNextGraphUri.mjs";
|
|
6
|
+
import { createNextGraphLdoDataset } from "./createNextGraphLdoDataset.mjs";
|
|
7
|
+
export { NextGraphConnectedContext, NextGraphConnectedPlugin, NextGraphCreateResourceOptions, NextGraphReadSuccess, NextGraphResource, NextGraphUri, NextGraphUriPrefix, createNextGraphLdoDataset, isNextGraphUri, nextGraphConnectedPlugin };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { NextGraphReadSuccess } from "./results/NextGraphReadSuccess.
|
|
2
|
-
import { NextGraphResource } from "./resources/NextGraphResource.
|
|
3
|
-
import { isNextGraphUri } from "./util/isNextGraphUri.
|
|
4
|
-
import { nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin.
|
|
5
|
-
import { createNextGraphLdoDataset } from "./createNextGraphLdoDataset.
|
|
6
|
-
|
|
7
|
-
export { NextGraphReadSuccess, NextGraphResource, createNextGraphLdoDataset, isNextGraphUri, nextGraphConnectedPlugin };
|
|
1
|
+
import { NextGraphReadSuccess } from "./results/NextGraphReadSuccess.mjs";
|
|
2
|
+
import { NextGraphResource } from "./resources/NextGraphResource.mjs";
|
|
3
|
+
import { isNextGraphUri } from "./util/isNextGraphUri.mjs";
|
|
4
|
+
import { nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin.mjs";
|
|
5
|
+
import { createNextGraphLdoDataset } from "./createNextGraphLdoDataset.mjs";
|
|
6
|
+
export { NextGraphReadSuccess, NextGraphResource, createNextGraphLdoDataset, isNextGraphUri, nextGraphConnectedPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphNotificationMessage.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"NextGraphNotificationMessage.d.cts","names":[],"sources":["../../src/notifications/NextGraphNotificationMessage.ts"],"mappings":";UAAiB,4BAAA;EACf,EAAA;IACE,KAAA;MACE,KAAA;QACE,OAAA,EAAS,uBAAA;MAAA;IAAA;IAGb,KAAA;MACE,KAAA;QACE,OAAA,EAAS,uBAAA;QACT,OAAA,EAAS,uBAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/dist/notifications/{NextGraphNotificationMessage.d.ts → NextGraphNotificationMessage.d.mts}
RENAMED
|
@@ -14,7 +14,6 @@ interface NextGraphNotificationMessage {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
//# sourceMappingURL=NextGraphNotificationMessage.d.ts.map
|
|
18
17
|
//#endregion
|
|
19
18
|
export { NextGraphNotificationMessage };
|
|
20
|
-
//# sourceMappingURL=NextGraphNotificationMessage.d.
|
|
19
|
+
//# sourceMappingURL=NextGraphNotificationMessage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphNotificationMessage.d.mts","names":[],"sources":["../../src/notifications/NextGraphNotificationMessage.ts"],"mappings":";UAAiB,4BAAA;EACf,EAAA;IACE,KAAA;MACE,KAAA;QACE,OAAA,EAAS,uBAAA;MAAA;IAAA;IAGb,KAAA;MACE,KAAA;QACE,OAAA,EAAS,uBAAA;QACT,OAAA,EAAS,uBAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _ldo_connected = require("@ldo/connected");
|
|
4
3
|
//#region src/notifications/NextGraphNotificationSubscription.ts
|
|
5
|
-
var NextGraphNotificationSubscription = class extends
|
|
6
|
-
unsub;
|
|
4
|
+
var NextGraphNotificationSubscription = class extends _ldo_connected.NotificationSubscription {
|
|
7
5
|
async open() {
|
|
8
6
|
this.unsub = await this.context.nextgraph.ng.doc_subscribe(this.resource.uri, this.context.nextgraph.sessionId, this.onNotification.bind(this));
|
|
9
7
|
}
|
|
@@ -12,6 +10,5 @@ var NextGraphNotificationSubscription = class extends __ldo_connected.Notificati
|
|
|
12
10
|
this.unsub = void 0;
|
|
13
11
|
}
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
//#endregion
|
|
17
|
-
exports.NextGraphNotificationSubscription = NextGraphNotificationSubscription;
|
|
14
|
+
exports.NextGraphNotificationSubscription = NextGraphNotificationSubscription;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { NotificationSubscription } from "@ldo/connected";
|
|
2
|
-
|
|
3
2
|
//#region src/notifications/NextGraphNotificationSubscription.ts
|
|
4
3
|
var NextGraphNotificationSubscription = class extends NotificationSubscription {
|
|
5
|
-
unsub;
|
|
6
4
|
async open() {
|
|
7
5
|
this.unsub = await this.context.nextgraph.ng.doc_subscribe(this.resource.uri, this.context.nextgraph.sessionId, this.onNotification.bind(this));
|
|
8
6
|
}
|
|
@@ -11,7 +9,7 @@ var NextGraphNotificationSubscription = class extends NotificationSubscription {
|
|
|
11
9
|
this.unsub = void 0;
|
|
12
10
|
}
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
//#endregion
|
|
16
13
|
export { NextGraphNotificationSubscription };
|
|
17
|
-
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=NextGraphNotificationSubscription.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphNotificationSubscription.mjs","names":[],"sources":["../../src/notifications/NextGraphNotificationSubscription.ts"],"sourcesContent":["import { NotificationSubscription } from \"@ldo/connected\";\nimport type { NextGraphConnectedPlugin } from \"../NextGraphConnectedPlugin\";\nimport type { NextGraphNotificationMessage } from \"./NextGraphNotificationMessage\";\n\nexport class NextGraphNotificationSubscription extends NotificationSubscription<\n NextGraphConnectedPlugin,\n NextGraphNotificationMessage\n> {\n private unsub: (() => void) | undefined;\n\n protected async open(): Promise<void> {\n this.unsub = await this.context.nextgraph.ng.doc_subscribe(\n this.resource.uri,\n this.context.nextgraph.sessionId,\n this.onNotification.bind(this),\n );\n }\n\n protected async close(): Promise<void> {\n this.unsub?.();\n this.unsub = undefined;\n }\n}\n"],"mappings":";;AAIA,IAAa,oCAAb,cAAuD,yBAGrD;CAGA,MAAgB,OAAsB;AACpC,OAAK,QAAQ,MAAM,KAAK,QAAQ,UAAU,GAAG,cAC3C,KAAK,SAAS,KACd,KAAK,QAAQ,UAAU,WACvB,KAAK,eAAe,KAAK,KAAK,CAC/B;;CAGH,MAAgB,QAAuB;AACrC,OAAK,SAAS;AACd,OAAK,QAAQ,KAAA"}
|
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_NextGraphReadSuccess = require("../results/NextGraphReadSuccess.cjs");
|
|
3
|
+
const require_NextGraphNotificationSubscription = require("../notifications/NextGraphNotificationSubscription.cjs");
|
|
4
|
+
let _ldo_connected = require("@ldo/connected");
|
|
5
|
+
let events = require("events");
|
|
6
|
+
events = require_runtime.__toESM(events);
|
|
7
|
+
let _ldo_rdf_utils = require("@ldo/rdf-utils");
|
|
8
|
+
let _ldo_ldo = require("@ldo/ldo");
|
|
9
|
+
let _ldo_dataset = require("@ldo/dataset");
|
|
10
10
|
//#region src/resources/NextGraphResource.ts
|
|
11
11
|
var NextGraphResource = class extends events.default {
|
|
12
|
-
uri;
|
|
13
|
-
type = "NextGraphResource";
|
|
14
|
-
isError = false;
|
|
15
|
-
status;
|
|
16
|
-
context;
|
|
17
|
-
fetched = false;
|
|
18
|
-
loading = false;
|
|
19
|
-
present = void 0;
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
* Handles notification subscriptions
|
|
23
|
-
*/
|
|
24
|
-
notificationSubscription;
|
|
25
12
|
constructor(uri, context) {
|
|
26
13
|
super();
|
|
14
|
+
this.type = "NextGraphResource";
|
|
15
|
+
this.isError = false;
|
|
16
|
+
this.fetched = false;
|
|
17
|
+
this.loading = false;
|
|
18
|
+
this.present = void 0;
|
|
27
19
|
this.uri = uri;
|
|
28
|
-
this.status = new
|
|
20
|
+
this.status = new _ldo_connected.Unfetched(this);
|
|
29
21
|
this.context = context;
|
|
30
|
-
this.notificationSubscription = new
|
|
22
|
+
this.notificationSubscription = new require_NextGraphNotificationSubscription.NextGraphNotificationSubscription(this, this.onNotification.bind(this), this.context);
|
|
31
23
|
}
|
|
32
24
|
isLoading() {
|
|
33
25
|
return this.loading;
|
|
@@ -51,7 +43,7 @@ var NextGraphResource = class extends events.default {
|
|
|
51
43
|
return this.notificationSubscription.isSubscribedToNotifications();
|
|
52
44
|
}
|
|
53
45
|
handleThrownError(err) {
|
|
54
|
-
const error =
|
|
46
|
+
const error = _ldo_connected.UnexpectedResourceError.fromThrown(this, err);
|
|
55
47
|
this.loading = false;
|
|
56
48
|
this.status = error;
|
|
57
49
|
this.emit("update");
|
|
@@ -59,10 +51,10 @@ var NextGraphResource = class extends events.default {
|
|
|
59
51
|
}
|
|
60
52
|
overwriteQuads(quads) {
|
|
61
53
|
const dataset = this.context.dataset;
|
|
62
|
-
const graphNode = (0,
|
|
54
|
+
const graphNode = (0, _ldo_rdf_utils.namedNode)(this.uri);
|
|
63
55
|
dataset.deleteMatches(void 0, void 0, void 0, graphNode);
|
|
64
56
|
dataset.addAll(quads.map((ngQuad) => {
|
|
65
|
-
return (0,
|
|
57
|
+
return (0, _ldo_rdf_utils.quad)(ngQuad.subject, ngQuad.predicate, ngQuad.object, graphNode);
|
|
66
58
|
}));
|
|
67
59
|
}
|
|
68
60
|
async read() {
|
|
@@ -71,7 +63,7 @@ var NextGraphResource = class extends events.default {
|
|
|
71
63
|
this.emit("update");
|
|
72
64
|
const sparqlResult = await this.context.nextgraph.ng.sparql_query(this.context.nextgraph.sessionId, `CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <${this.uri}> { ?s ?p ?o } }`, void 0, this.uri);
|
|
73
65
|
this.overwriteQuads(sparqlResult);
|
|
74
|
-
const result = new
|
|
66
|
+
const result = new require_NextGraphReadSuccess.NextGraphReadSuccess(this, false);
|
|
75
67
|
this.loading = false;
|
|
76
68
|
this.fetched = true;
|
|
77
69
|
this.present = true;
|
|
@@ -80,7 +72,7 @@ var NextGraphResource = class extends events.default {
|
|
|
80
72
|
return result;
|
|
81
73
|
} catch (err) {
|
|
82
74
|
if (err === "RepoNotFound") {
|
|
83
|
-
const result = new
|
|
75
|
+
const result = new require_NextGraphReadSuccess.NextGraphReadSuccess(this, false);
|
|
84
76
|
this.loading = false;
|
|
85
77
|
this.fetched = true;
|
|
86
78
|
this.present = false;
|
|
@@ -92,7 +84,7 @@ var NextGraphResource = class extends events.default {
|
|
|
92
84
|
}
|
|
93
85
|
}
|
|
94
86
|
async readIfUnfetched() {
|
|
95
|
-
if (this.isFetched()) return new
|
|
87
|
+
if (this.isFetched()) return new require_NextGraphReadSuccess.NextGraphReadSuccess(this, true);
|
|
96
88
|
return this.read();
|
|
97
89
|
}
|
|
98
90
|
async update(datasetChanges) {
|
|
@@ -100,8 +92,8 @@ var NextGraphResource = class extends events.default {
|
|
|
100
92
|
this.emit("update");
|
|
101
93
|
this.context.dataset.bulk(datasetChanges);
|
|
102
94
|
try {
|
|
103
|
-
await this.context.nextgraph.ng.sparql_update(this.context.nextgraph.sessionId, await (0,
|
|
104
|
-
return new
|
|
95
|
+
await this.context.nextgraph.ng.sparql_update(this.context.nextgraph.sessionId, await (0, _ldo_rdf_utils.changesToSparqlUpdate)(datasetChanges), this.uri);
|
|
96
|
+
return new _ldo_connected.UpdateSuccess(this);
|
|
105
97
|
} catch (err) {
|
|
106
98
|
this.context.dataset.bulk({
|
|
107
99
|
added: datasetChanges.removed,
|
|
@@ -112,13 +104,12 @@ var NextGraphResource = class extends events.default {
|
|
|
112
104
|
}
|
|
113
105
|
async notificationToQuads(notificationString) {
|
|
114
106
|
const rawTriples = JSON.parse(notificationString);
|
|
115
|
-
|
|
107
|
+
return (await Promise.all(rawTriples.map(async (rawTriple) => (0, _ldo_ldo.parseRdf)(`${rawTriple}.`, { baseIRI: this.uri })))).reduce((agg, ldoDataset) => {
|
|
116
108
|
ldoDataset.forEach((quad) => {
|
|
117
|
-
agg.add((0,
|
|
109
|
+
agg.add((0, _ldo_rdf_utils.quad)(quad.subject, quad.predicate, quad.object, (0, _ldo_rdf_utils.namedNode)(this.uri)));
|
|
118
110
|
});
|
|
119
111
|
return agg;
|
|
120
|
-
}, (0,
|
|
121
|
-
return triples;
|
|
112
|
+
}, (0, _ldo_dataset.createDataset)());
|
|
122
113
|
}
|
|
123
114
|
async onNotification(response) {
|
|
124
115
|
if (response.V0.State) {
|
|
@@ -151,6 +142,5 @@ var NextGraphResource = class extends events.default {
|
|
|
151
142
|
return this.notificationSubscription.unsubscribeFromAllNotifications();
|
|
152
143
|
}
|
|
153
144
|
};
|
|
154
|
-
|
|
155
145
|
//#endregion
|
|
156
|
-
exports.NextGraphResource = NextGraphResource;
|
|
146
|
+
exports.NextGraphResource = NextGraphResource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphResource.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"NextGraphResource.d.cts","names":[],"sources":["../../src/resources/NextGraphResource.ts"],"mappings":";;;;;;;;;cAmBuE,sBAAA,YAMlC,oBAAA;AAAA,cADxB,iBAAA,SACH,sBAAA,YACG,QAAA,CAAS,YAAA;EAAA,SAEJ,GAAA,EAAK,YAAA;EAAA,SACL,IAAA;EAAA,SACA,OAAA;EACT,MAAA,EAAQ,eAAA;EAAA,UACL,OAAA,EAAS,gBAAA,CAAiB,wBAAA;EAAA,QAE5B,OAAA;EAAA,QACA,OAAA;EAAA,QACA,OAAA;EALO;;;;EAAA,UAWL,wBAAA,EAA0B,wBAAA,CAClC,wBAAA,EACA,4BAAA;cAIA,GAAA,EAAK,YAAA,EACL,OAAA,EAAS,gBAAA,CAAiB,wBAAA;EAa5B,SAAA,CAAA;EAIA,SAAA,CAAA;EAIA,WAAA,CAAA;EAIA,mBAAA,CAAA;EAIA,SAAA,CAAA;EAIA,QAAA,CAAA;EAIA,2BAAA,CAAA;EAAA,QAIQ,iBAAA;EAAA,QAUA,cAAA;EAgBF,IAAA,CAAA,GAAQ,OAAA,CACZ,oBAAA,GAAuB,uBAAA,CAAwB,iBAAA;EAsC3C,eAAA,CAAA,GAAmB,OAAA,CACvB,oBAAA,GAAuB,uBAAA,CAAwB,iBAAA;EAQ3C,MAAA,CACJ,cAAA,EAAgB,cAAA,CAAe,IAAA,IAC9B,OAAA,CACC,aAAA,CAAc,iBAAA,IACd,uBAAA,CAAwB,iBAAA;EAAA,QA0Bd,mBAAA;EAAA,UA0BE,cAAA,CAAe,QAAA,EAAU,4BAAA,GAA4B,OAAA;EAgC/D,wBAAA,CACJ,SAAA,GAAY,qBAAA,CAAsB,4BAAA,IACjC,OAAA;EAMH,4BAAA,CAA6B,cAAA,WAAyB,OAAA;EAMtD,+BAAA,CAAA,GAAmC,OAAA;AAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NextGraphUri } from "../types.
|
|
2
|
-
import { NextGraphNotificationMessage } from "../notifications/NextGraphNotificationMessage.
|
|
3
|
-
import { NextGraphReadSuccess
|
|
4
|
-
import { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin.
|
|
1
|
+
import { NextGraphUri } from "../types.mjs";
|
|
2
|
+
import { NextGraphNotificationMessage } from "../notifications/NextGraphNotificationMessage.mjs";
|
|
3
|
+
import { NextGraphReadSuccess } from "../results/NextGraphReadSuccess.mjs";
|
|
4
|
+
import { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin.mjs";
|
|
5
5
|
import { ConnectedContext, ConnectedResult, NotificationSubscription, Resource, ResourceEventEmitter, SubscriptionCallbacks, UnexpectedResourceError, UpdateSuccess } from "@ldo/connected";
|
|
6
6
|
import { DatasetChanges } from "@ldo/rdf-utils";
|
|
7
7
|
import { Quad } from "@rdfjs/types";
|
|
@@ -42,5 +42,5 @@ declare class NextGraphResource extends NextGraphResource_base implements Resour
|
|
|
42
42
|
unsubscribeFromAllNotifications(): Promise<void>;
|
|
43
43
|
}
|
|
44
44
|
//#endregion
|
|
45
|
-
export { NextGraphResource
|
|
46
|
-
//# sourceMappingURL=NextGraphResource.d.
|
|
45
|
+
export { NextGraphResource };
|
|
46
|
+
//# sourceMappingURL=NextGraphResource.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphResource.d.mts","names":[],"sources":["../../src/resources/NextGraphResource.ts"],"mappings":";;;;;;;;;cAmBuE,sBAAA,YAMlC,oBAAA;AAAA,cADxB,iBAAA,SACH,sBAAA,YACG,QAAA,CAAS,YAAA;EAAA,SAEJ,GAAA,EAAK,YAAA;EAAA,SACL,IAAA;EAAA,SACA,OAAA;EACT,MAAA,EAAQ,eAAA;EAAA,UACL,OAAA,EAAS,gBAAA,CAAiB,wBAAA;EAAA,QAE5B,OAAA;EAAA,QACA,OAAA;EAAA,QACA,OAAA;EALO;;;;EAAA,UAWL,wBAAA,EAA0B,wBAAA,CAClC,wBAAA,EACA,4BAAA;cAIA,GAAA,EAAK,YAAA,EACL,OAAA,EAAS,gBAAA,CAAiB,wBAAA;EAa5B,SAAA,CAAA;EAIA,SAAA,CAAA;EAIA,WAAA,CAAA;EAIA,mBAAA,CAAA;EAIA,SAAA,CAAA;EAIA,QAAA,CAAA;EAIA,2BAAA,CAAA;EAAA,QAIQ,iBAAA;EAAA,QAUA,cAAA;EAgBF,IAAA,CAAA,GAAQ,OAAA,CACZ,oBAAA,GAAuB,uBAAA,CAAwB,iBAAA;EAsC3C,eAAA,CAAA,GAAmB,OAAA,CACvB,oBAAA,GAAuB,uBAAA,CAAwB,iBAAA;EAQ3C,MAAA,CACJ,cAAA,EAAgB,cAAA,CAAe,IAAA,IAC9B,OAAA,CACC,aAAA,CAAc,iBAAA,IACd,uBAAA,CAAwB,iBAAA;EAAA,QA0Bd,mBAAA;EAAA,UA0BE,cAAA,CAAe,QAAA,EAAU,4BAAA,GAA4B,OAAA;EAgC/D,wBAAA,CACJ,SAAA,GAAY,qBAAA,CAAsB,4BAAA,IACjC,OAAA;EAMH,4BAAA,CAA6B,cAAA,WAAyB,OAAA;EAMtD,+BAAA,CAAA,GAAmC,OAAA;AAAA"}
|
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import { NextGraphReadSuccess } from "../results/NextGraphReadSuccess.
|
|
2
|
-
import { NextGraphNotificationSubscription } from "../notifications/NextGraphNotificationSubscription.
|
|
1
|
+
import { NextGraphReadSuccess } from "../results/NextGraphReadSuccess.mjs";
|
|
2
|
+
import { NextGraphNotificationSubscription } from "../notifications/NextGraphNotificationSubscription.mjs";
|
|
3
3
|
import { UnexpectedResourceError, Unfetched, UpdateSuccess } from "@ldo/connected";
|
|
4
4
|
import EventEmitter from "events";
|
|
5
5
|
import { changesToSparqlUpdate, namedNode, quad } from "@ldo/rdf-utils";
|
|
6
6
|
import { parseRdf } from "@ldo/ldo";
|
|
7
7
|
import { createDataset } from "@ldo/dataset";
|
|
8
|
-
|
|
9
8
|
//#region src/resources/NextGraphResource.ts
|
|
10
9
|
var NextGraphResource = class extends EventEmitter {
|
|
11
|
-
uri;
|
|
12
|
-
type = "NextGraphResource";
|
|
13
|
-
isError = false;
|
|
14
|
-
status;
|
|
15
|
-
context;
|
|
16
|
-
fetched = false;
|
|
17
|
-
loading = false;
|
|
18
|
-
present = void 0;
|
|
19
|
-
/**
|
|
20
|
-
* @internal
|
|
21
|
-
* Handles notification subscriptions
|
|
22
|
-
*/
|
|
23
|
-
notificationSubscription;
|
|
24
10
|
constructor(uri, context) {
|
|
25
11
|
super();
|
|
12
|
+
this.type = "NextGraphResource";
|
|
13
|
+
this.isError = false;
|
|
14
|
+
this.fetched = false;
|
|
15
|
+
this.loading = false;
|
|
16
|
+
this.present = void 0;
|
|
26
17
|
this.uri = uri;
|
|
27
18
|
this.status = new Unfetched(this);
|
|
28
19
|
this.context = context;
|
|
@@ -111,13 +102,12 @@ var NextGraphResource = class extends EventEmitter {
|
|
|
111
102
|
}
|
|
112
103
|
async notificationToQuads(notificationString) {
|
|
113
104
|
const rawTriples = JSON.parse(notificationString);
|
|
114
|
-
|
|
105
|
+
return (await Promise.all(rawTriples.map(async (rawTriple) => parseRdf(`${rawTriple}.`, { baseIRI: this.uri })))).reduce((agg, ldoDataset) => {
|
|
115
106
|
ldoDataset.forEach((quad$1) => {
|
|
116
107
|
agg.add(quad(quad$1.subject, quad$1.predicate, quad$1.object, namedNode(this.uri)));
|
|
117
108
|
});
|
|
118
109
|
return agg;
|
|
119
110
|
}, createDataset());
|
|
120
|
-
return triples;
|
|
121
111
|
}
|
|
122
112
|
async onNotification(response) {
|
|
123
113
|
if (response.V0.State) {
|
|
@@ -150,7 +140,7 @@ var NextGraphResource = class extends EventEmitter {
|
|
|
150
140
|
return this.notificationSubscription.unsubscribeFromAllNotifications();
|
|
151
141
|
}
|
|
152
142
|
};
|
|
153
|
-
|
|
154
143
|
//#endregion
|
|
155
144
|
export { NextGraphResource };
|
|
156
|
-
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=NextGraphResource.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphResource.mjs","names":["createQuad","quad"],"sources":["../../src/resources/NextGraphResource.ts"],"sourcesContent":["import type {\n ConnectedContext,\n NotificationSubscription,\n SubscriptionCallbacks,\n} from \"@ldo/connected\";\nimport { UnexpectedResourceError, UpdateSuccess } from \"@ldo/connected\";\nimport {\n Unfetched,\n type ConnectedResult,\n type Resource,\n type ResourceEventEmitter,\n} from \"@ldo/connected\";\nimport type { NextGraphUri } from \"../types\";\nimport EventEmitter from \"events\";\nimport type { NextGraphConnectedPlugin } from \"../NextGraphConnectedPlugin\";\nimport { changesToSparqlUpdate, type DatasetChanges } from \"@ldo/rdf-utils\";\nimport type { NextGraphNotificationMessage } from \"../notifications/NextGraphNotificationMessage\";\nimport type { Dataset, Quad } from \"@rdfjs/types\";\nimport { namedNode, quad as createQuad } from \"@ldo/rdf-utils\";\nimport { NextGraphReadSuccess } from \"../results/NextGraphReadSuccess\";\nimport { NextGraphNotificationSubscription } from \"../notifications/NextGraphNotificationSubscription\";\nimport { parseRdf } from \"@ldo/ldo\";\nimport type { LdoDataset } from \"@ldo/ldo\";\nimport { createDataset } from \"@ldo/dataset\";\nexport class NextGraphResource\n extends (EventEmitter as new () => ResourceEventEmitter)\n implements Resource<NextGraphUri>\n{\n public readonly uri: NextGraphUri;\n public readonly type = \"NextGraphResource\" as const;\n public readonly isError = false as const;\n public status: ConnectedResult;\n protected context: ConnectedContext<NextGraphConnectedPlugin[]>;\n\n private fetched: boolean = false;\n private loading: boolean = false;\n private present: boolean | undefined = undefined;\n\n /**\n * @internal\n * Handles notification subscriptions\n */\n protected notificationSubscription: NotificationSubscription<\n NextGraphConnectedPlugin,\n NextGraphNotificationMessage\n >;\n\n constructor(\n uri: NextGraphUri,\n context: ConnectedContext<NextGraphConnectedPlugin[]>,\n ) {\n super();\n this.uri = uri;\n this.status = new Unfetched(this);\n this.context = context;\n this.notificationSubscription = new NextGraphNotificationSubscription(\n this,\n this.onNotification.bind(this),\n this.context,\n );\n }\n\n isLoading(): boolean {\n return this.loading;\n }\n\n isFetched(): boolean {\n return this.fetched;\n }\n\n isUnfetched(): boolean {\n return !this.fetched;\n }\n\n isDoingInitialFetch(): boolean {\n return this.loading && !this.fetched;\n }\n\n isPresent(): boolean | undefined {\n return this.present;\n }\n\n isAbsent(): boolean | undefined {\n return !this.present;\n }\n\n isSubscribedToNotifications(): boolean {\n return this.notificationSubscription.isSubscribedToNotifications();\n }\n\n private handleThrownError(\n err: unknown,\n ): UnexpectedResourceError<NextGraphResource> {\n const error = UnexpectedResourceError.fromThrown(this, err);\n this.loading = false;\n this.status = error;\n this.emit(\"update\");\n return error;\n }\n\n private overwriteQuads(quads: Quad[] | Dataset<Quad>) {\n const dataset = this.context.dataset;\n const graphNode = namedNode(this.uri);\n dataset.deleteMatches(undefined, undefined, undefined, graphNode);\n dataset.addAll(\n quads.map((ngQuad) => {\n return createQuad(\n ngQuad.subject,\n ngQuad.predicate,\n ngQuad.object,\n graphNode,\n );\n }),\n );\n }\n\n async read(): Promise<\n NextGraphReadSuccess | UnexpectedResourceError<NextGraphResource>\n > {\n try {\n this.loading = true;\n this.emit(\"update\");\n\n // Fetch the data once using construct\n const sparqlResult = await this.context.nextgraph.ng.sparql_query(\n this.context.nextgraph.sessionId,\n `CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <${this.uri}> { ?s ?p ?o } }`,\n undefined,\n this.uri,\n );\n // Update the dataset\n this.overwriteQuads(sparqlResult);\n\n // Update statuses\n const result = new NextGraphReadSuccess(this, false);\n this.loading = false;\n this.fetched = true;\n this.present = true;\n this.status = result;\n this.emit(\"update\");\n return result;\n } catch (err) {\n if (err === \"RepoNotFound\") {\n const result = new NextGraphReadSuccess(this, false);\n this.loading = false;\n this.fetched = true;\n this.present = false;\n this.status = result;\n this.emit(\"update\");\n return result;\n }\n return this.handleThrownError(err);\n }\n }\n\n async readIfUnfetched(): Promise<\n NextGraphReadSuccess | UnexpectedResourceError<NextGraphResource>\n > {\n if (this.isFetched()) {\n return new NextGraphReadSuccess(this, true);\n }\n return this.read();\n }\n\n async update(\n datasetChanges: DatasetChanges<Quad>,\n ): Promise<\n | UpdateSuccess<NextGraphResource>\n | UnexpectedResourceError<NextGraphResource>\n > {\n this.loading = true;\n this.emit(\"update\");\n\n // Optimistically apply updates\n this.context.dataset.bulk(datasetChanges);\n\n try {\n // Perform Update with remote\n await this.context.nextgraph.ng.sparql_update(\n this.context.nextgraph.sessionId,\n await changesToSparqlUpdate(datasetChanges),\n this.uri,\n );\n return new UpdateSuccess(this);\n } catch (err) {\n // Revert data on error\n this.context.dataset.bulk({\n added: datasetChanges.removed,\n removed: datasetChanges.added,\n });\n return this.handleThrownError(err);\n }\n }\n\n private async notificationToQuads(\n notificationString: string,\n ): Promise<Dataset<Quad>> {\n const rawTriples = JSON.parse(notificationString);\n const triples = (\n await Promise.all<LdoDataset>(\n rawTriples.map(async (rawTriple) =>\n parseRdf(`${rawTriple}.`, { baseIRI: this.uri }),\n ),\n )\n ).reduce((agg, ldoDataset) => {\n ldoDataset.forEach((quad) => {\n agg.add(\n createQuad(\n quad.subject,\n quad.predicate,\n quad.object,\n namedNode(this.uri),\n ),\n );\n });\n return agg;\n }, createDataset());\n return triples;\n }\n\n protected async onNotification(response: NextGraphNotificationMessage) {\n if (response.V0.State) {\n if (!response.V0.State.graph) {\n this.overwriteQuads([]);\n return;\n }\n const json_str = new TextDecoder().decode(\n response.V0.State.graph.triples,\n );\n const triples = await this.notificationToQuads(json_str);\n this.overwriteQuads(triples);\n } else if (response.V0.Patch?.graph) {\n const insertsString = new TextDecoder().decode(\n response.V0.Patch.graph.inserts,\n );\n const removesString = new TextDecoder().decode(\n response.V0.Patch.graph.removes,\n );\n\n const [added, removed] = await Promise.all(\n [insertsString, removesString].map(async (str) => {\n return this.notificationToQuads(str);\n }),\n );\n\n this.context.dataset.bulk({\n added,\n removed,\n });\n }\n }\n\n async subscribeToNotifications(\n callbacks?: SubscriptionCallbacks<NextGraphNotificationMessage>,\n ): Promise<string> {\n return await this.notificationSubscription.subscribeToNotifications(\n callbacks,\n );\n }\n\n unsubscribeFromNotifications(subscriptionId: string): Promise<void> {\n return this.notificationSubscription.unsubscribeFromNotification(\n subscriptionId,\n );\n }\n\n unsubscribeFromAllNotifications(): Promise<void> {\n return this.notificationSubscription.unsubscribeFromAllNotifications();\n }\n}\n"],"mappings":";;;;;;;;AAwBA,IAAa,oBAAb,cACW,aAEX;CAoBE,YACE,KACA,SACA;AACA,SAAO;cAtBc;iBACG;iBAIC;iBACA;iBACY,KAAA;AAgBrC,OAAK,MAAM;AACX,OAAK,SAAS,IAAI,UAAU,KAAK;AACjC,OAAK,UAAU;AACf,OAAK,2BAA2B,IAAI,kCAClC,MACA,KAAK,eAAe,KAAK,KAAK,EAC9B,KAAK,QACN;;C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AAC,OACtC,SAAS,GAAG,MAAM,MAAM,QACzB;GACD,MAAM,gBAAgB,IAAI,aAAa,CAAC,OACtC,SAAS,GAAG,MAAM,MAAM,QACzB;GAED,MAAM,CAAC,OAAO,WAAW,MAAM,QAAQ,IACrC,CAAC,eAAe,cAAc,CAAC,IAAI,OAAO,QAAQ;AAChD,WAAO,KAAK,oBAAoB,IAAI;KACpC,CACH;AAED,QAAK,QAAQ,QAAQ,KAAK;IACxB;IACA;IACD,CAAC;;;CAIN,MAAM,yBACJ,WACiB;AACjB,SAAO,MAAM,KAAK,yBAAyB,yBACzC,UACD;;CAGH,6BAA6B,gBAAuC;AAClE,SAAO,KAAK,yBAAyB,4BACnC,eACD;;CAGH,kCAAiD;AAC/C,SAAO,KAAK,yBAAyB,iCAAiC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _ldo_connected = require("@ldo/connected");
|
|
4
3
|
//#region src/results/NextGraphReadSuccess.ts
|
|
5
|
-
var NextGraphReadSuccess = class extends
|
|
6
|
-
|
|
4
|
+
var NextGraphReadSuccess = class extends _ldo_connected.ReadSuccess {
|
|
5
|
+
constructor(..._args) {
|
|
6
|
+
super(..._args);
|
|
7
|
+
this.type = "nextGraphReadSuccess";
|
|
8
|
+
}
|
|
7
9
|
};
|
|
8
|
-
|
|
9
10
|
//#endregion
|
|
10
|
-
exports.NextGraphReadSuccess = NextGraphReadSuccess;
|
|
11
|
+
exports.NextGraphReadSuccess = NextGraphReadSuccess;
|
|
@@ -5,8 +5,6 @@ import { ReadSuccess } from "@ldo/connected";
|
|
|
5
5
|
declare class NextGraphReadSuccess extends ReadSuccess<NextGraphResource> {
|
|
6
6
|
type: "nextGraphReadSuccess";
|
|
7
7
|
}
|
|
8
|
-
//# sourceMappingURL=NextGraphReadSuccess.d.ts.map
|
|
9
|
-
|
|
10
8
|
//#endregion
|
|
11
9
|
export { NextGraphReadSuccess };
|
|
12
10
|
//# sourceMappingURL=NextGraphReadSuccess.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphReadSuccess.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"NextGraphReadSuccess.d.cts","names":[],"sources":["../../src/results/NextGraphReadSuccess.ts"],"mappings":";;;;cAGa,oBAAA,SAA6B,WAAA,CAAY,iBAAA;EACpD,IAAA;AAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NextGraphResource } from "../resources/NextGraphResource.mjs";
|
|
2
|
+
import { ReadSuccess } from "@ldo/connected";
|
|
3
|
+
|
|
4
|
+
//#region src/results/NextGraphReadSuccess.d.ts
|
|
5
|
+
declare class NextGraphReadSuccess extends ReadSuccess<NextGraphResource> {
|
|
6
|
+
type: "nextGraphReadSuccess";
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { NextGraphReadSuccess };
|
|
10
|
+
//# sourceMappingURL=NextGraphReadSuccess.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphReadSuccess.d.mts","names":[],"sources":["../../src/results/NextGraphReadSuccess.ts"],"mappings":";;;;cAGa,oBAAA,SAA6B,WAAA,CAAY,iBAAA;EACpD,IAAA;AAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ReadSuccess } from "@ldo/connected";
|
|
2
|
-
|
|
3
2
|
//#region src/results/NextGraphReadSuccess.ts
|
|
4
3
|
var NextGraphReadSuccess = class extends ReadSuccess {
|
|
5
|
-
|
|
4
|
+
constructor(..._args) {
|
|
5
|
+
super(..._args);
|
|
6
|
+
this.type = "nextGraphReadSuccess";
|
|
7
|
+
}
|
|
6
8
|
};
|
|
7
|
-
|
|
8
9
|
//#endregion
|
|
9
10
|
export { NextGraphReadSuccess };
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=NextGraphReadSuccess.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphReadSuccess.mjs","names":[],"sources":["../../src/results/NextGraphReadSuccess.ts"],"sourcesContent":["import { ReadSuccess } from \"@ldo/connected\";\nimport type { NextGraphResource } from \"../resources/NextGraphResource\";\n\nexport class NextGraphReadSuccess extends ReadSuccess<NextGraphResource> {\n type = \"nextGraphReadSuccess\" as const;\n}\n"],"mappings":";;AAGA,IAAa,uBAAb,cAA0C,YAA+B;;;cAChE"}
|
package/dist/types.d.cts
CHANGED
|
@@ -4,7 +4,6 @@ type NextGraphUriPrefix = `did:ng`;
|
|
|
4
4
|
* A NextGraph is a URI that is valid in the NextGraph ecosystem
|
|
5
5
|
*/
|
|
6
6
|
type NextGraphUri = `${NextGraphUriPrefix}${string}` & {};
|
|
7
|
-
//# sourceMappingURL=types.d.ts.map
|
|
8
7
|
//#endregion
|
|
9
8
|
export { NextGraphUri, NextGraphUriPrefix };
|
|
10
9
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,kBAAA;AAAZ;;;AAAA,KAOY,YAAA,MAAkB,kBAAA"}
|
|
@@ -4,7 +4,6 @@ type NextGraphUriPrefix = `did:ng`;
|
|
|
4
4
|
* A NextGraph is a URI that is valid in the NextGraph ecosystem
|
|
5
5
|
*/
|
|
6
6
|
type NextGraphUri = `${NextGraphUriPrefix}${string}` & {};
|
|
7
|
-
//# sourceMappingURL=types.d.ts.map
|
|
8
7
|
//#endregion
|
|
9
8
|
export { NextGraphUri, NextGraphUriPrefix };
|
|
10
|
-
//# sourceMappingURL=types.d.
|
|
9
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,kBAAA;AAAZ;;;AAAA,KAOY,YAAA,MAAkB,kBAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/util/isNextGraphUri.ts
|
|
3
2
|
/**
|
|
4
3
|
* Checks if a provided string is a leaf URI
|
|
@@ -8,6 +7,5 @@
|
|
|
8
7
|
function isNextGraphUri(uri) {
|
|
9
8
|
return uri.startsWith("did:ng");
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
//#endregion
|
|
13
|
-
exports.isNextGraphUri = isNextGraphUri;
|
|
11
|
+
exports.isNextGraphUri = isNextGraphUri;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { NextGraphUri } from "../types.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/util/isNextGraphUri.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Checks if a provided string is a leaf URI
|
|
7
6
|
* @param uri - the string to check
|
|
8
7
|
* @returns true if the string is a leaf URI
|
|
9
8
|
*/
|
|
10
9
|
declare function isNextGraphUri(uri: string): uri is NextGraphUri;
|
|
11
|
-
//# sourceMappingURL=isNextGraphUri.d.ts.map
|
|
12
10
|
//#endregion
|
|
13
11
|
export { isNextGraphUri };
|
|
14
12
|
//# sourceMappingURL=isNextGraphUri.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isNextGraphUri.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"isNextGraphUri.d.cts","names":[],"sources":["../../src/util/isNextGraphUri.ts"],"mappings":";;;;;AAOA;;;iBAAgB,cAAA,CAAe,GAAA,WAAc,GAAA,IAAO,YAAA"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { NextGraphUri } from "../types.
|
|
1
|
+
import { NextGraphUri } from "../types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/util/isNextGraphUri.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Checks if a provided string is a leaf URI
|
|
7
6
|
* @param uri - the string to check
|
|
8
7
|
* @returns true if the string is a leaf URI
|
|
9
8
|
*/
|
|
10
9
|
declare function isNextGraphUri(uri: string): uri is NextGraphUri;
|
|
11
|
-
//# sourceMappingURL=isNextGraphUri.d.ts.map
|
|
12
10
|
//#endregion
|
|
13
|
-
export { isNextGraphUri
|
|
14
|
-
//# sourceMappingURL=isNextGraphUri.d.
|
|
11
|
+
export { isNextGraphUri };
|
|
12
|
+
//# sourceMappingURL=isNextGraphUri.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNextGraphUri.d.mts","names":[],"sources":["../../src/util/isNextGraphUri.ts"],"mappings":";;;;;AAOA;;;iBAAgB,cAAA,CAAe,GAAA,WAAc,GAAA,IAAO,YAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNextGraphUri.mjs","names":[],"sources":["../../src/util/isNextGraphUri.ts"],"sourcesContent":["import type { NextGraphUri } from \"../types\";\n\n/**\n * Checks if a provided string is a leaf URI\n * @param uri - the string to check\n * @returns true if the string is a leaf URI\n */\nexport function isNextGraphUri(uri: string): uri is NextGraphUri {\n return uri.startsWith(\"did:ng\");\n}\n"],"mappings":";;;;;;AAOA,SAAgB,eAAe,KAAkC;AAC/D,QAAO,IAAI,WAAW,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/connected-nextgraph",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.43",
|
|
4
4
|
"description": "A plugin for @ldo/connected to work with the Solid ecosystem.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.
|
|
8
|
-
"types": "./dist/index.d.
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"import": {
|
|
12
|
-
"types": "./dist/index.d.
|
|
13
|
-
"default": "./dist/index.
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
14
|
},
|
|
15
15
|
"require": {
|
|
16
16
|
"types": "./dist/index.d.cts",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"build": "rimraf dist && NODE_OPTIONS=--max-old-space-size=8192 tsdown",
|
|
24
24
|
"test": "[ \"$CI\" = \"true\" ] && echo 'Skipping integration tests in CI.' || npm run test:integration",
|
|
25
25
|
"prepublishOnly": "npm run build",
|
|
26
|
-
"lint": "eslint src/** --
|
|
26
|
+
"lint:check": "eslint src/** --no-error-on-unmatched-pattern",
|
|
27
|
+
"lint": "npm run lint:check -- --fix",
|
|
27
28
|
"docs": "typedoc --plugin typedoc-plugin-markdown",
|
|
28
29
|
"start-test-server": "./test/ngd -vv --save-key -l 14400 --base ./test/nextgraph-data",
|
|
29
30
|
"start-integration-test": "vitest run --coverage",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"homepage": "https://github.com/o-development/ldo/tree/main/packages/solid#readme",
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@inrupt/solid-client-authn-core": "^3.0.0",
|
|
45
|
-
"@ldo/cli": "^1.0.0-alpha.
|
|
46
|
+
"@ldo/cli": "^1.0.0-alpha.43",
|
|
46
47
|
"@solid-notifications/types": "^0.1.2",
|
|
47
48
|
"@solid/community-server": "8.0.0-alpha.0",
|
|
48
49
|
"cross-env": "^7.0.3",
|
|
@@ -56,11 +57,11 @@
|
|
|
56
57
|
"typedoc-plugin-markdown": "^3.17.1"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"@ldo/connected": "^1.0.0-alpha.
|
|
60
|
-
"@ldo/dataset": "^1.0.0-alpha.
|
|
61
|
-
"@ldo/ldo": "^1.0.0-alpha.
|
|
62
|
-
"@ldo/rdf-utils": "^1.0.0-alpha.
|
|
63
|
-
"@ldo/subscribable-dataset": "^1.0.0-alpha.
|
|
60
|
+
"@ldo/connected": "^1.0.0-alpha.43",
|
|
61
|
+
"@ldo/dataset": "^1.0.0-alpha.43",
|
|
62
|
+
"@ldo/ldo": "^1.0.0-alpha.43",
|
|
63
|
+
"@ldo/rdf-utils": "^1.0.0-alpha.43",
|
|
64
|
+
"@ldo/subscribable-dataset": "^1.0.0-alpha.43",
|
|
64
65
|
"@rdfjs/types": "^1.0.1",
|
|
65
66
|
"@solid-notifications/subscription": "^0.1.2",
|
|
66
67
|
"cross-fetch": "^3.1.6",
|
|
@@ -73,5 +74,5 @@
|
|
|
73
74
|
"publishConfig": {
|
|
74
75
|
"access": "public"
|
|
75
76
|
},
|
|
76
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "474cff455e7e3993747d8ecdd40d12e9b20b74f5"
|
|
77
78
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphConnectedPlugin.d.ts","names":[],"sources":["../../src/NextGraphConnectedPlugin.ts"],"sourcesContent":[],"mappings":";;;;;UAKiB,yBAAA;;EAAA,SAAA,CAAA,EAAA,MAAA;EAUA,gBAAA,CAAA,EAAA,MAAA;EAMA,cAAA,CAAA,EAAA,MAAA;EACf,aAAA,CAAA,EAAA,MAAA;;AAGE,UAVa,8BAAA,CAUb;EAAiB,SACjB,CAAA,EAAA,QAAA,GAAA,WAAA,GAAA,SAAA,GAAA,OAAA,GAAA,QAAA;EAAyB,SACzB,CAAA,EAAA,MAAA;EAA8B,YAIzB,CAAA,EAAA,MAAA;;AAEF,UAZU,wBAAA,SACP,eAWH,CAAA,WAAA,EATH,YASG,EARH,iBAQG,EAPH,yBAOG,EANH,8BAMG,CAAA,CAAA;EAAiB,IACE,EAAA,WAAA;EAAgB,WAAmB,EAAA,CAAA,GAAA,EAHpD,YAGoD,EAAA,OAAA,EAFhD,gBAEgD,CAAA,IAAA,EAAA,CAAA,EAAA,GADtD,iBACsD;EAAiB,cAAzB,CAAA,OAAA,EAA3B,gBAA2B,CAAA,IAAA,EAAA,CAAA,CAAA,EAAA,OAAA,CAAQ,iBAAR,CAAA;;AAZ5B,cAeZ,wBAfY,EAec,wBAfd;AAezB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphConnectedPlugin.js","names":["nextGraphConnectedPlugin: NextGraphConnectedPlugin","uri: NextGraphUri","context: ConnectedContext<NextGraphConnectedPlugin[]>","options?: NextGraphCreateResourceOptions","nuri: NextGraphUri","uri: string"],"sources":["../src/NextGraphConnectedPlugin.ts"],"sourcesContent":["import type { ConnectedContext, ConnectedPlugin } from \"@ldo/connected\";\nimport type { NextGraphUri } from \"./types\";\nimport { NextGraphResource } from \"./resources/NextGraphResource\";\nimport { isNextGraphUri } from \"./util/isNextGraphUri\";\n\nexport interface NextGraphConnectedContext {\n // NG does not have a type definition\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ng?: any;\n sessionId?: string;\n protectedStoreId?: string;\n privateStoreId?: string;\n publicStoreId?: string;\n}\n\nexport interface NextGraphCreateResourceOptions {\n storeType?: \"public\" | \"protected\" | \"private\" | \"group\" | \"dialog\";\n storeRepo?: string;\n primaryClass?: string;\n}\n\nexport interface NextGraphConnectedPlugin\n extends ConnectedPlugin<\n \"nextgraph\",\n NextGraphUri,\n NextGraphResource,\n NextGraphConnectedContext,\n NextGraphCreateResourceOptions\n > {\n name: \"nextgraph\";\n getResource: (\n uri: NextGraphUri,\n context: ConnectedContext<this[]>,\n ) => NextGraphResource;\n createResource(context: ConnectedContext<this[]>): Promise<NextGraphResource>;\n}\n\nexport const nextGraphConnectedPlugin: NextGraphConnectedPlugin = {\n name: \"nextgraph\",\n\n getResource: function (\n uri: NextGraphUri,\n context: ConnectedContext<NextGraphConnectedPlugin[]>,\n ): NextGraphResource {\n return new NextGraphResource(uri, context);\n },\n\n createResource: async function (\n context: ConnectedContext<NextGraphConnectedPlugin[]>,\n options?: NextGraphCreateResourceOptions,\n ): Promise<NextGraphResource> {\n const storeType = options?.storeType;\n const storeRepo =\n options?.storeRepo ??\n (storeType === \"protected\"\n ? context.nextgraph.protectedStoreId\n : storeType === \"public\"\n ? context.nextgraph.publicStoreId\n : storeType === \"private\"\n ? context.nextgraph.privateStoreId\n : undefined);\n const primaryClass = options?.primaryClass ?? \"data:graph\";\n\n const nuri: NextGraphUri = await context.nextgraph.ng.doc_create(\n context.nextgraph.sessionId,\n \"Graph\",\n primaryClass,\n \"store\",\n storeType,\n storeRepo,\n );\n const newResource = new NextGraphResource(nuri, context);\n await newResource.read();\n return newResource;\n },\n\n isUriValid: function (uri: string): uri is NextGraphUri {\n return isNextGraphUri(uri);\n },\n\n initialContext: {\n sessionId: undefined,\n },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore \"Types\" only exists for the typing system\n types: {},\n};\n"],"mappings":";;;;AAqCA,MAAaA,2BAAqD;CAChE,MAAM;CAEN,aAAa,SACXC,KACAC,SACmB;AACnB,SAAO,IAAI,kBAAkB,KAAK;CACnC;CAED,gBAAgB,eACdA,SACAC,SAC4B;EAC5B,MAAM,YAAY,SAAS;EAC3B,MAAM,YACJ,SAAS,cACR,cAAc,cACX,QAAQ,UAAU,mBAClB,cAAc,WACd,QAAQ,UAAU,gBAClB,cAAc,YACd,QAAQ,UAAU;EAExB,MAAM,eAAe,SAAS,gBAAgB;EAE9C,MAAMC,OAAqB,MAAM,QAAQ,UAAU,GAAG,WACpD,QAAQ,UAAU,WAClB,SACA,cACA,SACA,WACA,UACD;EACD,MAAM,cAAc,IAAI,kBAAkB,MAAM;AAChD,QAAM,YAAY,MAAM;AACxB,SAAO;CACR;CAED,YAAY,SAAUC,KAAkC;AACtD,SAAO,eAAe,IAAI;CAC3B;CAED,gBAAgB,EACd,kBACD;CAGD,OAAO,CAAE;AACV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createNextGraphLdoDataset.d.ts","names":[],"sources":["../../src/createNextGraphLdoDataset.ts"],"sourcesContent":[],"mappings":";;;iBAKgB,yBAAA,CAAA,GAAyB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createNextGraphLdoDataset.js","names":[],"sources":["../src/createNextGraphLdoDataset.ts"],"sourcesContent":["import { ConnectedLdoDataset } from \"@ldo/connected\";\nimport { nextGraphConnectedPlugin } from \"./NextGraphConnectedPlugin\";\nimport { createDatasetFactory } from \"@ldo/dataset\";\nimport { createTransactionDatasetFactory } from \"@ldo/subscribable-dataset\";\n\nexport function createNextGraphLdoDataset() {\n const nextGraphLdoDataset = new ConnectedLdoDataset(\n [nextGraphConnectedPlugin],\n createDatasetFactory(),\n createTransactionDatasetFactory(),\n );\n return nextGraphLdoDataset;\n}\n"],"mappings":";;;;;;AAKA,SAAgB,4BAA4B;CAC1C,MAAM,sBAAsB,IAAI,oBAC9B,CAAC,wBAAyB,GAC1B,sBAAsB,EACtB,iCAAiC;AAEnC,QAAO;AACR"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NextGraphUri, NextGraphUriPrefix } from "./types.js";
|
|
2
|
-
import { NextGraphReadSuccess$1 as NextGraphReadSuccess } from "./results/NextGraphReadSuccess.js";
|
|
3
|
-
import { NextGraphResource$1 as NextGraphResource } from "./resources/NextGraphResource.js";
|
|
4
|
-
import { NextGraphConnectedContext, NextGraphConnectedPlugin, NextGraphCreateResourceOptions, nextGraphConnectedPlugin$1 as nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin.js";
|
|
5
|
-
import { isNextGraphUri$1 as isNextGraphUri } from "./util/isNextGraphUri.js";
|
|
6
|
-
import { createNextGraphLdoDataset$1 as createNextGraphLdoDataset } from "./createNextGraphLdoDataset.js";
|
|
7
|
-
export { NextGraphConnectedContext, NextGraphConnectedPlugin, NextGraphCreateResourceOptions, NextGraphReadSuccess, NextGraphResource, NextGraphUri, NextGraphUriPrefix, createNextGraphLdoDataset, isNextGraphUri, nextGraphConnectedPlugin };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphNotificationMessage.d.ts","names":[],"sources":["../../../src/notifications/NextGraphNotificationMessage.ts"],"sourcesContent":[],"mappings":";UAAiB,4BAAA;EAAA,EAAA,EAAA;IAA4B,KAAA,CAAA,EAAA;MAI5B,KAAA,EAAA;QAKA,OAAA,EALA,uBAKA;MACA,CAAA;IAAuB,CAAA;;;iBADvB;iBACA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphNotificationSubscription.js","names":[],"sources":["../../src/notifications/NextGraphNotificationSubscription.ts"],"sourcesContent":["import { NotificationSubscription } from \"@ldo/connected\";\nimport type { NextGraphConnectedPlugin } from \"../NextGraphConnectedPlugin\";\nimport type { NextGraphNotificationMessage } from \"./NextGraphNotificationMessage\";\n\nexport class NextGraphNotificationSubscription extends NotificationSubscription<\n NextGraphConnectedPlugin,\n NextGraphNotificationMessage\n> {\n private unsub: (() => void) | undefined;\n\n protected async open(): Promise<void> {\n this.unsub = await this.context.nextgraph.ng.doc_subscribe(\n this.resource.uri,\n this.context.nextgraph.sessionId,\n this.onNotification.bind(this),\n );\n }\n\n protected async close(): Promise<void> {\n this.unsub?.();\n this.unsub = undefined;\n }\n}\n"],"mappings":";;;AAIA,IAAa,oCAAb,cAAuD,yBAGrD;CACA,AAAQ;CAER,MAAgB,OAAsB;AACpC,OAAK,QAAQ,MAAM,KAAK,QAAQ,UAAU,GAAG,cAC3C,KAAK,SAAS,KACd,KAAK,QAAQ,UAAU,WACvB,KAAK,eAAe,KAAK,KAAK,CAC/B;CACF;CAED,MAAgB,QAAuB;AACrC,OAAK,SAAS;AACd,OAAK;CACN;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphResource.d.ts","names":[],"sources":["../../../src/resources/NextGraphResource.ts"],"sourcesContent":[],"mappings":";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,mBAAA;EAAO,UAsD+B,cAAA,CAAA,QAAA,EAAA,4BAAA,CAAA,EAA4B,OAA5B,CAAA,IAAA,CAAA;EAA4B,wBAAA,CAAA,SAAA,CAAA,EAiCvD,qBAjCuD,CAiCjC,4BAjCiC,CAAA,CAAA,EAkClE,OAlCkE,CAAA,MAAA,CAAA;EAAA,4BAiCjC,CAAA,cAAA,EAAA,MAAA,CAAA,EAOkB,OAPlB,CAAA,IAAA,CAAA;EAA4B,+BAAlD,CAAA,CAAA,EAaqB,OAbrB,CAAA,IAAA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphResource.js","names":["uri: NextGraphUri","context: ConnectedContext<NextGraphConnectedPlugin[]>","err: unknown","quads: Quad[] | Dataset<Quad>","datasetChanges: DatasetChanges<Quad>","notificationString: string","quad","response: NextGraphNotificationMessage","callbacks?: SubscriptionCallbacks<NextGraphNotificationMessage>","subscriptionId: string"],"sources":["../../src/resources/NextGraphResource.ts"],"sourcesContent":["import type {\n ConnectedContext,\n NotificationSubscription,\n SubscriptionCallbacks,\n} from \"@ldo/connected\";\nimport { UnexpectedResourceError, UpdateSuccess } from \"@ldo/connected\";\nimport {\n Unfetched,\n type ConnectedResult,\n type Resource,\n type ResourceEventEmitter,\n} from \"@ldo/connected\";\nimport type { NextGraphUri } from \"../types\";\nimport EventEmitter from \"events\";\nimport type { NextGraphConnectedPlugin } from \"../NextGraphConnectedPlugin\";\nimport { changesToSparqlUpdate, type DatasetChanges } from \"@ldo/rdf-utils\";\nimport type { NextGraphNotificationMessage } from \"../notifications/NextGraphNotificationMessage\";\nimport type { Dataset, Quad } from \"@rdfjs/types\";\nimport { namedNode, quad as createQuad } from \"@ldo/rdf-utils\";\nimport { NextGraphReadSuccess } from \"../results/NextGraphReadSuccess\";\nimport { NextGraphNotificationSubscription } from \"../notifications/NextGraphNotificationSubscription\";\nimport { parseRdf } from \"@ldo/ldo\";\nimport type { LdoDataset } from \"@ldo/ldo\";\nimport { createDataset } from \"@ldo/dataset\";\nexport class NextGraphResource\n extends (EventEmitter as new () => ResourceEventEmitter)\n implements Resource<NextGraphUri>\n{\n public readonly uri: NextGraphUri;\n public readonly type = \"NextGraphResource\" as const;\n public readonly isError = false as const;\n public status: ConnectedResult;\n protected context: ConnectedContext<NextGraphConnectedPlugin[]>;\n\n private fetched: boolean = false;\n private loading: boolean = false;\n private present: boolean | undefined = undefined;\n\n /**\n * @internal\n * Handles notification subscriptions\n */\n protected notificationSubscription: NotificationSubscription<\n NextGraphConnectedPlugin,\n NextGraphNotificationMessage\n >;\n\n constructor(\n uri: NextGraphUri,\n context: ConnectedContext<NextGraphConnectedPlugin[]>,\n ) {\n super();\n this.uri = uri;\n this.status = new Unfetched(this);\n this.context = context;\n this.notificationSubscription = new NextGraphNotificationSubscription(\n this,\n this.onNotification.bind(this),\n this.context,\n );\n }\n\n isLoading(): boolean {\n return this.loading;\n }\n\n isFetched(): boolean {\n return this.fetched;\n }\n\n isUnfetched(): boolean {\n return !this.fetched;\n }\n\n isDoingInitialFetch(): boolean {\n return this.loading && !this.fetched;\n }\n\n isPresent(): boolean | undefined {\n return this.present;\n }\n\n isAbsent(): boolean | undefined {\n return !this.present;\n }\n\n isSubscribedToNotifications(): boolean {\n return this.notificationSubscription.isSubscribedToNotifications();\n }\n\n private handleThrownError(\n err: unknown,\n ): UnexpectedResourceError<NextGraphResource> {\n const error = UnexpectedResourceError.fromThrown(this, err);\n this.loading = false;\n this.status = error;\n this.emit(\"update\");\n return error;\n }\n\n private overwriteQuads(quads: Quad[] | Dataset<Quad>) {\n const dataset = this.context.dataset;\n const graphNode = namedNode(this.uri);\n dataset.deleteMatches(undefined, undefined, undefined, graphNode);\n dataset.addAll(\n quads.map((ngQuad) => {\n return createQuad(\n ngQuad.subject,\n ngQuad.predicate,\n ngQuad.object,\n graphNode,\n );\n }),\n );\n }\n\n async read(): Promise<\n NextGraphReadSuccess | UnexpectedResourceError<NextGraphResource>\n > {\n try {\n this.loading = true;\n this.emit(\"update\");\n\n // Fetch the data once using construct\n const sparqlResult = await this.context.nextgraph.ng.sparql_query(\n this.context.nextgraph.sessionId,\n `CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <${this.uri}> { ?s ?p ?o } }`,\n undefined,\n this.uri,\n );\n // Update the dataset\n this.overwriteQuads(sparqlResult);\n\n // Update statuses\n const result = new NextGraphReadSuccess(this, false);\n this.loading = false;\n this.fetched = true;\n this.present = true;\n this.status = result;\n this.emit(\"update\");\n return result;\n } catch (err) {\n if (err === \"RepoNotFound\") {\n const result = new NextGraphReadSuccess(this, false);\n this.loading = false;\n this.fetched = true;\n this.present = false;\n this.status = result;\n this.emit(\"update\");\n return result;\n }\n return this.handleThrownError(err);\n }\n }\n\n async readIfUnfetched(): Promise<\n NextGraphReadSuccess | UnexpectedResourceError<NextGraphResource>\n > {\n if (this.isFetched()) {\n return new NextGraphReadSuccess(this, true);\n }\n return this.read();\n }\n\n async update(\n datasetChanges: DatasetChanges<Quad>,\n ): Promise<\n | UpdateSuccess<NextGraphResource>\n | UnexpectedResourceError<NextGraphResource>\n > {\n this.loading = true;\n this.emit(\"update\");\n\n // Optimistically apply updates\n this.context.dataset.bulk(datasetChanges);\n\n try {\n // Perform Update with remote\n await this.context.nextgraph.ng.sparql_update(\n this.context.nextgraph.sessionId,\n await changesToSparqlUpdate(datasetChanges),\n this.uri,\n );\n return new UpdateSuccess(this);\n } catch (err) {\n // Revert data on error\n this.context.dataset.bulk({\n added: datasetChanges.removed,\n removed: datasetChanges.added,\n });\n return this.handleThrownError(err);\n }\n }\n\n private async notificationToQuads(\n notificationString: string,\n ): Promise<Dataset<Quad>> {\n const rawTriples = JSON.parse(notificationString);\n const triples = (\n await Promise.all<LdoDataset>(\n rawTriples.map(async (rawTriple) =>\n parseRdf(`${rawTriple}.`, { baseIRI: this.uri }),\n ),\n )\n ).reduce((agg, ldoDataset) => {\n ldoDataset.forEach((quad) => {\n agg.add(\n createQuad(\n quad.subject,\n quad.predicate,\n quad.object,\n namedNode(this.uri),\n ),\n );\n });\n return agg;\n }, createDataset());\n return triples;\n }\n\n protected async onNotification(response: NextGraphNotificationMessage) {\n if (response.V0.State) {\n if (!response.V0.State.graph) {\n this.overwriteQuads([]);\n return;\n }\n const json_str = new TextDecoder().decode(\n response.V0.State.graph.triples,\n );\n const triples = await this.notificationToQuads(json_str);\n this.overwriteQuads(triples);\n } else if (response.V0.Patch?.graph) {\n const insertsString = new TextDecoder().decode(\n response.V0.Patch.graph.inserts,\n );\n const removesString = new TextDecoder().decode(\n response.V0.Patch.graph.removes,\n );\n\n const [added, removed] = await Promise.all(\n [insertsString, removesString].map(async (str) => {\n return this.notificationToQuads(str);\n }),\n );\n\n this.context.dataset.bulk({\n added,\n removed,\n });\n }\n }\n\n async subscribeToNotifications(\n callbacks?: SubscriptionCallbacks<NextGraphNotificationMessage>,\n ): Promise<string> {\n return await this.notificationSubscription.subscribeToNotifications(\n callbacks,\n );\n }\n\n unsubscribeFromNotifications(subscriptionId: string): Promise<void> {\n return this.notificationSubscription.unsubscribeFromNotification(\n subscriptionId,\n );\n }\n\n unsubscribeFromAllNotifications(): Promise<void> {\n return this.notificationSubscription.unsubscribeFromAllNotifications();\n }\n}\n"],"mappings":";;;;;;;;;AAwBA,IAAa,oBAAb,cACW,aAEX;CACE,AAAgB;CAChB,AAAgB,OAAO;CACvB,AAAgB,UAAU;CAC1B,AAAO;CACP,AAAU;CAEV,AAAQ,UAAmB;CAC3B,AAAQ,UAAmB;CAC3B,AAAQ;;;;;CAMR,AAAU;CAKV,YACEA,KACAC,SACA;AACA,SAAO;AACP,OAAK,MAAM;AACX,OAAK,SAAS,IAAI,UAAU;AAC5B,OAAK,UAAU;AACf,OAAK,2BAA2B,IAAI,kCAClC,MACA,KAAK,eAAe,KAAK,KAAK,EAC9B,KAAK;CAER;CAED,YAAqB;AACnB,SAAO,KAAK;CACb;CAED,YAAqB;AACnB,SAAO,KAAK;CACb;CAED,cAAuB;AACrB,UAAQ,KA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,IAAI,cAAc,OACtC,SAAS,GAAG,MAAM,MAAM,QACzB;GAED,MAAM,CAAC,OAAO,QAAQ,GAAG,MAAM,QAAQ,IACrC,CAAC,eAAe,aAAc,EAAC,IAAI,OAAO,QAAQ;AAChD,WAAO,KAAK,oBAAoB,IAAI;GACrC,EAAC,CACH;AAED,QAAK,QAAQ,QAAQ,KAAK;IACxB;IACA;GACD,EAAC;EACH;CACF;CAED,MAAM,yBACJC,WACiB;AACjB,SAAO,MAAM,KAAK,yBAAyB,yBACzC,UACD;CACF;CAED,6BAA6BC,gBAAuC;AAClE,SAAO,KAAK,yBAAyB,4BACnC,eACD;CACF;CAED,kCAAiD;AAC/C,SAAO,KAAK,yBAAyB,iCAAiC;CACvE;AACF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { NextGraphResource$1 as NextGraphResource } from "../resources/NextGraphResource.js";
|
|
2
|
-
import { ReadSuccess } from "@ldo/connected";
|
|
3
|
-
|
|
4
|
-
//#region src/results/NextGraphReadSuccess.d.ts
|
|
5
|
-
declare class NextGraphReadSuccess extends ReadSuccess<NextGraphResource> {
|
|
6
|
-
type: "nextGraphReadSuccess";
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=NextGraphReadSuccess.d.ts.map
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { NextGraphReadSuccess as NextGraphReadSuccess$1 };
|
|
12
|
-
//# sourceMappingURL=NextGraphReadSuccess.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphReadSuccess.d.ts","names":[],"sources":["../../../src/results/NextGraphReadSuccess.ts"],"sourcesContent":[],"mappings":";;;;cAGa,oBAAA,SAA6B,YAAY;;AAAtD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphReadSuccess.js","names":[],"sources":["../../src/results/NextGraphReadSuccess.ts"],"sourcesContent":["import { ReadSuccess } from \"@ldo/connected\";\nimport type { NextGraphResource } from \"../resources/NextGraphResource\";\n\nexport class NextGraphReadSuccess extends ReadSuccess<NextGraphResource> {\n type = \"nextGraphReadSuccess\" as const;\n}\n"],"mappings":";;;AAGA,IAAa,uBAAb,cAA0C,YAA+B;CACvE,OAAO;AACR"}
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";KAAY,kBAAA;AAAZ;AAOA;;KAAY,YAAA,MAAkB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isNextGraphUri.d.ts","names":[],"sources":["../../../src/util/isNextGraphUri.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;iBAAgB,cAAA,sBAAoC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isNextGraphUri.js","names":["uri: string"],"sources":["../../src/util/isNextGraphUri.ts"],"sourcesContent":["import type { NextGraphUri } from \"../types\";\n\n/**\n * Checks if a provided string is a leaf URI\n * @param uri - the string to check\n * @returns true if the string is a leaf URI\n */\nexport function isNextGraphUri(uri: string): uri is NextGraphUri {\n return uri.startsWith(\"did:ng\");\n}\n"],"mappings":";;;;;;AAOA,SAAgB,eAAeA,KAAkC;AAC/D,QAAO,IAAI,WAAW,SAAS;AAChC"}
|