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
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Changelog

## Unreleased
## 0.3.0-rc.22

### Added

- `LEGACY_APP_SETTINGS_FOLDER`, `legacyAppSettingsPath(app)` and `resolveAppSettingsPath(app, { currentExists, legacyExists })`, exported from the root and `@tasknotes/model/settings`. The resolver chooses the new path when it exists, otherwise the legacy path when it exists, otherwise the new path for creation. Clients read and save the selected record without moving it.

### Changed

- **New-collection layout:** `APP_SETTINGS_FOLDER` and `appSettingsPath` / `TASKNOTES_SETTINGS_PATH` now use `_mdbase/settings`. New collection resources explicitly default to `_mdbase/types` and `_mdbase/contracts`; schema files follow the parent of the contracts folder. Existing collections keep their configured folders (or the unchanged mdbase spec defaults `_types` / `_contracts`); clients must use the path resolver rather than creating a second settings record.
- Settings resources implement `mdbase.app-settings` 2.0.0 and `tasknotes.settings` 1.1.0 with settings type version 2. The record's `settings_version` remains 1. `resolveAppSettings` accepts the path read as its third argument, and `resolveTaskNotesAppSettings` accepts `options.path`, so read-only messages identify the actual record.
- Vendor the `tasknotes.task` 0.3.0-rc.21 pack from mdbase-contracts PR #23 (`c50a6d08d975b02891fdb8f9c9f08011179efd51`). Generated packs now include the published settings resources, retained contracts/schemas and seed upgrade history, with configured folder targets and byte-identical support documents. `provides` includes the settings contracts as well as `tasknotes.task`. Refresh the vendored artifact with `MDBASE_CONTRACTS_ROOT=<checkout> npm run sync:mdbase-pack` after building that checkout's `dist/`.
- Documented `taskSchemaDocument`, `bindingSchemaDocument`, `paths.taskSchema` and `paths.bindingSchema` as tasknotes.task type-pack resources. A host must not write them as plain files: mdbase setup refuses a plain file at a path the pack manages unless it holds the exact resource bytes (tasknotes-app #436). The contract already carries both schemas inline.

## 0.3.0-rc.21
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,31 @@ The package exports both the root module and focused subpath modules:
| `@tasknotes/model/frontmatter` | Markdown task document parse/serialize helpers |
| `@tasknotes/model/mdbase` | Canonical mdbase v0.3 config, contract, schema, and implementing-type generation; reading a type or implementation into a configuration; `patchTaskNotesMdbaseTypeSettings`, the one editor for a task type's settings, statuses, priorities and custom fields |
| `@tasknotes/model/starter` | The published TaskNotes starter type (`tasknotes.task` pack seed), pinned to mdbase-contracts by the test suite. Use it, not the plugin defaults in `defaults`, to build starter types |
| `@tasknotes/model/settings` | Shared app-settings paths, resolution, patches, conflicts and published TaskNotes settings resources |
| `@tasknotes/model/conformance` | tasknotes-spec conformance operation dispatcher |

## Collection metadata and settings

New collection resources explicitly use `_mdbase/types`, `_mdbase/contracts` and
`_mdbase/settings/<app>.md`. Schema resources are placed under the parent of the
contracts folder. Existing collections keep their configured layout; when reading
an existing config, the mdbase spec defaults remain `_types` and `_contracts`.
Pass those existing folders to the resource builders instead of adopting the
new-collection defaults.

Check `appSettingsPath(app)` and `legacyAppSettingsPath(app)`, then call
`resolveAppSettingsPath(app, { currentExists, legacyExists })`. Read and save the
returned path: new wins when both exist, legacy wins when only it exists, and
creation uses the new path. Never move a record or fall back merely because its
contents are invalid. Pass the selected path to `resolveAppSettings` as its third
argument, or to `resolveTaskNotesAppSettings` as `options.path`, so messages name
the record actually read.

`buildTaskNotesMdbaseTypePack` carries the published rc.21 settings resources,
retained contracts and schemas, and seed upgrade history. Its `provides` includes
`tasknotes.settings` 1.1.0 and `mdbase.app-settings` 2.0.0 alongside `tasknotes.task`.
The settings type is version 2; the record's `settings_version` remains 1.

## Calendar contract

```ts
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tasknotes/model",
"version": "0.3.0-rc.21",
"version": "0.3.0-rc.22",
"description": "TaskNotes model, mapping, validation, recurrence, and operation-planning reference implementation.",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -138,6 +138,7 @@
"scripts": {
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
"sync:mdbase-contract": "node scripts/sync-tasknotes-contract.mjs",
"sync:mdbase-pack": "node scripts/sync-tasknotes-pack.mjs",
"build": "npm run clean && node scripts/build.mjs && tsc -p tsconfig.types.json",
"prepack": "npm run build",
"typecheck": "tsc -p tsconfig.types.json --emitDeclarationOnly false --noEmit",
Expand Down
8 changes: 8 additions & 0 deletions scripts/smoke-package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ try {
);

for (const [filename, content] of [
["settings.mjs", 'import { resolveAppSettingsPath as rootResolve } from "@tasknotes/model";\nimport { resolveAppSettingsPath, legacyAppSettingsPath, LEGACY_APP_SETTINGS_FOLDER } from "@tasknotes/model/settings";\nif (rootResolve("dev.tasknotes", { currentExists: false, legacyExists: true }) !== legacyAppSettingsPath("dev.tasknotes")) throw new Error("Root settings export failed");\nif (LEGACY_APP_SETTINGS_FOLDER !== "_settings" || resolveAppSettingsPath("dev.tasknotes", { currentExists: false, legacyExists: false }) !== "_mdbase/settings/dev.tasknotes.md") throw new Error("ESM settings exports failed");\n'],
["settings.cjs", 'const { resolveAppSettingsPath } = require("@tasknotes/model/settings");\nconst { legacyAppSettingsPath } = require("@tasknotes/model");\nif (resolveAppSettingsPath("dev.tasknotes", { currentExists: false, legacyExists: true }) !== legacyAppSettingsPath("dev.tasknotes")) throw new Error("CJS settings exports failed");\n'],
["settings.ts", 'import { resolveAppSettingsPath } from "@tasknotes/model";\nimport { appSettingsPath, legacyAppSettingsPath, resolveTaskNotesAppSettings } from "@tasknotes/model/settings";\nconst path: string = resolveAppSettingsPath("dev.tasknotes", { currentExists: true, legacyExists: true });\nresolveTaskNotesAppSettings(undefined, { path });\nvoid appSettingsPath;\nvoid legacyAppSettingsPath;\n'],
["calendar.mjs", 'import { buildCalendarEntries, createCalendarEntryIndex, planCalendarEdit } from "@tasknotes/model/calendar";\nimport { calendarFixtures } from "@tasknotes/model/calendar/fixtures";\nif (!planCalendarEdit || !createCalendarEntryIndex || buildCalendarEntries(calendarFixtures[0].input).length !== calendarFixtures[0].expectedEntries.length) throw new Error("ESM calendar exports failed");\n'],
["calendar.cjs", 'const { buildCalendarEntries } = require("@tasknotes/model/calendar");\nconst { calendarFixtures } = require("@tasknotes/model/calendar/fixtures");\nconst raw = [...require("@tasknotes/model/fixtures/calendar/scenarios.json"), ...require("@tasknotes/model/fixtures/calendar/moved-occurrences.json")];\nif (raw.length !== calendarFixtures.length || buildCalendarEntries(raw[0].input).length !== raw[0].expectedEntries.length) throw new Error("CJS calendar exports failed");\n'],
["calendar.ts", 'import { buildCalendarEntries, type CalendarEntry } from "@tasknotes/model/calendar";\nimport { calendarFixtures, type CalendarFixture } from "@tasknotes/model/calendar/fixtures";\nconst fixture: CalendarFixture = calendarFixtures[0];\nconst entries: CalendarEntry[] = buildCalendarEntries(fixture.input);\nvoid entries;\n'],
Expand All @@ -61,11 +64,16 @@ try {
execFileSync(process.execPath, ["attachments.cjs"], { cwd: tempRoot, stdio: "inherit" });
execFileSync(process.execPath, ["calendar.mjs"], { cwd: tempRoot, stdio: "inherit" });
execFileSync(process.execPath, ["calendar.cjs"], { cwd: tempRoot, stdio: "inherit" });
execFileSync(process.execPath, ["settings.mjs"], { cwd: tempRoot, stdio: "inherit" });
execFileSync(process.execPath, ["settings.cjs"], { cwd: tempRoot, stdio: "inherit" });
for (const resolution of ["nodenext", "node"]) {
execFileSync(process.execPath, [resolve(packageRoot, "node_modules/typescript/bin/tsc"),
"--noEmit", "--strict", "--target", "es2020", "--module", resolution === "nodenext" ? "nodenext" : "esnext",
"--moduleResolution", resolution, "calendar.ts"], { cwd: tempRoot, stdio: "inherit" });
}
execFileSync(process.execPath, [resolve(packageRoot, "node_modules/typescript/bin/tsc"),
"--noEmit", "--strict", "--target", "es2020", "--module", "esnext",
"--moduleResolution", "node", "settings.ts"], { cwd: tempRoot, stdio: "inherit" });
} finally {
if (tarball) rmSync(tarball, { force: true });
rmSync(tempRoot, { recursive: true, force: true });
Expand Down
18 changes: 18 additions & 0 deletions scripts/sync-tasknotes-pack.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { mkdir, readFile, writeFile } from "node:fs/promises";
import path from "node:path";

const contractsRoot =
process.env.MDBASE_CONTRACTS_ROOT ??
path.resolve(import.meta.dirname, "../../mdbase-contracts");
const generatedPath = path.resolve(
import.meta.dirname,
"../src/generated/tasknotes-type-pack.json"
);
const source = await readFile(
path.join(contractsRoot, "dist/packs/tasknotes.task/0.3.0-rc.21.json"),
"utf8"
);

await mkdir(path.dirname(generatedPath), { recursive: true });
await writeFile(generatedPath, source);
console.log(`Synced TaskNotes type pack from ${contractsRoot}`);
Loading
Loading