2023-10-03 12:16:33 +00:00
|
|
|
import { ObjectValue } from "$sb/types.ts";
|
|
|
|
import { indexObjects } from "./api.ts";
|
|
|
|
import { AttributeObject } from "./attributes.ts";
|
|
|
|
import { TagObject } from "./tags.ts";
|
|
|
|
|
|
|
|
export const builtinPseudoPage = ":builtin:";
|
|
|
|
|
|
|
|
export const builtins: Record<string, Record<string, string>> = {
|
|
|
|
page: {
|
2023-10-09 18:39:03 +00:00
|
|
|
ref: "string",
|
2023-10-03 12:16:33 +00:00
|
|
|
name: "string",
|
|
|
|
lastModified: "date",
|
|
|
|
perm: "rw|ro",
|
|
|
|
contentType: "string",
|
|
|
|
size: "number",
|
|
|
|
tags: "array",
|
|
|
|
},
|
|
|
|
task: {
|
2023-10-09 18:39:03 +00:00
|
|
|
ref: "string",
|
2023-10-03 12:16:33 +00:00
|
|
|
name: "string",
|
|
|
|
done: "boolean",
|
|
|
|
page: "string",
|
|
|
|
state: "string",
|
|
|
|
deadline: "string",
|
|
|
|
pos: "number",
|
|
|
|
tags: "array",
|
|
|
|
},
|
2023-10-13 15:10:57 +00:00
|
|
|
taskstate: {
|
|
|
|
ref: "string",
|
|
|
|
tags: "array",
|
|
|
|
state: "string",
|
|
|
|
count: "number",
|
|
|
|
page: "string",
|
|
|
|
},
|
2023-10-03 12:16:33 +00:00
|
|
|
tag: {
|
2023-10-09 18:39:03 +00:00
|
|
|
ref: "string",
|
2023-10-03 12:16:33 +00:00
|
|
|
name: "string",
|
|
|
|
page: "string",
|
|
|
|
context: "string",
|
|
|
|
},
|
|
|
|
attribute: {
|
2023-10-09 18:39:03 +00:00
|
|
|
ref: "string",
|
2023-10-03 12:16:33 +00:00
|
|
|
name: "string",
|
|
|
|
attributeType: "string",
|
|
|
|
type: "string",
|
|
|
|
page: "string",
|
|
|
|
},
|
|
|
|
anchor: {
|
2023-10-09 18:39:03 +00:00
|
|
|
ref: "string",
|
2023-10-03 12:16:33 +00:00
|
|
|
name: "string",
|
|
|
|
page: "string",
|
|
|
|
pos: "number",
|
|
|
|
},
|
|
|
|
link: {
|
2023-10-09 18:39:03 +00:00
|
|
|
ref: "string",
|
2023-10-03 12:16:33 +00:00
|
|
|
name: "string",
|
|
|
|
page: "string",
|
|
|
|
pos: "number",
|
|
|
|
alias: "string",
|
|
|
|
inDirective: "boolean",
|
|
|
|
asTemplate: "boolean",
|
|
|
|
},
|
2023-10-12 18:30:47 +00:00
|
|
|
paragraph: {
|
|
|
|
text: "string",
|
|
|
|
page: "string",
|
|
|
|
pos: "number",
|
|
|
|
},
|
2023-10-03 12:16:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export async function loadBuiltinsIntoIndex() {
|
|
|
|
console.log("Loading builtins attributes into index");
|
|
|
|
const allTags: ObjectValue<TagObject>[] = [];
|
|
|
|
for (const [tag, attributes] of Object.entries(builtins)) {
|
|
|
|
allTags.push({
|
|
|
|
ref: tag,
|
|
|
|
tags: ["tag"],
|
|
|
|
name: tag,
|
|
|
|
page: builtinPseudoPage,
|
|
|
|
parent: "builtin",
|
|
|
|
});
|
|
|
|
await indexObjects<AttributeObject>(
|
|
|
|
builtinPseudoPage,
|
|
|
|
Object.entries(attributes).map(([name, attributeType]) => {
|
|
|
|
return {
|
|
|
|
ref: `${tag}:${name}`,
|
|
|
|
tags: ["attribute"],
|
|
|
|
tag,
|
|
|
|
name,
|
|
|
|
attributeType,
|
|
|
|
builtinPseudoPage,
|
|
|
|
page: builtinPseudoPage,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
await indexObjects(builtinPseudoPage, allTags);
|
|
|
|
}
|