Set up interfaces for connected-nextgraph

main
Jackson Morgan 5 months ago
parent a14b494f1d
commit 6f2406bfb7
  1. 48
      packages/connected-nextgraph/src/NextGraphConnectedPlugin.ts
  2. 22
      packages/connected-nextgraph/src/resources/NextGraphResource.ts

@ -1,18 +1,44 @@
import type { ConnectedPlugin } from "@ldo/connected";
import type { ConnectedContext, ConnectedPlugin } from "@ldo/connected";
import type { NextGraphUri } from "./types";
import type { NextGraphResource } from "./resources/NextGraphResource";
export interface NextGraphConnectedPlugin extends ConnectedPlugin {
name: "nextGraph";
getResource(uri: NextGraphUri): NextGraphResource;
context: {
sessionId: string;
};
export interface NextGraphConnectedContext {
sessionId?: string;
}
export interface NextGraphConnectedPlugin
extends ConnectedPlugin<
"nextgraph",
NextGraphUri,
NextGraphResource,
NextGraphConnectedContext
> {
name: "nextgraph";
getResource: (
uri: NextGraphUri,
context: ConnectedContext<this[]>,
) => NextGraphResource;
createResource(context: ConnectedContext<this[]>): Promise<NextGraphResource>;
}
export const nextGraphConnectedPlugin: NextGraphConnectedPlugin = {
name: "nextGraph",
getResource(_uri: NextGraphUri): NextGraphResource {
throw new Error("Not Implemented");
export const nextgGraphConnectedPlugin: NextGraphConnectedPlugin = {
name: "nextgraph",
getResource: function (_uri: NextGraphUri): NextGraphResource {
throw new Error("Function not implemented.");
},
createResource: function (): Promise<NextGraphResource> {
throw new Error("Function not implemented.");
},
isUriValid: function (uri: string): uri is NextGraphUri {
throw new Error("Function not implemented.");
},
initialContext: {
sessionId: undefined,
},
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Types" only exists for the typing system
types: {},
};

@ -1,16 +1,19 @@
import type { ConnectedContext } from "@ldo/connected";
import type {
ConnectedContext,
ReadSuccess,
UpdateSuccess,
} from "@ldo/connected";
import {
Unfetched,
type ConnectedResult,
type Resource,
type ResourceResult,
type SubscriptionCallbacks,
type ResourceEventEmitter,
} from "@ldo/connected";
import type { NextGraphUri } from "../types";
import EventEmitter from "events";
import type { NextGraphConnectedPlugin } from "../NextGraphConnectedPlugin";
import ng from "nextgraph";
import type { DatasetChanges } from "@ldo/rdf-utils";
export class NextGraphResource
extends (EventEmitter as new () => ResourceEventEmitter)
@ -18,6 +21,7 @@ export class NextGraphResource
{
public readonly uri: NextGraphUri;
public readonly type = "NextGraphResource" as const;
public readonly isError = false as const;
public status: ConnectedResult;
protected context: ConnectedContext<NextGraphConnectedPlugin[]>;
@ -59,20 +63,26 @@ export class NextGraphResource
throw new Error("Method not implemented.");
}
read(): Promise<ResourceResult<this>> {
read(): Promise<ReadSuccess<NextGraphResource>> {
throw new Error("Method not implemented.");
}
readIfAbsent(): Promise<ResourceResult<this>> {
readIfUnfetched(): Promise<ReadSuccess<NextGraphResource>> {
throw new Error("Method not implemented.");
}
update(
_datasetChanges: DatasetChanges,
): Promise<UpdateSuccess<NextGraphResource>> {
throw new Error("Method Not Implemented");
}
protected async onNotification(message: unknown) {
// TODO
}
subscribeToNotifications(callbacks?: SubscriptionCallbacks): Promise<string> {
ng.
throw new Error("Method not implemented.");
}
unsubscribeFromNotifications(subscriptionId: string): Promise<void> {

Loading…
Cancel
Save