diff --git a/packages/connected-nextgraph/src/NextGraphConnectedPlugin.ts b/packages/connected-nextgraph/src/NextGraphConnectedPlugin.ts index 529467a..764fccd 100644 --- a/packages/connected-nextgraph/src/NextGraphConnectedPlugin.ts +++ b/packages/connected-nextgraph/src/NextGraphConnectedPlugin.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, + ) => NextGraphResource; + createResource(context: ConnectedContext): Promise; +} + +export const nextgGraphConnectedPlugin: NextGraphConnectedPlugin = { + name: "nextgraph", + + getResource: function (_uri: NextGraphUri): NextGraphResource { + throw new Error("Function not implemented."); + }, + + createResource: function (): Promise { + throw new Error("Function not implemented."); + }, + + isUriValid: function (uri: string): uri is NextGraphUri { + throw new Error("Function not implemented."); + }, -export const nextGraphConnectedPlugin: NextGraphConnectedPlugin = { - name: "nextGraph", - getResource(_uri: NextGraphUri): NextGraphResource { - throw new Error("Not Implemented"); + initialContext: { + sessionId: undefined, }, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore "Types" only exists for the typing system + types: {}, }; diff --git a/packages/connected-nextgraph/src/resources/NextGraphResource.ts b/packages/connected-nextgraph/src/resources/NextGraphResource.ts index d11336b..c6b8229 100644 --- a/packages/connected-nextgraph/src/resources/NextGraphResource.ts +++ b/packages/connected-nextgraph/src/resources/NextGraphResource.ts @@ -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; @@ -59,20 +63,26 @@ export class NextGraphResource throw new Error("Method not implemented."); } - read(): Promise> { + read(): Promise> { throw new Error("Method not implemented."); } - readIfAbsent(): Promise> { + readIfUnfetched(): Promise> { throw new Error("Method not implemented."); } + update( + _datasetChanges: DatasetChanges, + ): Promise> { + throw new Error("Method Not Implemented"); + } + protected async onNotification(message: unknown) { // TODO } subscribeToNotifications(callbacks?: SubscriptionCallbacks): Promise { - ng. + throw new Error("Method not implemented."); } unsubscribeFromNotifications(subscriptionId: string): Promise {