Setup connected-nextgraph structure

main
Jackson Morgan 6 months ago
parent f11fcbda49
commit 778d49ef85
  1. 7
      package-lock.json
  2. 1
      packages/connected-nextgraph/package.json
  3. 3
      packages/connected-nextgraph/src/NextGraphConnectedPlugin.ts
  4. 10
      packages/connected-nextgraph/src/createSolidLdoDataset.ts
  5. 17
      packages/connected-nextgraph/src/resources/NextGraphResource.ts
  6. 15
      packages/connected-nextgraph/src/util/NextGraphNotificationMessage.ts
  7. 8
      packages/connected/src/ConnectedContext.ts
  8. 1
      packages/connected/src/index.ts

7
package-lock.json generated

@ -14687,6 +14687,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/nextgraph": {
"version": "0.1.1-alpha.3",
"resolved": "https://registry.npmjs.org/nextgraph/-/nextgraph-0.1.1-alpha.3.tgz",
"integrity": "sha512-rXpyah3Y5ybuM7swfsKE2nON4eQHXZ68AMnRXFeeI/fkJjvh0Gw/vrrADAEVJJ9vSln+pFydH38vUfyVW5h3yw==",
"license": "MIT/Apache-2.0"
},
"node_modules/node-addon-api": {
"version": "3.2.1",
"dev": true,
@ -20716,6 +20722,7 @@
"@solid-notifications/subscription": "^0.1.2",
"cross-fetch": "^3.1.6",
"http-link-header": "^1.1.1",
"nextgraph": "^0.1.1-alpha.3",
"ws": "^8.18.0"
},
"devDependencies": {

@ -46,6 +46,7 @@
"@solid-notifications/subscription": "^0.1.2",
"cross-fetch": "^3.1.6",
"http-link-header": "^1.1.1",
"nextgraph": "^0.1.1-alpha.3",
"ws": "^8.18.0"
},
"files": [

@ -5,6 +5,9 @@ import type { NextGraphResource } from "./resources/NextGraphResource";
export interface NextGraphConnectedPlugin extends ConnectedPlugin {
name: "nextGraph";
getResource(uri: NextGraphUri): NextGraphResource;
context: {
sessionId: string;
};
}
export const nextGraphConnectedPlugin: NextGraphConnectedPlugin = {

@ -1,13 +1,13 @@
import { ConnectedLdoDataset } from "@ldo/connected";
import { solidConnectedPlugin } from "./NextGraphConnectedPlugin";
import { nextGraphConnectedPlugin } from "./NextGraphConnectedPlugin";
import { createDatasetFactory } from "@ldo/dataset";
import { createTransactionDatasetFactory } from "@ldo/subscribable-dataset";
export function createSolidLdoDataset() {
const solidLdoDataset = new ConnectedLdoDataset(
[solidConnectedPlugin],
export function createNextGraphLdoDataset() {
const nextGraphLdoDataset = new ConnectedLdoDataset(
[nextGraphConnectedPlugin],
createDatasetFactory(),
createTransactionDatasetFactory(),
);
return solidLdoDataset;
return nextGraphLdoDataset;
}

@ -1,3 +1,4 @@
import type { ConnectedContext } from "@ldo/connected";
import {
Unfetched,
type ConnectedResult,
@ -8,6 +9,8 @@ import {
} from "@ldo/connected";
import type { NextGraphUri } from "../types";
import EventEmitter from "events";
import type { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin";
import ng from "nextgraph";
export class NextGraphResource
extends (EventEmitter as new () => ResourceEventEmitter)
@ -16,11 +19,16 @@ export class NextGraphResource
public readonly uri: NextGraphUri;
public readonly type = "NextGraphResource" as const;
public status: ConnectedResult;
protected context: ConnectedContext<NextGraphConnectedPlugin[]>;
constructor(uri: NextGraphUri) {
constructor(
uri: NextGraphUri,
context: ConnectedContext<NextGraphConnectedPlugin[]>,
) {
super();
this.uri = uri;
this.status = new Unfetched(this);
this.context = context;
}
isLoading(): boolean {
@ -59,8 +67,12 @@ export class NextGraphResource
throw new Error("Method not implemented.");
}
protected async onNotification(message: unknown) {
// TODO
}
subscribeToNotifications(callbacks?: SubscriptionCallbacks): Promise<string> {
throw new Error("Method not implemented.");
ng.
}
unsubscribeFromNotifications(subscriptionId: string): Promise<void> {
@ -70,5 +82,4 @@ export class NextGraphResource
unsubscribeFromAllNotifications(): Promise<void> {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,15 @@
export interface NextGraphNotificationMessage {
V0: {
State: {
graph: {
triples: AllowSharedBufferSource;
};
};
Patch: {
graph: {
inserts: AllowSharedBufferSource;
removes: AllowSharedBufferSource;
};
};
};
}

@ -0,0 +1,8 @@
import type { ConnectedLdoDataset } from "./ConnectedLdoDataset";
import type { ConnectedPlugin } from "./ConnectedPlugin";
export type ConnectedContext<Plugins extends ConnectedPlugin[]> = {
dataset: ConnectedLdoDataset<Plugins>;
} & {
[P in Plugins[number] as P["name"]]: P["context"];
};

@ -2,6 +2,7 @@ export * from "./ConnectedLdoDataset";
export * from "./ConnectedPlugin";
export * from "./Resource";
export * from "./InvalidIdentifierResource";
export * from "./ConnectedContext";
export * from "./notifications/NotificationMessage";
export * from "./notifications/NotificationSubscription";

Loading…
Cancel
Save