|
|
@ -3,7 +3,6 @@ import type { NextGraphUri } from "./types"; |
|
|
|
import { NextGraphResource } from "./resources/NextGraphResource"; |
|
|
|
import { NextGraphResource } from "./resources/NextGraphResource"; |
|
|
|
import ng from "nextgraph"; |
|
|
|
import ng from "nextgraph"; |
|
|
|
import { isNextGraphUri } from "./util/isNextGraphUri"; |
|
|
|
import { isNextGraphUri } from "./util/isNextGraphUri"; |
|
|
|
import { NoNextGraphStoreError } from "./results/NoNextGraphStoreError"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface NextGraphConnectedContext { |
|
|
|
export interface NextGraphConnectedContext { |
|
|
|
sessionId?: string; |
|
|
|
sessionId?: string; |
|
|
@ -13,7 +12,7 @@ export interface NextGraphConnectedContext { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export interface NextGraphCreateResourceOptions { |
|
|
|
export interface NextGraphCreateResourceOptions { |
|
|
|
storeType?: "public" | "protected" | "private"; |
|
|
|
storeType?: "public" | "protected" | "private" | "group" | "dialog"; |
|
|
|
storeRepo?: string; |
|
|
|
storeRepo?: string; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -30,9 +29,7 @@ export interface NextGraphConnectedPlugin |
|
|
|
uri: NextGraphUri, |
|
|
|
uri: NextGraphUri, |
|
|
|
context: ConnectedContext<this[]>, |
|
|
|
context: ConnectedContext<this[]>, |
|
|
|
) => NextGraphResource; |
|
|
|
) => NextGraphResource; |
|
|
|
createResource( |
|
|
|
createResource(context: ConnectedContext<this[]>): Promise<NextGraphResource>; |
|
|
|
context: ConnectedContext<this[]>, |
|
|
|
|
|
|
|
): Promise<NextGraphResource | NoNextGraphStoreError>; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const nextGraphConnectedPlugin: NextGraphConnectedPlugin = { |
|
|
|
export const nextGraphConnectedPlugin: NextGraphConnectedPlugin = { |
|
|
@ -48,8 +45,8 @@ export const nextGraphConnectedPlugin: NextGraphConnectedPlugin = { |
|
|
|
createResource: async function ( |
|
|
|
createResource: async function ( |
|
|
|
context: ConnectedContext<NextGraphConnectedPlugin[]>, |
|
|
|
context: ConnectedContext<NextGraphConnectedPlugin[]>, |
|
|
|
options?: NextGraphCreateResourceOptions, |
|
|
|
options?: NextGraphCreateResourceOptions, |
|
|
|
): Promise<NextGraphResource | NoNextGraphStoreError> { |
|
|
|
): Promise<NextGraphResource> { |
|
|
|
const storeType = options?.storeType ?? "protected"; |
|
|
|
const storeType = options?.storeType; |
|
|
|
const storeRepo = |
|
|
|
const storeRepo = |
|
|
|
options?.storeRepo ?? |
|
|
|
options?.storeRepo ?? |
|
|
|
(storeType === "protected" |
|
|
|
(storeType === "protected" |
|
|
@ -59,9 +56,6 @@ export const nextGraphConnectedPlugin: NextGraphConnectedPlugin = { |
|
|
|
: storeType === "private" |
|
|
|
: storeType === "private" |
|
|
|
? context.nextgraph.privateStoreId |
|
|
|
? context.nextgraph.privateStoreId |
|
|
|
: undefined); |
|
|
|
: undefined); |
|
|
|
if (!storeRepo) { |
|
|
|
|
|
|
|
return new NoNextGraphStoreError(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const nuri: NextGraphUri = await ng.doc_create( |
|
|
|
const nuri: NextGraphUri = await ng.doc_create( |
|
|
|
context.nextgraph.sessionId, |
|
|
|
context.nextgraph.sessionId, |
|
|
|