@ldo/connected-nextgraph 1.0.0-alpha.32 → 1.0.0-alpha.36
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/dist/NextGraphConnectedPlugin.cjs +27 -0
- package/dist/NextGraphConnectedPlugin.d.cts +28 -0
- package/dist/NextGraphConnectedPlugin.d.cts.map +1 -0
- package/dist/NextGraphConnectedPlugin.d.ts +28 -0
- package/dist/NextGraphConnectedPlugin.d.ts.map +1 -0
- package/dist/NextGraphConnectedPlugin.js +28 -0
- package/dist/NextGraphConnectedPlugin.js.map +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/createNextGraphLdoDataset.cjs +14 -0
- package/dist/createNextGraphLdoDataset.d.cts +9 -0
- package/dist/createNextGraphLdoDataset.d.cts.map +1 -0
- package/dist/createNextGraphLdoDataset.d.ts +9 -0
- package/dist/createNextGraphLdoDataset.d.ts.map +1 -0
- package/dist/createNextGraphLdoDataset.js +14 -0
- package/dist/createNextGraphLdoDataset.js.map +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/notifications/NextGraphNotificationMessage.d.cts +20 -0
- package/dist/notifications/NextGraphNotificationMessage.d.cts.map +1 -0
- package/dist/notifications/NextGraphNotificationMessage.d.ts +20 -0
- package/dist/notifications/NextGraphNotificationMessage.d.ts.map +1 -0
- package/dist/notifications/NextGraphNotificationSubscription.cjs +17 -0
- package/dist/notifications/NextGraphNotificationSubscription.js +17 -0
- package/dist/notifications/NextGraphNotificationSubscription.js.map +1 -0
- package/dist/resources/NextGraphResource.cjs +156 -0
- package/dist/resources/NextGraphResource.d.cts +46 -0
- package/dist/resources/NextGraphResource.d.cts.map +1 -0
- package/dist/resources/NextGraphResource.d.ts +46 -0
- package/dist/resources/NextGraphResource.d.ts.map +1 -0
- package/dist/resources/NextGraphResource.js +156 -0
- package/dist/resources/NextGraphResource.js.map +1 -0
- package/dist/results/NextGraphReadSuccess.cjs +10 -0
- package/dist/results/NextGraphReadSuccess.d.cts +12 -0
- package/dist/results/NextGraphReadSuccess.d.cts.map +1 -0
- package/dist/results/NextGraphReadSuccess.d.ts +12 -0
- package/dist/results/NextGraphReadSuccess.d.ts.map +1 -0
- package/dist/results/NextGraphReadSuccess.js +10 -0
- package/dist/results/NextGraphReadSuccess.js.map +1 -0
- package/dist/types.d.cts +10 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util/isNextGraphUri.cjs +13 -0
- package/dist/util/isNextGraphUri.d.cts +14 -0
- package/dist/util/isNextGraphUri.d.cts.map +1 -0
- package/dist/util/isNextGraphUri.d.ts +14 -0
- package/dist/util/isNextGraphUri.d.ts.map +1 -0
- package/dist/util/isNextGraphUri.js +13 -0
- package/dist/util/isNextGraphUri.js.map +1 -0
- package/package.json +22 -18
- package/src/NextGraphConnectedPlugin.ts +3 -3
- package/src/createNextGraphLdoDataset.ts +1 -1
- package/src/index.ts +6 -6
- package/src/notifications/NextGraphNotificationSubscription.ts +2 -2
- package/src/resources/NextGraphResource.ts +5 -5
- package/src/results/NextGraphReadSuccess.ts +1 -1
- package/src/util/isNextGraphUri.ts +1 -1
- package/dist/cjs/NextGraphConnectedPlugin.cjs +0 -37
- package/dist/cjs/NextGraphConnectedPlugin.js.map +0 -1
- package/dist/cjs/createNextGraphLdoDataset.cjs +0 -13
- package/dist/cjs/createNextGraphLdoDataset.js.map +0 -1
- package/dist/cjs/index.cjs +0 -23
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/notifications/NextGraphNotificationMessage.cjs +0 -3
- package/dist/cjs/notifications/NextGraphNotificationMessage.js.map +0 -1
- package/dist/cjs/notifications/NextGraphNotificationSubscription.cjs +0 -15
- package/dist/cjs/notifications/NextGraphNotificationSubscription.js.map +0 -1
- package/dist/cjs/resources/NextGraphResource.cjs +0 -163
- package/dist/cjs/resources/NextGraphResource.js.map +0 -1
- package/dist/cjs/results/NextGraphReadSuccess.cjs +0 -12
- package/dist/cjs/results/NextGraphReadSuccess.js.map +0 -1
- package/dist/cjs/types.cjs +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/util/NextGraphNotificationMessage.cjs +0 -3
- package/dist/cjs/util/NextGraphNotificationMessage.js.map +0 -1
- package/dist/cjs/util/isNextGraphUri.cjs +0 -13
- package/dist/cjs/util/isNextGraphUri.js.map +0 -1
- package/dist/esm/NextGraphConnectedPlugin.js +0 -34
- package/dist/esm/NextGraphConnectedPlugin.js.map +0 -1
- package/dist/esm/createNextGraphLdoDataset.js +0 -9
- package/dist/esm/createNextGraphLdoDataset.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/notifications/NextGraphNotificationMessage.js +0 -2
- package/dist/esm/notifications/NextGraphNotificationMessage.js.map +0 -1
- package/dist/esm/notifications/NextGraphNotificationSubscription.js +0 -11
- package/dist/esm/notifications/NextGraphNotificationSubscription.js.map +0 -1
- package/dist/esm/resources/NextGraphResource.js +0 -156
- package/dist/esm/resources/NextGraphResource.js.map +0 -1
- package/dist/esm/results/NextGraphReadSuccess.js +0 -8
- package/dist/esm/results/NextGraphReadSuccess.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/util/NextGraphNotificationMessage.js +0 -2
- package/dist/esm/util/NextGraphNotificationMessage.js.map +0 -1
- package/dist/esm/util/isNextGraphUri.js +0 -9
- package/dist/esm/util/isNextGraphUri.js.map +0 -1
- package/dist/types/NextGraphConnectedPlugin.d.ts +0 -22
- package/dist/types/NextGraphConnectedPlugin.d.ts.map +0 -1
- package/dist/types/createNextGraphLdoDataset.d.ts +0 -3
- package/dist/types/createNextGraphLdoDataset.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/notifications/NextGraphNotificationMessage.d.ts +0 -16
- package/dist/types/notifications/NextGraphNotificationMessage.d.ts.map +0 -1
- package/dist/types/notifications/NextGraphNotificationSubscription.d.ts +0 -9
- package/dist/types/notifications/NextGraphNotificationSubscription.d.ts.map +0 -1
- package/dist/types/resources/NextGraphResource.d.ts +0 -48
- package/dist/types/resources/NextGraphResource.d.ts.map +0 -1
- package/dist/types/results/NextGraphReadSuccess.d.ts +0 -6
- package/dist/types/results/NextGraphReadSuccess.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -6
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/util/NextGraphNotificationMessage.d.ts +0 -16
- package/dist/types/util/NextGraphNotificationMessage.d.ts.map +0 -1
- package/dist/types/util/isNextGraphUri.d.ts +0 -8
- package/dist/types/util/isNextGraphUri.d.ts.map +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { NextGraphReadSuccess } from "../results/NextGraphReadSuccess.js";
|
|
2
|
+
import { NextGraphNotificationSubscription } from "../notifications/NextGraphNotificationSubscription.js";
|
|
3
|
+
import { UnexpectedResourceError, Unfetched, UpdateSuccess } from "@ldo/connected";
|
|
4
|
+
import EventEmitter from "events";
|
|
5
|
+
import { changesToSparqlUpdate, namedNode, quad } from "@ldo/rdf-utils";
|
|
6
|
+
import { parseRdf } from "@ldo/ldo";
|
|
7
|
+
import { createDataset } from "@ldo/dataset";
|
|
8
|
+
|
|
9
|
+
//#region src/resources/NextGraphResource.ts
|
|
10
|
+
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
|
+
constructor(uri, context) {
|
|
25
|
+
super();
|
|
26
|
+
this.uri = uri;
|
|
27
|
+
this.status = new Unfetched(this);
|
|
28
|
+
this.context = context;
|
|
29
|
+
this.notificationSubscription = new NextGraphNotificationSubscription(this, this.onNotification.bind(this), this.context);
|
|
30
|
+
}
|
|
31
|
+
isLoading() {
|
|
32
|
+
return this.loading;
|
|
33
|
+
}
|
|
34
|
+
isFetched() {
|
|
35
|
+
return this.fetched;
|
|
36
|
+
}
|
|
37
|
+
isUnfetched() {
|
|
38
|
+
return !this.fetched;
|
|
39
|
+
}
|
|
40
|
+
isDoingInitialFetch() {
|
|
41
|
+
return this.loading && !this.fetched;
|
|
42
|
+
}
|
|
43
|
+
isPresent() {
|
|
44
|
+
return this.present;
|
|
45
|
+
}
|
|
46
|
+
isAbsent() {
|
|
47
|
+
return !this.present;
|
|
48
|
+
}
|
|
49
|
+
isSubscribedToNotifications() {
|
|
50
|
+
return this.notificationSubscription.isSubscribedToNotifications();
|
|
51
|
+
}
|
|
52
|
+
handleThrownError(err) {
|
|
53
|
+
const error = UnexpectedResourceError.fromThrown(this, err);
|
|
54
|
+
this.loading = false;
|
|
55
|
+
this.status = error;
|
|
56
|
+
this.emit("update");
|
|
57
|
+
return error;
|
|
58
|
+
}
|
|
59
|
+
overwriteQuads(quads) {
|
|
60
|
+
const dataset = this.context.dataset;
|
|
61
|
+
const graphNode = namedNode(this.uri);
|
|
62
|
+
dataset.deleteMatches(void 0, void 0, void 0, graphNode);
|
|
63
|
+
dataset.addAll(quads.map((ngQuad) => {
|
|
64
|
+
return quad(ngQuad.subject, ngQuad.predicate, ngQuad.object, graphNode);
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
async read() {
|
|
68
|
+
try {
|
|
69
|
+
this.loading = true;
|
|
70
|
+
this.emit("update");
|
|
71
|
+
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);
|
|
72
|
+
this.overwriteQuads(sparqlResult);
|
|
73
|
+
const result = new NextGraphReadSuccess(this, false);
|
|
74
|
+
this.loading = false;
|
|
75
|
+
this.fetched = true;
|
|
76
|
+
this.present = true;
|
|
77
|
+
this.status = result;
|
|
78
|
+
this.emit("update");
|
|
79
|
+
return result;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
if (err === "RepoNotFound") {
|
|
82
|
+
const result = new NextGraphReadSuccess(this, false);
|
|
83
|
+
this.loading = false;
|
|
84
|
+
this.fetched = true;
|
|
85
|
+
this.present = false;
|
|
86
|
+
this.status = result;
|
|
87
|
+
this.emit("update");
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
return this.handleThrownError(err);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async readIfUnfetched() {
|
|
94
|
+
if (this.isFetched()) return new NextGraphReadSuccess(this, true);
|
|
95
|
+
return this.read();
|
|
96
|
+
}
|
|
97
|
+
async update(datasetChanges) {
|
|
98
|
+
this.loading = true;
|
|
99
|
+
this.emit("update");
|
|
100
|
+
this.context.dataset.bulk(datasetChanges);
|
|
101
|
+
try {
|
|
102
|
+
await this.context.nextgraph.ng.sparql_update(this.context.nextgraph.sessionId, await changesToSparqlUpdate(datasetChanges), this.uri);
|
|
103
|
+
return new UpdateSuccess(this);
|
|
104
|
+
} catch (err) {
|
|
105
|
+
this.context.dataset.bulk({
|
|
106
|
+
added: datasetChanges.removed,
|
|
107
|
+
removed: datasetChanges.added
|
|
108
|
+
});
|
|
109
|
+
return this.handleThrownError(err);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async notificationToQuads(notificationString) {
|
|
113
|
+
const rawTriples = JSON.parse(notificationString);
|
|
114
|
+
const triples = (await Promise.all(rawTriples.map(async (rawTriple) => parseRdf(`${rawTriple}.`, { baseIRI: this.uri })))).reduce((agg, ldoDataset) => {
|
|
115
|
+
ldoDataset.forEach((quad$1) => {
|
|
116
|
+
agg.add(quad(quad$1.subject, quad$1.predicate, quad$1.object, namedNode(this.uri)));
|
|
117
|
+
});
|
|
118
|
+
return agg;
|
|
119
|
+
}, createDataset());
|
|
120
|
+
return triples;
|
|
121
|
+
}
|
|
122
|
+
async onNotification(response) {
|
|
123
|
+
if (response.V0.State) {
|
|
124
|
+
if (!response.V0.State.graph) {
|
|
125
|
+
this.overwriteQuads([]);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const json_str = new TextDecoder().decode(response.V0.State.graph.triples);
|
|
129
|
+
const triples = await this.notificationToQuads(json_str);
|
|
130
|
+
this.overwriteQuads(triples);
|
|
131
|
+
} else if (response.V0.Patch?.graph) {
|
|
132
|
+
const insertsString = new TextDecoder().decode(response.V0.Patch.graph.inserts);
|
|
133
|
+
const removesString = new TextDecoder().decode(response.V0.Patch.graph.removes);
|
|
134
|
+
const [added, removed] = await Promise.all([insertsString, removesString].map(async (str) => {
|
|
135
|
+
return this.notificationToQuads(str);
|
|
136
|
+
}));
|
|
137
|
+
this.context.dataset.bulk({
|
|
138
|
+
added,
|
|
139
|
+
removed
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async subscribeToNotifications(callbacks) {
|
|
144
|
+
return await this.notificationSubscription.subscribeToNotifications(callbacks);
|
|
145
|
+
}
|
|
146
|
+
unsubscribeFromNotifications(subscriptionId) {
|
|
147
|
+
return this.notificationSubscription.unsubscribeFromNotification(subscriptionId);
|
|
148
|
+
}
|
|
149
|
+
unsubscribeFromAllNotifications() {
|
|
150
|
+
return this.notificationSubscription.unsubscribeFromAllNotifications();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
export { NextGraphResource };
|
|
156
|
+
//# sourceMappingURL=NextGraphResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const __ldo_connected = require_rolldown_runtime.__toESM(require("@ldo/connected"));
|
|
3
|
+
|
|
4
|
+
//#region src/results/NextGraphReadSuccess.ts
|
|
5
|
+
var NextGraphReadSuccess = class extends __ldo_connected.ReadSuccess {
|
|
6
|
+
type = "nextGraphReadSuccess";
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.NextGraphReadSuccess = NextGraphReadSuccess;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NextGraphResource } from "../resources/NextGraphResource.cjs";
|
|
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 };
|
|
12
|
+
//# sourceMappingURL=NextGraphReadSuccess.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphReadSuccess.d.cts","names":[],"sources":["../../../src/results/NextGraphReadSuccess.ts"],"sourcesContent":[],"mappings":";;;;cAGa,oBAAA,SAA6B,YAAY;;AAAtD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextGraphReadSuccess.d.ts","names":[],"sources":["../../../src/results/NextGraphReadSuccess.ts"],"sourcesContent":[],"mappings":";;;;cAGa,oBAAA,SAA6B,YAAY;;AAAtD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReadSuccess } from "@ldo/connected";
|
|
2
|
+
|
|
3
|
+
//#region src/results/NextGraphReadSuccess.ts
|
|
4
|
+
var NextGraphReadSuccess = class extends ReadSuccess {
|
|
5
|
+
type = "nextGraphReadSuccess";
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { NextGraphReadSuccess };
|
|
10
|
+
//# sourceMappingURL=NextGraphReadSuccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type NextGraphUriPrefix = `did:ng`;
|
|
3
|
+
/**
|
|
4
|
+
* A NextGraph is a URI that is valid in the NextGraph ecosystem
|
|
5
|
+
*/
|
|
6
|
+
type NextGraphUri = `${NextGraphUriPrefix}${string}` & {};
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
8
|
+
//#endregion
|
|
9
|
+
export { NextGraphUri, NextGraphUriPrefix };
|
|
10
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";KAAY,kBAAA;AAAZ;AAOA;;KAAY,YAAA,MAAkB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type NextGraphUriPrefix = `did:ng`;
|
|
3
|
+
/**
|
|
4
|
+
* A NextGraph is a URI that is valid in the NextGraph ecosystem
|
|
5
|
+
*/
|
|
6
|
+
type NextGraphUri = `${NextGraphUriPrefix}${string}` & {};
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
8
|
+
//#endregion
|
|
9
|
+
export { NextGraphUri, NextGraphUriPrefix };
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";KAAY,kBAAA;AAAZ;AAOA;;KAAY,YAAA,MAAkB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/util/isNextGraphUri.ts
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a provided string is a leaf URI
|
|
5
|
+
* @param uri - the string to check
|
|
6
|
+
* @returns true if the string is a leaf URI
|
|
7
|
+
*/
|
|
8
|
+
function isNextGraphUri(uri) {
|
|
9
|
+
return uri.startsWith("did:ng");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.isNextGraphUri = isNextGraphUri;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NextGraphUri } from "../types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/util/isNextGraphUri.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a provided string is a leaf URI
|
|
7
|
+
* @param uri - the string to check
|
|
8
|
+
* @returns true if the string is a leaf URI
|
|
9
|
+
*/
|
|
10
|
+
declare function isNextGraphUri(uri: string): uri is NextGraphUri;
|
|
11
|
+
//# sourceMappingURL=isNextGraphUri.d.ts.map
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isNextGraphUri };
|
|
14
|
+
//# sourceMappingURL=isNextGraphUri.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNextGraphUri.d.cts","names":[],"sources":["../../../src/util/isNextGraphUri.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;iBAAgB,cAAA,sBAAoC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NextGraphUri } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/util/isNextGraphUri.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a provided string is a leaf URI
|
|
7
|
+
* @param uri - the string to check
|
|
8
|
+
* @returns true if the string is a leaf URI
|
|
9
|
+
*/
|
|
10
|
+
declare function isNextGraphUri(uri: string): uri is NextGraphUri;
|
|
11
|
+
//# sourceMappingURL=isNextGraphUri.d.ts.map
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isNextGraphUri as isNextGraphUri$1 };
|
|
14
|
+
//# sourceMappingURL=isNextGraphUri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNextGraphUri.d.ts","names":[],"sources":["../../../src/util/isNextGraphUri.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;iBAAgB,cAAA,sBAAoC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/util/isNextGraphUri.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a provided string is a leaf URI
|
|
4
|
+
* @param uri - the string to check
|
|
5
|
+
* @returns true if the string is a leaf URI
|
|
6
|
+
*/
|
|
7
|
+
function isNextGraphUri(uri) {
|
|
8
|
+
return uri.startsWith("did:ng");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isNextGraphUri };
|
|
13
|
+
//# sourceMappingURL=isNextGraphUri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/connected-nextgraph",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.36",
|
|
4
4
|
"description": "A plugin for @ldo/connected to work with the Solid ecosystem.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/
|
|
7
|
-
"module": "./dist/
|
|
8
|
-
"types": "./dist/
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
14
19
|
},
|
|
15
20
|
"./package.json": "./package.json"
|
|
16
21
|
},
|
|
17
22
|
"scripts": {
|
|
18
|
-
"build": "rimraf dist &&
|
|
19
|
-
"build:cjs": "tsc --project tsconfig.cjs.json && node ../../scripts/rename-to-cjs.js",
|
|
20
|
-
"build:esm": "tsc --project tsconfig.esm.json",
|
|
23
|
+
"build": "rimraf dist && NODE_OPTIONS=--max-old-space-size=8192 tsdown",
|
|
21
24
|
"test": "[ \"$CI\" = \"true\" ] && echo 'Skipping integration tests in CI.' || npm run test:integration",
|
|
22
|
-
"prepublishOnly": "
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
23
26
|
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
|
|
24
27
|
"docs": "typedoc --plugin typedoc-plugin-markdown",
|
|
25
28
|
"start-test-server": "./test/ngd -vv --save-key -l 14400 --base ./test/nextgraph-data",
|
|
@@ -39,8 +42,7 @@
|
|
|
39
42
|
"homepage": "https://github.com/o-development/ldo/tree/main/packages/solid#readme",
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@inrupt/solid-client-authn-core": "^3.0.0",
|
|
42
|
-
"@ldo/cli": "^1.0.0-alpha.
|
|
43
|
-
"@rdfjs/types": "^1.0.1",
|
|
45
|
+
"@ldo/cli": "^1.0.0-alpha.36",
|
|
44
46
|
"@solid-notifications/types": "^0.1.2",
|
|
45
47
|
"@solid/community-server": "8.0.0-alpha.0",
|
|
46
48
|
"cross-env": "^7.0.3",
|
|
@@ -54,10 +56,12 @@
|
|
|
54
56
|
"typedoc-plugin-markdown": "^3.17.1"
|
|
55
57
|
},
|
|
56
58
|
"dependencies": {
|
|
57
|
-
"@ldo/connected": "^1.0.0-alpha.
|
|
58
|
-
"@ldo/dataset": "^1.0.0-alpha.
|
|
59
|
-
"@ldo/ldo": "^1.0.0-alpha.
|
|
60
|
-
"@ldo/rdf-utils": "^1.0.0-alpha.
|
|
59
|
+
"@ldo/connected": "^1.0.0-alpha.36",
|
|
60
|
+
"@ldo/dataset": "^1.0.0-alpha.36",
|
|
61
|
+
"@ldo/ldo": "^1.0.0-alpha.36",
|
|
62
|
+
"@ldo/rdf-utils": "^1.0.0-alpha.36",
|
|
63
|
+
"@ldo/subscribable-dataset": "^1.0.0-alpha.36",
|
|
64
|
+
"@rdfjs/types": "^1.0.1",
|
|
61
65
|
"@solid-notifications/subscription": "^0.1.2",
|
|
62
66
|
"cross-fetch": "^3.1.6",
|
|
63
67
|
"ws": "^8.18.0"
|
|
@@ -69,5 +73,5 @@
|
|
|
69
73
|
"publishConfig": {
|
|
70
74
|
"access": "public"
|
|
71
75
|
},
|
|
72
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "e97a0f8b5fa7f609e5070e472b1b63ff8a9502a8"
|
|
73
77
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConnectedContext, ConnectedPlugin } from "@ldo/connected";
|
|
2
|
-
import type { NextGraphUri } from "./types
|
|
3
|
-
import { NextGraphResource } from "./resources/NextGraphResource
|
|
4
|
-
import { isNextGraphUri } from "./util/isNextGraphUri
|
|
2
|
+
import type { NextGraphUri } from "./types";
|
|
3
|
+
import { NextGraphResource } from "./resources/NextGraphResource";
|
|
4
|
+
import { isNextGraphUri } from "./util/isNextGraphUri";
|
|
5
5
|
|
|
6
6
|
export interface NextGraphConnectedContext {
|
|
7
7
|
// NG does not have a type definition
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConnectedLdoDataset } from "@ldo/connected";
|
|
2
|
-
import { nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin
|
|
2
|
+
import { nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin";
|
|
3
3
|
import { createDatasetFactory } from "@ldo/dataset";
|
|
4
4
|
import { createTransactionDatasetFactory } from "@ldo/subscribable-dataset";
|
|
5
5
|
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./types
|
|
2
|
-
export * from "./NextGraphConnectedPlugin
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./NextGraphConnectedPlugin";
|
|
3
3
|
|
|
4
|
-
export * from "./resources/NextGraphResource
|
|
4
|
+
export * from "./resources/NextGraphResource";
|
|
5
5
|
|
|
6
|
-
export * from "./util/isNextGraphUri
|
|
6
|
+
export * from "./util/isNextGraphUri";
|
|
7
7
|
|
|
8
|
-
export * from "./results/NextGraphReadSuccess
|
|
8
|
+
export * from "./results/NextGraphReadSuccess";
|
|
9
9
|
|
|
10
|
-
export * from "./createNextGraphLdoDataset
|
|
10
|
+
export * from "./createNextGraphLdoDataset";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NotificationSubscription } from "@ldo/connected";
|
|
2
|
-
import type { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin
|
|
3
|
-
import type { NextGraphNotificationMessage } from "./NextGraphNotificationMessage
|
|
2
|
+
import type { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin";
|
|
3
|
+
import type { NextGraphNotificationMessage } from "./NextGraphNotificationMessage";
|
|
4
4
|
|
|
5
5
|
export class NextGraphNotificationSubscription extends NotificationSubscription<
|
|
6
6
|
NextGraphConnectedPlugin,
|
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
type Resource,
|
|
11
11
|
type ResourceEventEmitter,
|
|
12
12
|
} from "@ldo/connected";
|
|
13
|
-
import type { NextGraphUri } from "../types
|
|
13
|
+
import type { NextGraphUri } from "../types";
|
|
14
14
|
import EventEmitter from "events";
|
|
15
|
-
import type { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin
|
|
15
|
+
import type { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin";
|
|
16
16
|
import { changesToSparqlUpdate, type DatasetChanges } from "@ldo/rdf-utils";
|
|
17
|
-
import type { NextGraphNotificationMessage } from "../notifications/NextGraphNotificationMessage
|
|
17
|
+
import type { NextGraphNotificationMessage } from "../notifications/NextGraphNotificationMessage";
|
|
18
18
|
import type { Dataset, Quad } from "@rdfjs/types";
|
|
19
19
|
import { namedNode, quad as createQuad } from "@ldo/rdf-utils";
|
|
20
|
-
import { NextGraphReadSuccess } from "../results/NextGraphReadSuccess
|
|
21
|
-
import { NextGraphNotificationSubscription } from "../notifications/NextGraphNotificationSubscription
|
|
20
|
+
import { NextGraphReadSuccess } from "../results/NextGraphReadSuccess";
|
|
21
|
+
import { NextGraphNotificationSubscription } from "../notifications/NextGraphNotificationSubscription";
|
|
22
22
|
import { parseRdf } from "@ldo/ldo";
|
|
23
23
|
import type { LdoDataset } from "@ldo/ldo";
|
|
24
24
|
import { createDataset } from "@ldo/dataset";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReadSuccess } from "@ldo/connected";
|
|
2
|
-
import type { NextGraphResource } from "../resources/NextGraphResource
|
|
2
|
+
import type { NextGraphResource } from "../resources/NextGraphResource";
|
|
3
3
|
|
|
4
4
|
export class NextGraphReadSuccess extends ReadSuccess<NextGraphResource> {
|
|
5
5
|
type = "nextGraphReadSuccess" as const;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nextGraphConnectedPlugin = void 0;
|
|
4
|
-
const NextGraphResource_js_1 = require("./resources/NextGraphResource.js");
|
|
5
|
-
const isNextGraphUri_js_1 = require("./util/isNextGraphUri.js");
|
|
6
|
-
exports.nextGraphConnectedPlugin = {
|
|
7
|
-
name: "nextgraph",
|
|
8
|
-
getResource: function (uri, context) {
|
|
9
|
-
return new NextGraphResource_js_1.NextGraphResource(uri, context);
|
|
10
|
-
},
|
|
11
|
-
createResource: async function (context, options) {
|
|
12
|
-
const storeType = options?.storeType;
|
|
13
|
-
const storeRepo = options?.storeRepo ??
|
|
14
|
-
(storeType === "protected"
|
|
15
|
-
? context.nextgraph.protectedStoreId
|
|
16
|
-
: storeType === "public"
|
|
17
|
-
? context.nextgraph.publicStoreId
|
|
18
|
-
: storeType === "private"
|
|
19
|
-
? context.nextgraph.privateStoreId
|
|
20
|
-
: undefined);
|
|
21
|
-
const primaryClass = options?.primaryClass ?? "data:graph";
|
|
22
|
-
const nuri = await context.nextgraph.ng.doc_create(context.nextgraph.sessionId, "Graph", primaryClass, "store", storeType, storeRepo);
|
|
23
|
-
const newResource = new NextGraphResource_js_1.NextGraphResource(nuri, context);
|
|
24
|
-
await newResource.read();
|
|
25
|
-
return newResource;
|
|
26
|
-
},
|
|
27
|
-
isUriValid: function (uri) {
|
|
28
|
-
return (0, isNextGraphUri_js_1.isNextGraphUri)(uri);
|
|
29
|
-
},
|
|
30
|
-
initialContext: {
|
|
31
|
-
sessionId: undefined,
|
|
32
|
-
},
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
34
|
-
// @ts-ignore "Types" only exists for the typing system
|
|
35
|
-
types: {},
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=NextGraphConnectedPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphConnectedPlugin.js","sourceRoot":"","sources":["../../src/NextGraphConnectedPlugin.ts"],"names":[],"mappings":";;;AAEA,2EAAqE;AACrE,gEAA0D;AAkC7C,QAAA,wBAAwB,GAA6B;IAChE,IAAI,EAAE,WAAW;IAEjB,WAAW,EAAE,UACX,GAAiB,EACjB,OAAqD;QAErD,OAAO,IAAI,wCAAiB,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;QACjB,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,YAAY,CAAC;QAE3D,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,wCAAiB,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,kCAAc,EAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,cAAc,EAAE;QACd,SAAS,EAAE,SAAS;KACrB;IACD,6DAA6D;IAC7D,uDAAuD;IACvD,KAAK,EAAE,EAAE;CACV,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNextGraphLdoDataset = void 0;
|
|
4
|
-
const connected_1 = require("@ldo/connected");
|
|
5
|
-
const NextGraphConnectedPlugin_js_1 = require("./NextGraphConnectedPlugin.js");
|
|
6
|
-
const dataset_1 = require("@ldo/dataset");
|
|
7
|
-
const subscribable_dataset_1 = require("@ldo/subscribable-dataset");
|
|
8
|
-
function createNextGraphLdoDataset() {
|
|
9
|
-
const nextGraphLdoDataset = new connected_1.ConnectedLdoDataset([NextGraphConnectedPlugin_js_1.nextGraphConnectedPlugin], (0, dataset_1.createDatasetFactory)(), (0, subscribable_dataset_1.createTransactionDatasetFactory)());
|
|
10
|
-
return nextGraphLdoDataset;
|
|
11
|
-
}
|
|
12
|
-
exports.createNextGraphLdoDataset = createNextGraphLdoDataset;
|
|
13
|
-
//# sourceMappingURL=createNextGraphLdoDataset.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createNextGraphLdoDataset.js","sourceRoot":"","sources":["../../src/createNextGraphLdoDataset.ts"],"names":[],"mappings":";;;AAAA,8CAAqD;AACrD,+EAAyE;AACzE,0CAAoD;AACpD,oEAA4E;AAE5E,SAAgB,yBAAyB;IACvC,MAAM,mBAAmB,GAAG,IAAI,+BAAmB,CACjD,CAAC,sDAAwB,CAAC,EAC1B,IAAA,8BAAoB,GAAE,EACtB,IAAA,sDAA+B,GAAE,CAClC,CAAC;IACF,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAPD,8DAOC"}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types.js"), exports);
|
|
18
|
-
__exportStar(require("./NextGraphConnectedPlugin.js"), exports);
|
|
19
|
-
__exportStar(require("./resources/NextGraphResource.js"), exports);
|
|
20
|
-
__exportStar(require("./util/isNextGraphUri.js"), exports);
|
|
21
|
-
__exportStar(require("./results/NextGraphReadSuccess.js"), exports);
|
|
22
|
-
__exportStar(require("./createNextGraphLdoDataset.js"), exports);
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,gEAA8C;AAE9C,mEAAiD;AAEjD,2DAAyC;AAEzC,oEAAkD;AAElD,iEAA+C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextGraphNotificationMessage.js","sourceRoot":"","sources":["../../../src/notifications/NextGraphNotificationMessage.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NextGraphNotificationSubscription = void 0;
|
|
4
|
-
const connected_1 = require("@ldo/connected");
|
|
5
|
-
class NextGraphNotificationSubscription extends connected_1.NotificationSubscription {
|
|
6
|
-
async open() {
|
|
7
|
-
this.unsub = await this.context.nextgraph.ng.doc_subscribe(this.resource.uri, this.context.nextgraph.sessionId, this.onNotification.bind(this));
|
|
8
|
-
}
|
|
9
|
-
async close() {
|
|
10
|
-
this.unsub?.();
|
|
11
|
-
this.unsub = undefined;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.NextGraphNotificationSubscription = NextGraphNotificationSubscription;
|
|
15
|
-
//# sourceMappingURL=NextGraphNotificationSubscription.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,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;AAlBD,8EAkBC"}
|