Complete redo of content indexing and querying (#517)

Complete redo of data store
Introduces live queries and live templates
This commit is contained in:
Zef Hemel
2023-10-03 14:16:33 +02:00
committed by GitHub
parent 7af98e7c7b
commit 0313565610
200 changed files with 4675 additions and 4363 deletions
@@ -1,5 +1,10 @@
import { syscall } from "./syscall.ts";
/**
* Implements a very simple (string) key value store for the client.
* Generally should only be used to set some client-specific states, such as preferences.
*/
export function set(key: string, value: any): Promise<void> {
return syscall("clientStore.set", key, value);
}
+4 -2
View File
@@ -72,7 +72,7 @@ export function filterBox(
}
export function showPanel(
id: "lhs" | "rhs" | "bhs" | "modal",
id: "lhs" | "rhs" | "bhs" | "modal" | "ps",
mode: number,
html: string,
script = "",
@@ -80,7 +80,9 @@ export function showPanel(
return syscall("editor.showPanel", id, mode, html, script);
}
export function hidePanel(id: "lhs" | "rhs" | "bhs" | "modal"): Promise<void> {
export function hidePanel(
id: "lhs" | "rhs" | "bhs" | "modal" | "ps",
): Promise<void> {
return syscall("editor.hidePanel", id);
}
@@ -0,0 +1,16 @@
import { syscall } from "$sb/silverbullet-syscall/syscall.ts";
/**
* Renders
* @param template
* @param obj
* @param globals
* @returns
*/
export function renderTemplate(
template: string,
obj: any,
globals: Record<string, any> = {},
): Promise<string> {
return syscall("handlebars.renderTemplate", template, obj, globals);
}
-54
View File
@@ -1,54 +0,0 @@
import type { Query } from "../plugos-syscall/store.ts";
import { syscall } from "./syscall.ts";
export type KV = {
key: string;
value: any;
};
export function set(
page: string,
key: string,
value: any,
): Promise<void> {
return syscall("index.set", page, key, value);
}
export function batchSet(page: string, kvs: KV[]): Promise<void> {
return syscall("index.batchSet", page, kvs);
}
export function get(page: string, key: string): Promise<any> {
return syscall("index.get", page, key);
}
export function del(page: string, key: string): Promise<void> {
return syscall("index.delete", page, key);
}
export function queryPrefix(
prefix: string,
): Promise<{ key: string; page: string; value: any }[]> {
return syscall("index.queryPrefix", prefix);
}
export function query(
query: Query,
): Promise<{ key: string; page: string; value: any }[]> {
return syscall("index.query", query);
}
export function clearPageIndexForPage(page: string): Promise<void> {
return syscall("index.clearPageIndexForPage", page);
}
export function deletePrefixForPage(
page: string,
prefix: string,
): Promise<void> {
return syscall("index.deletePrefixForPage", page, prefix);
}
export function clearPageIndex(): Promise<void> {
return syscall("index.clearPageIndex");
}
+16
View File
@@ -0,0 +1,16 @@
import { syscall } from "$sb/silverbullet-syscall/syscall.ts";
import type { ParseTree } from "$sb/lib/tree.ts";
/**
* Parses a piece of code using any of the supported SB languages, see `common/languages.ts` for a list
* @param language the language to parse
* @param code the code to parse
* @returns a ParseTree representation of the code
*/
export function parseLanguage(
language: string,
code: string,
): Promise<ParseTree> {
return syscall("language.parseLanguage", language, code);
}
+2 -1
View File
@@ -1,8 +1,9 @@
export * as editor from "./editor.ts";
export * as index from "./index.ts";
export * as markdown from "./markdown.ts";
export * as space from "./space.ts";
export * as system from "./system.ts";
export * as clientStore from "./clientStore.ts";
export * as sync from "./sync.ts";
export * as debug from "./debug.ts";
export * as language from "./language.ts";
export * as handlebars from "./handlebars.ts";
+1 -2
View File
@@ -1,6 +1,5 @@
import { syscall } from "./syscall.ts";
import type { AttachmentMeta, PageMeta } from "../../web/types.ts";
import { FileMeta } from "$sb/types.ts";
import { AttachmentMeta, FileMeta, PageMeta } from "$sb/types.ts";
export function listPages(unfiltered = false): Promise<PageMeta[]> {
return syscall("space.listPages", unfiltered);
-13
View File
@@ -1,13 +0,0 @@
import { syscall } from "./syscall.ts";
export function set(key: string, value: any): Promise<void> {
return syscall("store.set", key, value);
}
export function get(key: string): Promise<any> {
return syscall("store.get", key);
}
export function del(key: string): Promise<void> {
return syscall("store.delete", key);
}