From f2497993d1fb631784a06d4e855cfa155dd523c7 Mon Sep 17 00:00:00 2001 From: callumalpass Date: Wed, 18 Nov 2026 08:28:42 +1100 Subject: [PATCH 1/2] feat: keep the task ID under the type's mapped property A collection's task type can map the tasknotes.task id field to another property (callumalpass/tasknotes#2574). Writes now use the mapped name instead of always writing id, and the summary index reads it. Reading already goes through the model mapping. Requires @tasknotes/model 0.3.1. --- docs/releases/unreleased.md | 2 ++ pnpm-lock.yaml | 14 +++++++------- pnpm-workspace.yaml | 2 +- src/domain/tasknotes-model.test.ts | 28 ++++++++++++++++++++++++++++ src/domain/tasknotes-model.ts | 5 +++-- 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index e2e2171d..96632422 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -1,5 +1,7 @@ # Unreleased +- Keep each task's ID in the property your collection's task type maps it to, such as `tasknote_id`, instead of always writing `id`. A plain `id` property is then left as your own data. Collections that use `id` are unchanged (tasknotes#2574, requested by @minchinweb). + - Show reminders as ready as soon as notification access is approved in mdbase, instead of still asking for approval until the page is reloaded. - Keep a reminder's generated notification text in step with its time: changing "15 minutes before" to 2 minutes now reads "2 minutes before". Text you wrote yourself is never changed. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4899baca..bcfc057b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,8 +10,8 @@ catalogs: specifier: 0.1.7 version: 0.1.7 '@tasknotes/model': - specifier: 0.3.0 - version: 0.3.0 + specifier: 0.3.1 + version: 0.3.1 importers: @@ -94,7 +94,7 @@ importers: version: 0.1.10(react@19.2.8) '@tasknotes/model': specifier: 'catalog:' - version: 0.3.0 + version: 0.3.1 codemirror: specifier: ^6.0.2 version: 6.0.2 @@ -254,7 +254,7 @@ importers: version: 0.1.7 '@tasknotes/model': specifier: 'catalog:' - version: 0.3.0 + version: 0.3.1 react: specifier: 19.3.0 version: 19.3.0 @@ -1831,8 +1831,8 @@ packages: react: optional: true - '@tasknotes/model@0.3.0': - resolution: {integrity: sha512-F7JfLCszUgMOfRCFVW+rfV97IP5fmWpc/ZNCZ+GyzwZAnxggGgLVvJIArn+biiwCAdbr8Fk0lXxMIu2/HRarqw==} + '@tasknotes/model@0.3.1': + resolution: {tarball: https://registry.npmjs.org/@tasknotes/model/-/model-0.3.1.tgz} '@testing-library/dom@10.4.1': resolution: {integrity: sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==} @@ -6635,7 +6635,7 @@ snapshots: optionalDependencies: react: 19.2.8 - '@tasknotes/model@0.3.0': + '@tasknotes/model@0.3.1': dependencies: rrule: 2.8.1 yaml: 2.9.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 46e3aff2..36039072 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -3,4 +3,4 @@ packages: catalog: "@mdbase-dev/sdk": 0.1.7 - "@tasknotes/model": 0.3.0 + "@tasknotes/model": 0.3.1 diff --git a/src/domain/tasknotes-model.test.ts b/src/domain/tasknotes-model.test.ts index 6335083a..307c8359 100644 --- a/src/domain/tasknotes-model.test.ts +++ b/src/domain/tasknotes-model.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it, vi } from "vitest"; import { buildCalendarEntries } from "@tasknotes/model/calendar"; +import { DEFAULT_FIELD_MAPPING } from "@tasknotes/model/mapping"; import { calendarOccurrenceChoice } from "./calendar-edit"; import { TaskNotesTaskModel } from "./tasknotes-model"; @@ -1020,3 +1021,30 @@ function priority(value: string, label: string, weight: number) { function canonicalLocal(value: string): string { return new Date(value).toISOString().replace(".000Z", "Z"); } + +// tasknotes#2574: a collection's type can store the stable ID under another +// property, freeing `id` for the user's own data. +describe("a remapped task ID", () => { + const model = new TaskNotesTaskModel({ + fieldMapping: { ...DEFAULT_FIELD_MAPPING, id: "tasknote_id" }, + }); + + it("writes, reads and keeps the ID under the mapped property", () => { + const created = model.create({ title: "Remapped" }, { id: "abc" }); + expect(created.id).toBe("abc"); + expect(created.frontmatter.tasknote_id).toBe("abc"); + expect(created.frontmatter).not.toHaveProperty("id"); + + const task = model.read({ + path: created.path, + frontmatter: { ...created.frontmatter, id: "mine" }, + body: "", + }); + expect(task.id).toBe("abc"); + + const updated = model.update(task, { title: "Renamed" }); + expect(updated.frontmatter.tasknote_id).toBe("abc"); + expect(updated.frontmatter.id).toBe("mine"); + expect(model.summaryFields()).toContain("tasknote_id"); + }); +}); diff --git a/src/domain/tasknotes-model.ts b/src/domain/tasknotes-model.ts index c218e79d..4fec0590 100644 --- a/src/domain/tasknotes-model.ts +++ b/src/domain/tasknotes-model.ts @@ -15,6 +15,7 @@ import { updateToNextScheduledOccurrence } from "@tasknotes/model/recurrence"; import { mapTaskFromFrontmatter, mapTaskToFrontmatter, + toUserField, } from "@tasknotes/model/mapping"; import { applyFrontmatterPatch, @@ -202,7 +203,7 @@ export class TaskNotesTaskModel { summaryFields(): string[] { return [ ...new Set([ - "id", + toUserField(this.config.fieldMapping, "id"), "mobileRevision", "tags", ...Object.values(this.config.fieldMapping), @@ -983,7 +984,7 @@ export class TaskNotesTaskModel { ) ? { [this.config.fieldMapping.skippedInstances]: [] } : {}), - id, + [toUserField(this.config.fieldMapping, "id")]: id, mobileRevision: revision, }; } From a1233feb0fa08a44066786a0e71933f727fa1dcd Mon Sep 17 00:00:00 2001 From: callumalpass Date: Thu, 19 Nov 2026 00:05:40 +1100 Subject: [PATCH 2/2] chore(deps): record @tasknotes/model 0.3.1 integrity --- pnpm-lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bcfc057b..cf2f4c44 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1832,7 +1832,7 @@ packages: optional: true '@tasknotes/model@0.3.1': - resolution: {tarball: https://registry.npmjs.org/@tasknotes/model/-/model-0.3.1.tgz} + resolution: {integrity: sha512-LEFpiTO4o37Z83JqzfvsI5GSjgOVYKyjIrIjiJylVk/bcQJgoUp/NgN+EsvOPNlxSqJRJk2QQHjf9gW7/MeNhA==} '@testing-library/dom@10.4.1': resolution: {integrity: sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==}