Skip to content

Commit d87f91f

Browse files
committed
Merge branch 'macro' — plan 53 (role: context flag + isContext helper)
- Pre-existing patchedPryv import-x/first lint fix (e71501d) - HDSModelStreams#isContext(streamId) helper + 4 new tests [CTXR-P/Q/R/S] in tests/contextResolution.test.js (4ea42c2) Surfaces the new data-model role: context flag at the runtime layer. Returns true iff a stream definition has role === 'context'. Unknown streamIds return false (no throw — yes/no probe). Lint clean, 499 tests pass.
2 parents 3061fd4 + 4ea42c2 commit d87f91f

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Added (plan 53 phase A — `HDSModelStreams.isContext()` helper)
6+
- `HDSModelStreams#isContext(streamId): boolean` — returns `true` iff the stream's data-model definition carries `role: 'context'` (the D3 descendant-streamId marker flag introduced in `@hds/data-model` Plan 53 Phase A). Unknown streamIds return `false` (no throw).
7+
- Use this to elide / mute / re-render context streams as metadata in settings trees, form-section renderers, and dashboards rather than as data-bearing buckets. Runtime resolution (`itemsDefs.forEvent` walk-up) is unaffected.
8+
- Tests: `[CTXR-P/Q/R/S]` in `tests/contextResolution.test.js`. Validates against the locally-built `data-model/dist/pack.json` so the flag is sourced from real YAML.
9+
310
## [1.0.0] - 2026-05-27
411

512
### Plan 61 Phase C — legacy collector code deleted

tests/contextResolution.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ describe('[CTXR] Context-via-substream (Plan 46 D3)', () => {
104104
});
105105
});
106106

107+
describe('isContext() — Plan 53 role: context flag', () => {
108+
it('[CTXR-P] treatment-fertility is flagged as context', () => {
109+
assert.equal(model.streams.isContext('treatment-fertility'), true);
110+
});
111+
112+
it('[CTXR-Q] procedure-fertility is flagged as context', () => {
113+
assert.equal(model.streams.isContext('procedure-fertility'), true);
114+
});
115+
116+
it('[CTXR-R] data-bearing parent streams are not context', () => {
117+
assert.equal(model.streams.isContext('treatment'), false);
118+
assert.equal(model.streams.isContext('procedure'), false);
119+
});
120+
121+
it('[CTXR-S] unknown streamId returns false (no throw)', () => {
122+
assert.equal(model.streams.isContext('no-such-stream'), false);
123+
});
124+
});
125+
107126
describe('legacy multi-streamId resolution still works (no regression)', () => {
108127
it('[CTXR-K] event with multiple streamIds resolves via direct match', () => {
109128
// bridge-athenahealth pattern: streamIds carry both the canonical home

ts/HDSModel/HDSModel-Streams.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ export class HDSModelStreams {
7676
return streamData;
7777
}
7878

79+
/**
80+
* True iff the stream exists and its data-model definition carries
81+
* `role: 'context'` — i.e. it's a descendant-streamId marker for the D3
82+
* context-via-substream mechanic, not a data-bearing bucket. Unknown
83+
* streamIds return `false` (no throw — this is a yes/no probe).
84+
*
85+
* Consumers (settings trees, form-section renderers, dashboards) should
86+
* use this to elide / mute / re-render context streams as metadata rather
87+
* than as independent input streams. See Plan 53.
88+
*/
89+
isContext (streamId: string): boolean {
90+
const streamData = this.#modelStreamsById[streamId];
91+
return streamData != null && streamData.role === 'context';
92+
}
93+
7994
/**
8095
* Get all parents id;
8196
*/

ts/patchedPryv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import _pryv from 'pryv';
99
import type * as _PryvTypes from 'pryv';
1010
import monitor from '@pryv/monitor';
1111
import socketIo from '@pryv/socket.io';
12+
import * as _cmc from '@pryv/cmc';
1213
// @ts-expect-error CJS plugin pattern: module.exports = function(pryv) { ... }
1314
monitor(_pryv);
1415
// @ts-expect-error CJS plugin pattern: module.exports = function(pryv) { ... }
@@ -40,5 +41,4 @@ export namespace pryv {
4041
export type KeyValue = _PryvTypes.KeyValue;
4142
}
4243

43-
import * as _cmc from '@pryv/cmc';
4444
export const cmc = _cmc;

0 commit comments

Comments
 (0)