|
|
@ -1,12 +1,15 @@ |
|
|
|
import type { |
|
|
|
import { |
|
|
|
ConnectedLdoDataset, |
|
|
|
type ConnectedLdoDataset, |
|
|
|
ConnectedPlugin, |
|
|
|
type ConnectedPlugin, |
|
|
|
ExpandDeep, |
|
|
|
type ExpandDeep, |
|
|
|
LQInput, |
|
|
|
type LQInput, |
|
|
|
LQReturn, |
|
|
|
type LQReturn, |
|
|
|
} from "@ldo/connected"; |
|
|
|
} from "@ldo/connected"; |
|
|
|
import type { LdoBase, ShapeType } from "@ldo/ldo"; |
|
|
|
import { type LdoBase, type LdoBuilder, type ShapeType } from "@ldo/ldo"; |
|
|
|
import type { SubjectNode } from "@ldo/rdf-utils"; |
|
|
|
import type { SubjectNode } from "@ldo/rdf-utils"; |
|
|
|
|
|
|
|
import { type Readable } from "svelte/store"; |
|
|
|
|
|
|
|
import { useTrackingProxy } from "../util/useTrackingProxy.js"; |
|
|
|
|
|
|
|
import { onDestroy } from "svelte"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @internal |
|
|
|
* @internal |
|
|
@ -28,7 +31,29 @@ export function createUseLinkQuery<Plugins extends ConnectedPlugin[]>( |
|
|
|
startingResource: string, |
|
|
|
startingResource: string, |
|
|
|
startingSubject: SubjectNode | string, |
|
|
|
startingSubject: SubjectNode | string, |
|
|
|
linkQuery: QueryInput, |
|
|
|
linkQuery: QueryInput, |
|
|
|
): ExpandDeep<LQReturn<Type, QueryInput>> | undefined { |
|
|
|
): Readable<ExpandDeep<LQReturn<Type, QueryInput>> | undefined> { |
|
|
|
throw new Error("Link Query is Not Implemented for Svelte"); |
|
|
|
const resource = dataset.getResource(startingResource); |
|
|
|
|
|
|
|
console.log(resource); |
|
|
|
|
|
|
|
const lq = dataset |
|
|
|
|
|
|
|
.usingType(shapeType) |
|
|
|
|
|
|
|
.startLinkQuery(resource, startingSubject, linkQuery); |
|
|
|
|
|
|
|
console.log("Calling subscribe"); |
|
|
|
|
|
|
|
lq.subscribe(); |
|
|
|
|
|
|
|
console.log("After call subscribe"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onDestroy(() => { |
|
|
|
|
|
|
|
lq.unsubscribeAll(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fromSubject = (builder: LdoBuilder<Type>) => { |
|
|
|
|
|
|
|
if (!startingSubject) return; |
|
|
|
|
|
|
|
return builder.fromSubject(startingSubject); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return useTrackingProxy( |
|
|
|
|
|
|
|
shapeType, |
|
|
|
|
|
|
|
fromSubject, |
|
|
|
|
|
|
|
dataset, |
|
|
|
|
|
|
|
) as unknown as Readable<ExpandDeep<LQReturn<Type, QueryInput>>>; |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|