Skip to content

Commit 5fc75e2

Browse files
committed
v0.7.2 — runtime support for deprecated: true itemDefs (Plan 50 Phase 3)
- HDSItemDef.isDeprecated getter - HDSModel.itemsDefs.getAllActive() filter (getAll/forKey/forEvent unchanged so readers still resolve old events) - 4 new tests in [MDPX] block
1 parent 7afe061 commit 5fc75e2

5 files changed

Lines changed: 70 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
## [Unreleased]
44

5+
## [0.7.2] - 2026-04-28
6+
7+
### Added — runtime support for `deprecated: true` itemDefs (Plan 50)
8+
- `HDSItemDef.isDeprecated` getter — `true` when the underlying itemDef has `deprecated: true` in pack.json (set in `data-model` ≥ 1.5.0).
9+
- `HDSModel.itemsDefs.getAllActive()` — returns every itemDef except deprecated ones. Use this for any UI that lets a user create new data points (form builder item browsers, item picker sheets, the data-model browser default listing).
10+
- `getAll()`, `forKey()`, `forEvent()` are unchanged: they still return deprecated items so existing events remain readable / renderable.
11+
12+
Tests: `[MDPX]` block in `tests/hdsModel.test.js` — covers the getter on the three currently-flagged items (`body-vulva-mucus-stretch`, `body-vulva-wetness-feeling`, `fertility-cycles-charted-count`), the contrast with non-deprecated items, and the `getAllActive` vs `getAll` invariant.
13+
14+
Contract documented in `data-model/AGENTS.md § "deprecated: true on items"`.
15+
516
## [0.7.1] - 2026-04-28
617

718
### Changed — `package.json.exports.import` now points at TS source (Plan 49)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hds-lib",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "Health Data Safe - Library",
55
"type": "module",
66
"engines": {

tests/hdsModel.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,41 @@ describe('[MODX] Model', () => {
3737
}
3838
});
3939

40+
// ---------- deprecated --------- //
41+
describe('[MDPX] deprecated items', function () {
42+
it('[MDPA] isDeprecated getter returns true for items flagged in pack.json', () => {
43+
// Three items were marked deprecated under plan 48 / formalised in plan 50.
44+
const stretch = model.itemsDefs.forKey('body-vulva-mucus-stretch');
45+
const wetness = model.itemsDefs.forKey('body-vulva-wetness-feeling');
46+
const charted = model.itemsDefs.forKey('fertility-cycles-charted-count');
47+
assert.equal(stretch.isDeprecated, true);
48+
assert.equal(wetness.isDeprecated, true);
49+
assert.equal(charted.isDeprecated, true);
50+
});
51+
52+
it('[MDPB] isDeprecated getter returns false for non-deprecated items', () => {
53+
assert.equal(model.itemsDefs.forKey('body-weight').isDeprecated, false);
54+
});
55+
56+
it('[MDPC] forKey still resolves deprecated items (readers must see them)', () => {
57+
const itemDef = model.itemsDefs.forKey('body-vulva-mucus-stretch');
58+
assert.ok(itemDef);
59+
assert.equal(itemDef.key, 'body-vulva-mucus-stretch');
60+
});
61+
62+
it('[MDPD] getAllActive() excludes deprecated, getAll() includes them', () => {
63+
const all = model.itemsDefs.getAll();
64+
const active = model.itemsDefs.getAllActive();
65+
assert.ok(all.length > active.length, 'active list must be smaller than full list');
66+
const activeKeys = new Set(active.map((d) => d.key));
67+
assert.equal(activeKeys.has('body-vulva-mucus-stretch'), false);
68+
assert.equal(activeKeys.has('body-vulva-wetness-feeling'), false);
69+
assert.equal(activeKeys.has('fertility-cycles-charted-count'), false);
70+
// sanity — non-deprecated items still in
71+
assert.equal(activeKeys.has('body-weight'), true);
72+
});
73+
});
74+
4075
// ---------- itemDef ------------ //
4176
describe('[MDVX] itemDef methods', function () {
4277
it('[MDVA] eventTemplate() returns event template with streamId and type', async () => {

ts/HDSModel/HDSItemDef.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ export class HDSItemDef {
3434
return this.#data.repeatable || 'unlimited';
3535
}
3636

37+
/**
38+
* Whether this item is deprecated. Deprecated items remain readable
39+
* (existing events keep validating + rendering) but should not be
40+
* surfaced in UIs that let users create new events. See
41+
* `data-model/AGENTS.md § "deprecated: true on items"`.
42+
*/
43+
get isDeprecated (): boolean {
44+
return this.#data.deprecated === true;
45+
}
46+
3747
get reminder (): ReminderConfig | null {
3848
return this.#data.reminder || null;
3949
}

ts/HDSModel/HDSModel-ItemsDefs.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export class HDSModelItemsDefs {
2929
}
3030

3131
/**
32-
* get all itemDefs
32+
* get all itemDefs (includes deprecated). Use this when reading existing
33+
* events: every event must still resolve to an itemDef even if the item
34+
* was deprecated.
3335
*/
3436
getAll (): HDSItemDef[] {
3537
const res: HDSItemDef[] = [];
@@ -39,6 +41,16 @@ export class HDSModelItemsDefs {
3941
return res;
4042
}
4143

44+
/**
45+
* get all non-deprecated itemDefs. Use this for any UI that lets a user
46+
* pick an item to create new data points (form builders, item picker
47+
* sheets, data-model browser default listing). Deprecated items remain
48+
* resolvable via `forKey` / `forEvent` so existing events still render.
49+
*/
50+
getAllActive (): HDSItemDef[] {
51+
return this.getAll().filter((itemDef) => !itemDef.isDeprecated);
52+
}
53+
4254
/**
4355
* get item for a key
4456
*/

0 commit comments

Comments
 (0)