Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@mdbase-dev/connect": "0.1.0-beta.114",
"@mdbase-dev/connect-protocol": "0.1.0-beta.114",
"@tanstack/react-virtual": "3.14.11",
"@tasknotes/model": "file:vendor/tasknotes-model-0.3.0-rc.13.tgz",
"@tasknotes/model": "file:vendor/tasknotes-model-0.3.0-rc.14.tgz",
"codemirror": "^6.0.2",
"dexie": "4.4.4",
"firebase": "12.16.0",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions scripts/tasknotes-manifest.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TASKNOTES_APP_TYPE_PACK_VERSION,
} from "./tasknotes-manifest.mjs";
import { buildAppTaskNotesResources } from "./tasknotes-resources.mjs";
import { loadCanonicalTaskNotesTypePack } from "./canonical-task-pack.mjs";

describe("TaskNotes mdbase manifest", () => {
it("declares content-free runtime criteria without requiring Firebase", async () => {
Expand Down Expand Up @@ -153,6 +154,17 @@ describe("TaskNotes mdbase manifest", () => {
]);
});

it("generates exactly the starter type the pinned pack installs", async () => {
const pack = await loadCanonicalTaskNotesTypePack();
const typeResource = pack.manifest.resources.find(
(resource) => resource.target === "_types/task.md",
);
const document = pack.resources.find(
(resource) => resource.source === typeResource.source,
).document;
expect(buildAppTaskNotesResources().typeDocument).toBe(document);
});

it("provisions TaskNotes-compatible string ranks for manual order", () => {
const generated = buildAppTaskNotesResources();
const implementation = generated.type.implements.find(
Expand Down
91 changes: 4 additions & 87 deletions scripts/tasknotes-resources.mjs
Original file line number Diff line number Diff line change
@@ -1,90 +1,7 @@
import { cloneDefaultModelConfig } from "@tasknotes/model/defaults";
import { serializeMarkdownDocument } from "@tasknotes/model/frontmatter";
import { buildTaskNotesMdbaseResources } from "@tasknotes/model/mdbase";
import { TASKNOTES_SPEC_VERSION } from "@tasknotes/model/types";
import { buildTaskNotesStarterResources } from "@tasknotes/model/starter";

// The published TaskNotes starter (the tasknotes.task pack's seed type). It is
// defined, and pinned to the published pack, in @tasknotes/model.
export function buildAppTaskNotesResources() {
const modelConfig = cloneDefaultModelConfig();
const statusColors = {
none: "#94a3b8",
open: "#64748b",
"in-progress": "#3b82f6",
done: "#22c55e",
};
const priorityColors = {
none: "#94a3b8",
low: "#3b82f6",
normal: "#f59e0b",
high: "#ef4444",
};
modelConfig.statuses = modelConfig.statuses.map((status) => ({
...status,
color: statusColors[status.value] ?? status.color,
}));
modelConfig.priorities = modelConfig.priorities.map((priority) => ({
...priority,
color: priorityColors[priority.value] ?? priority.color,
}));
modelConfig.statuses.push({
id: "cancelled",
value: "cancelled",
label: "Cancelled",
color: "#94a3b8",
isCompleted: false,
isSkipped: true,
excludeFromCycle: true,
order: modelConfig.statuses.length,
autoArchive: false,
autoArchiveDelay: 5,
});
const resources = buildTaskNotesMdbaseResources({
profiles: ["core-lite", "recurrence", "materialized-occurrences"],
modelConfig,
});
const type = structuredClone(resources.type);
const taskSchema = structuredClone(resources.taskSchema);
const implementation = type.implements.find(
(candidate) =>
candidate.contract === "tasknotes.task" &&
candidate.version === TASKNOTES_SPEC_VERSION,
);
if (!implementation)
throw new Error(
`The generated type does not implement tasknotes.task ${TASKNOTES_SPEC_VERSION}.`,
);
const taskDateSchema = {
anyOf: [
{ type: "string", format: "date" },
{ type: "string", format: "date-time" },
],
};
type.schema.value.properties[implementation.fields.due] = taskDateSchema;
type.schema.value.properties[implementation.fields.scheduled] =
taskDateSchema;
taskSchema.properties.due = taskDateSchema;
taskSchema.properties.scheduled = taskDateSchema;
const extension = implementation.binding;
extension.status = {
...extension.status,
skipped_values: ["cancelled"],
default_skipped: "cancelled",
};
extension.occurrences = {
...extension.occurrences,
default_materialization: modelConfig.occurrences.defaultMaterialization,
default_next_trigger: modelConfig.occurrences.defaultNextTrigger,
past_horizon: modelConfig.occurrences.pastHorizon,
future_horizon: modelConfig.occurrences.futureHorizon,
};
const body = `# Task

Task records live under \`${resources.paths.records}/\`.
`;
return {
...resources,
type,
taskSchema,
taskSchemaDocument: `${JSON.stringify(taskSchema, null, 2)}\n`,
typeDocument: serializeMarkdownDocument(type, body),
};
return buildTaskNotesStarterResources();
}
2 changes: 1 addition & 1 deletion vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ suites passed:

- `../mdbase-contracts` (`tasknotes.task` pack `0.3.0-rc.16`, catalog digest
`sha256:02aa8b3b…`, see `vendor/mdbase-contracts`)
- `../tasknotes-model` (`0.3.0-rc.13`)
- `../tasknotes-model` (`0.3.0-rc.14`, whose `@tasknotes/model/starter` defines the published starter type)
- `../tasknotes-nlp-core` (`62a0d9d`, including wikilink-safe parsing)
- `../tasknotes-spec`
- `../mdbase`
Expand Down
Binary file added vendor/tasknotes-model-0.3.0-rc.14.tgz
Binary file not shown.
Loading