import { NamedNode, Namespace, Node, SomeTerm } from "@ontologies/core"; import { Location } from "history"; import { DataObject, SomeNode } from "link-lib"; import { LinkReduxLRSType } from "link-redux"; export declare type IRIParams = Record; export interface ParsedAction = {}> { action: NamedNode; base: NamedNode; params: Partial; } export declare type BoundActionDispatcher = {}> = (action: string, payload?: Partial, args?: DataObject) => Promise; /** * Generate a path?query combination for the given {action} and {payload}. * * @see {createActionIRI} * @see {createActionPair} * * @param action The path of the action. * @param payload */ export declare function actionIRI = {}>(action: string, payload?: Partial): string; /** * Create an action generator to easy in IRI generation. * * @see {actionIRI} * @see {createActionPair} * @param base - The base Namespace to which the action/payload is added. */ export declare const createActionIRI: = {}>(base: Namespace) => (action: string, payload?: Partial) => NamedNode; /** * Create a action creator with the store and namespace already bound. * * @param base - The namespace to which the action name should be appended. * @param store - The store where the action should be dispatched. * * @see {createActionPair} * * @example * const dispatch = createActionIRI(store, myNamespace); * store.actions.example = { * initialize: (iri: NamedNode) => dispatch('initialize', { iri }) * }; */ export declare const createActionNS: = {}>(base: Namespace, store: LinkReduxLRSType) => BoundActionDispatcher; /** * Create a dispatch-parse pair for use in middleware. * * @param base - The namespace to create actions on. * @param store - The store to dispatch actions on. */ export declare const createActionPair: >(base: Namespace, store: LinkReduxLRSType) => { dispatch: BoundActionDispatcher; parse: (action: NamedNode) => ParsedAction; }; /** * Get the IRI which the browser will fetch (the document). * * Effectively the IRI without the fragment. */ export declare function doc(iri: NamedNode): NamedNode; /** * Get the filename (with extension) from an IRI. * * @param iri - The IRI to get the filename from. * @param folder - The base folder to trim. Will be guessed if omitted. * @returns The filename with extension or an empty string if it has no filename. */ export declare function filename(iri: NamedNode, folder?: NamedNode): string; /** * Get the origin of the {iri} without trailing slash */ export declare function origin(iri: NamedNode): NamedNode; /** * Get the IRI of the directory containing {iri} or its parent if {iri} has a trailing slash. */ export declare function parentDir(iri: NamedNode): NamedNode; /** * Parse an action for its base IRI and parameters separated. * * Only the last value of each param is included, so duplicates are omitted. * * The param values are parsed and converted for n-quads syntax, otherwise their literal value is * used. The resulting {return.params} is not guaranteed to be correct with the given {ParamMap}, it * is for typing purposes only. */ export declare const parseAction: = {}>(action: NamedNode) => ParsedAction; /** * Get the origin of the {iri} with trailing slash */ export declare function site(iri: NamedNode): NamedNode; /** * Return the top label of the IRI. * * Is either the fragment or the {filename}. */ export declare function term(iri: NamedNode): string; export declare function dbpediaToWikiQuery(base: any, iri: NamedNode | string): string; /** * Generate a path?query combination for the given {action} and {payload}. The subject will be * * @param subject * @param action * @param payload */ export declare function subjectActionIRI(subject: Node, action: string, payload?: { [k: string]: string; }): string; export declare function articleToWikiIRISet(article: Location): { data: any; iri: any; page: any; }; export declare function resourceToWikiPath(iri: SomeNode | string, linkTemplate?: any): string; export declare function tryShorten(iri: NamedNode): string;