Skip to content

refactor(mdbase): use the model package's vocabulary check, and share custom field names - #2536

Merged
callumalpass merged 2 commits into
v5from
refactor/v5-model-type-editor
Nov 10, 2026
Merged

callumalpass merged 2 commits into
v5from
refactor/v5-model-type-editor

Conversation

@callumalpass

@callumalpass callumalpass commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Why

The plugin, the TaskNotes app and @tasknotes/model each had their own code for the statuses, priorities and custom fields a task type holds. callumalpass/tasknotes-model#26 puts the editing and checking in the model package. This moves the plugin's checking onto it. The plugin still writes the type by generating it from settings and merging, because that also covers field mapping, task identification and filenames, which the model's editor does not; the model now tests that its generator and its editor produce the same type.

What changes

  • validateCanonicalTaskType no longer compares the binding with the schema by hand. It uses the model's taskNotesMdbaseTypeDisagreements and reconcileTaskNotesMdbaseTypeVocabulary. A type whose two lists differ is read with every value either list names, and is valid if that list is one a collection can hold. A type that cannot be reconciled is reported as before, with the same messages.
  • The collection check counts a status only the schema allows as a status. It still validates records against the schema as written.
  • A custom field's display name is written to the type as the property's title (the model's generator does this from rc.21), wins over the stale title when the plugin merges, is part of the settings fingerprint so a rename is saved, and is read back in preference to this device's name.

Behaviour people can notice

  • Adding a status to the type's schema by hand used to block the type with "is inconsistent". It is now read, and the next settings change writes it to both places.
  • A custom field renamed in the plugin shows that name in the app and on other devices, and the reverse.
  • Removing a value from only the schema does not remove the status: the binding still describes it, and the next write restores it. Remove it in settings instead.

Deleting a status that tasks still use is unchanged: the plugin still allows it after its confirmation, and the collection check finds those tasks.

Dependency

@tasknotes/model is pinned to 0.3.0-rc.21 from npm, published from tasknotes-model#26. The vendored build used while it was unpublished is removed.

Testing

  • npx jest: 830 suites, 6,705 tests pass against the npm package. New tests cover a schema-only status, a status the schema lost, a type that cannot be reconciled, and a field name going both ways.
  • npm run lint, npx tsc --noEmit, npm run build, run locally; no CI runs on this branch.
  • Not run in Obsidian.

The plugin compared the binding's statuses, priorities and defaults with
the schema's by hand and reported any difference as an inconsistent type.
@tasknotes/model 0.3.0-rc.21 now reads every value either copy names and
can make the copies agree, so a status added to the schema by hand is read
instead of blocking the type. The next write from settings stores one list.

A custom field's name is written to the type as the property's title and
read back from it, so it reaches other devices and the TaskNotes app.
Removes the vendored build of the unpublished release and restores the
dependency order in package.json that the earlier install had changed.
@callumalpass
callumalpass marked this pull request as ready for review November 10, 2026 23:42
@callumalpass
callumalpass merged commit 7a81df5 into v5 Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant