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

Loading…
Cancel
Save