@selfhelp/shared 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,182 +1,231 @@
1
- # Changelog
2
-
3
- All notable changes to `@selfhelp/shared` will be documented in this file.
4
-
5
- This project follows semantic versioning.
6
-
7
- ## [1.2.0] - 2026-05-28
8
-
9
- ### Added
10
-
11
- - Canonical plugin runtime-shim contract exported from
12
- `@selfhelp/shared/plugin-sdk`. This is the single source of truth
13
- every consumer (host import map, host `globalThis` stash, host
14
- `/api/plugins/runtime-shim/*` BFF route, plugin Vite build, plugin
15
- dev-runtime server) now reads from, so the three pieces cannot
16
- drift apart again:
17
- - `PLUGIN_RUNTIME_SHIM_SPECIFIERS` — readonly list of every bare
18
- specifier the host shims to plugins. Includes the previously
19
- missing `react/jsx-dev-runtime` (needed by Vite's React plugin in
20
- dev mode) and `@mantine/notifications` (consumed by plugins that
21
- show toast notifications), so dev-server bundles can resolve them
22
- instead of bundling a second copy of React or Mantine.
23
- - `PLUGIN_RUNTIME_SHIM_BASE_PATH` — `/api/plugins/runtime-shim/`
24
- constant; the host frontend owns this route.
25
- - `PLUGIN_RUNTIME_GLOBAL_KEY` — `__SELFHELP_RUNTIME__` constant.
26
- - `PLUGIN_RUNTIME_IMPORT_MAP` — frozen `Record` derived from the
27
- specifier list, ready to be `JSON.stringify`ed into the host's
28
- `<script type="importmap">` tag.
29
- - `buildPluginRuntimeShimPath(specifier)` — string builder for a
30
- single specifier.
31
- - `isPluginRuntimeShimSpecifier(value)` — runtime type guard.
32
- - `TPluginRuntimeShimSpecifier` — string-literal type union of the
33
- supported specifiers.
34
- - The plugin SDK contract version bumps from `1.1` to `1.2` to
35
- reflect the additive surface. Hosts on SDK `1.2+` still accept
36
- plugins declaring `pluginApiVersion: "1.1"`, so existing plugins
37
- remain compatible.
38
-
39
- ### Changed
40
-
41
- - `PLUGIN_API_VERSION` constant: `1.1` → `1.2`. No behavioural
42
- change for plugins that do not consume the runtime-shim contract
43
- directly; this only signals which optional SDK surface the host
44
- exposes.
45
-
46
- ## [1.1.0] - 2026-05-25
47
-
48
- ### Added
49
-
50
- - Plugin SDK field-renderer contracts:
51
- `IFieldRendererDefinition`, `IPluginFieldRendererProps`, and
52
- `fieldRenderers` on `IPluginRegistration`, so plugins can contribute
53
- custom CMS section-field editor controls for plugin-owned field types.
54
-
55
- ### Changed
56
-
57
- - Bumped `PLUGIN_API_VERSION` from `1.0` to `1.1` to reflect the new
58
- additive plugin SDK surface.
59
- - Re-exported the new field-renderer types from `@selfhelp/shared/plugin-sdk`.
60
-
61
- ## [1.0.4] - 2026-05-22
62
-
63
- ### Added
64
-
65
- - New `plugin-sdk` surface for the SelfHelp plugin ecosystem:
66
- - `definePlugin()` / `defineMobilePlugin()` helpers for typed plugin
67
- manifests.
68
- - `definePluginRealtimeTopic()` topic helpers with template expansion.
69
- - `usePluginRealtime()` React hook for Mercure topic subscription. The
70
- hook accepts a `transportFactory` so frontend hosts can inject
71
- `EventSource` and mobile hosts can inject `react-native-sse` without
72
- forcing the SDK to depend on either runtime.
73
- - TypeScript mirrors for `IPluginManifest`, `IPluginRegistry`, and
74
- `IPluginLock` plus the `scripts/check-schema-parity.mjs` script that
75
- verifies the JSON schemas stay in lockstep with the TS types.
76
- - React is now declared as an **optional peer dependency**
77
- (`react ^18 || ^19`). Non-React consumers can keep using the package
78
- without installing React; the `usePluginRealtime` hook is only required
79
- if you opt into realtime updates.
80
-
81
- ### Changed (breaking type contracts)
82
-
83
- These changes broaden the schema-mirroring types so they actually match
84
- the canonical JSON Schemas the backend publishes. Plugin authors
85
- upgrading from `1.0.3` need to update any code that constructed these
86
- shapes literally:
87
-
88
- - `IPluginRegistry`
89
- - Renamed `schemaVersion` (string `'1.0'`) to **`registryVersion`**
90
- (`number`, currently `1`).
91
- - Added required field `name: string`.
92
- - Added optional `homepage`, `publishedAt`, `trustKey`, and `channels`
93
- fields to align with `plugin-registry.schema.json`.
94
- - `IPluginLock`
95
- - Added required field **`lockfileVersion: number`** (currently `1`).
96
- - Added required nested object **`sdk: { version: string; pluginApiVersion: string }`**
97
- so lockfiles always advertise which SDK version they were generated
98
- against.
99
- - `plugins` is now `Record<string, IPluginLockEntry>` instead of an
100
- array — keyed by plugin id, which matches the schema and removes
101
- the need for clients to do an extra lookup.
102
- - `installMode` is now optional at the top level (per-entry
103
- `installMode` already exists inside each plugin entry).
104
- - `IPluginManifest`
105
- - `dataAccess` gained `ownedTables: string[]` and
106
- `ownedDataTablePrefix?: string` so plugins can declare their owned
107
- tables for the install-time validator and the purger.
108
-
109
- ### Migration notes for plugin authors
110
-
111
- ```ts
112
- // before (1.0.3)
113
- const registry: IPluginRegistry = {
114
- schemaVersion: '1.0',
115
- plugins: [],
116
- };
117
-
118
- // after (1.0.4)
119
- const registry: IPluginRegistry = {
120
- registryVersion: 1,
121
- name: 'my-registry',
122
- plugins: [],
123
- };
124
- ```
125
-
126
- ```ts
127
- // before (1.0.3)
128
- const lock: IPluginLock = {
129
- generatedAt: '...',
130
- plugins: [],
131
- installMode: 'managed',
132
- };
133
-
134
- // after (1.0.4)
135
- const lock: IPluginLock = {
136
- lockfileVersion: 1,
137
- generatedAt: '...',
138
- sdk: { version: '1.0.4', pluginApiVersion: '1.0' },
139
- plugins: {},
140
- };
141
- ```
142
-
143
- Run `npm run check:schemas` (from `sh-selfhelp_shared`) to verify your
144
- TypeScript matches the canonical JSON schemas after the upgrade.
145
-
146
- ## [1.0.3] - 2026-05-19
147
-
148
- - Adjust types after the DB refactoring
149
-
150
- ## [1.0.0] - 2026-05-08
151
-
152
- First stable release of `@selfhelp/shared`.
153
-
154
- ### Added
155
-
156
- - Shared TypeScript contracts for pages, styles, auth models, and API payloads.
157
- - A typed `STYLE_REGISTRY` for CMS-driven rendering.
158
- - Common theme token exports and a shared Tailwind preset surface.
159
- - Runtime helpers for:
160
- - interpolation via `replaceCalcedValues()`
161
- - condition evaluation via `evaluateCondition()`
162
- - asset URL normalization via `resolveAssetUrl()`
163
- - spacing parsing and page-data transformation utilities
164
- - CMS class allow-listing, remapping, and classification helpers.
165
- - Public npm packaging setup for reuse across multiple projects.
166
-
167
- ### Included in this release
168
-
169
- - Root package exports for the main shared API.
170
- - Subpath exports for:
171
- - `@selfhelp/shared/registry`
172
- - `@selfhelp/shared/theme`
173
- - `@selfhelp/shared/tailwind`
174
- - Generated CJS, ESM, and TypeScript declaration output in `dist/`.
175
- - README publishing instructions and package documentation.
176
-
177
- ### Purpose of the 1.0.0 release
178
-
179
- This release establishes `@selfhelp/shared` as the source of truth for shared
180
- frontend and mobile contracts in the SelfHelp ecosystem. The goal of `1.0.0` is
181
- to provide a stable base that other applications can install, build against, and
182
- upgrade using normal npm versioning.
1
+ <!--
2
+ SPDX-FileCopyrightText: 2026 Humdek, University of Bern
3
+ SPDX-License-Identifier: MPL-2.0
4
+ -->
5
+
6
+ # Changelog
7
+
8
+ All notable changes to `@selfhelp/shared` will be documented in this file.
9
+
10
+ This project follows semantic versioning.
11
+
12
+ ## [1.2.1] - 2026-05-28
13
+
14
+ ### Fixed
15
+
16
+ - `IPluginRegistry` in `@selfhelp/shared/plugin-sdk` is now back in
17
+ sync with the canonical `plugin-registry.schema.json` shipped by
18
+ `sh-selfhelp_backend`. The root version field is the schema's
19
+ `schemaVersion: '1.0'` again (the `registryVersion: number` rename
20
+ introduced in `1.0.4` mis-described the wire format). Added the two
21
+ other canonical root fields, `baseUrl` and `publisher`, as optional
22
+ so the type matches what `scripts/publish-to-registry.mjs` actually
23
+ emits. The pre-existing `name` / `homepage` / `trustKey` /
24
+ `channels` properties are kept as optional legacy helpers and
25
+ flagged in the JSDoc as not part of the canonical schema; they will
26
+ be removed in the next major release once the deeper drift in
27
+ `IPluginRegistryEntry` / `IPluginRegistryVersionEntry` is rewritten
28
+ to match the canonical schema.
29
+ - `npm run check:schemas` is green again — previously failed because
30
+ `schemaVersion` was missing from the TS mirror after the `1.0.4`
31
+ rename.
32
+
33
+ ### Migration notes
34
+
35
+ ```ts
36
+ // before (1.2.0, broken)
37
+ const registry: IPluginRegistry = {
38
+ registryVersion: 1,
39
+ name: 'my-registry',
40
+ plugins: [],
41
+ };
42
+
43
+ // after (1.2.1, matches plugin-registry.schema.json)
44
+ const registry: IPluginRegistry = {
45
+ schemaVersion: '1.0',
46
+ publisher: { name: 'my-registry' },
47
+ plugins: [],
48
+ };
49
+ ```
50
+
51
+ No runtime/installation behaviour changed — this only corrects the
52
+ shape of the published TS contract that plugin authors compile
53
+ against. The backend's `RegistryClient` already reads the canonical
54
+ wire format, so installed registries keep working.
55
+
56
+ ## [1.2.0] - 2026-05-28
57
+
58
+ ### Added
59
+
60
+ - Canonical plugin runtime-shim contract exported from
61
+ `@selfhelp/shared/plugin-sdk`. This is the single source of truth
62
+ every consumer (host import map, host `globalThis` stash, host
63
+ `/api/plugins/runtime-shim/*` BFF route, plugin Vite build, plugin
64
+ dev-runtime server) now reads from, so the three pieces cannot
65
+ drift apart again:
66
+ - `PLUGIN_RUNTIME_SHIM_SPECIFIERS` — readonly list of every bare
67
+ specifier the host shims to plugins. Includes the previously
68
+ missing `react/jsx-dev-runtime` (needed by Vite's React plugin in
69
+ dev mode) and `@mantine/notifications` (consumed by plugins that
70
+ show toast notifications), so dev-server bundles can resolve them
71
+ instead of bundling a second copy of React or Mantine.
72
+ - `PLUGIN_RUNTIME_SHIM_BASE_PATH` — `/api/plugins/runtime-shim/`
73
+ constant; the host frontend owns this route.
74
+ - `PLUGIN_RUNTIME_GLOBAL_KEY` — `__SELFHELP_RUNTIME__` constant.
75
+ - `PLUGIN_RUNTIME_IMPORT_MAP` — frozen `Record` derived from the
76
+ specifier list, ready to be `JSON.stringify`ed into the host's
77
+ `<script type="importmap">` tag.
78
+ - `buildPluginRuntimeShimPath(specifier)` — string builder for a
79
+ single specifier.
80
+ - `isPluginRuntimeShimSpecifier(value)` — runtime type guard.
81
+ - `TPluginRuntimeShimSpecifier` — string-literal type union of the
82
+ supported specifiers.
83
+ - The plugin SDK contract version bumps from `1.1` to `1.2` to
84
+ reflect the additive surface. Hosts on SDK `1.2+` still accept
85
+ plugins declaring `pluginApiVersion: "1.1"`, so existing plugins
86
+ remain compatible.
87
+
88
+ ### Changed
89
+
90
+ - `PLUGIN_API_VERSION` constant: `1.1` → `1.2`. No behavioural
91
+ change for plugins that do not consume the runtime-shim contract
92
+ directly; this only signals which optional SDK surface the host
93
+ exposes.
94
+
95
+ ## [1.1.0] - 2026-05-25
96
+
97
+ ### Added
98
+
99
+ - Plugin SDK field-renderer contracts:
100
+ `IFieldRendererDefinition`, `IPluginFieldRendererProps`, and
101
+ `fieldRenderers` on `IPluginRegistration`, so plugins can contribute
102
+ custom CMS section-field editor controls for plugin-owned field types.
103
+
104
+ ### Changed
105
+
106
+ - Bumped `PLUGIN_API_VERSION` from `1.0` to `1.1` to reflect the new
107
+ additive plugin SDK surface.
108
+ - Re-exported the new field-renderer types from `@selfhelp/shared/plugin-sdk`.
109
+
110
+ ## [1.0.4] - 2026-05-22
111
+
112
+ ### Added
113
+
114
+ - New `plugin-sdk` surface for the SelfHelp plugin ecosystem:
115
+ - `definePlugin()` / `defineMobilePlugin()` helpers for typed plugin
116
+ manifests.
117
+ - `definePluginRealtimeTopic()` topic helpers with template expansion.
118
+ - `usePluginRealtime()` React hook for Mercure topic subscription. The
119
+ hook accepts a `transportFactory` so frontend hosts can inject
120
+ `EventSource` and mobile hosts can inject `react-native-sse` without
121
+ forcing the SDK to depend on either runtime.
122
+ - TypeScript mirrors for `IPluginManifest`, `IPluginRegistry`, and
123
+ `IPluginLock` plus the `scripts/check-schema-parity.mjs` script that
124
+ verifies the JSON schemas stay in lockstep with the TS types.
125
+ - React is now declared as an **optional peer dependency**
126
+ (`react ^18 || ^19`). Non-React consumers can keep using the package
127
+ without installing React; the `usePluginRealtime` hook is only required
128
+ if you opt into realtime updates.
129
+
130
+ ### Changed (breaking type contracts)
131
+
132
+ These changes broaden the schema-mirroring types so they actually match
133
+ the canonical JSON Schemas the backend publishes. Plugin authors
134
+ upgrading from `1.0.3` need to update any code that constructed these
135
+ shapes literally:
136
+
137
+ - `IPluginRegistry`
138
+ - Renamed `schemaVersion` (string `'1.0'`) to **`registryVersion`**
139
+ (`number`, currently `1`).
140
+ - Added required field `name: string`.
141
+ - Added optional `homepage`, `publishedAt`, `trustKey`, and `channels`
142
+ fields to align with `plugin-registry.schema.json`.
143
+ - `IPluginLock`
144
+ - Added required field **`lockfileVersion: number`** (currently `1`).
145
+ - Added required nested object **`sdk: { version: string; pluginApiVersion: string }`**
146
+ so lockfiles always advertise which SDK version they were generated
147
+ against.
148
+ - `plugins` is now `Record<string, IPluginLockEntry>` instead of an
149
+ array — keyed by plugin id, which matches the schema and removes
150
+ the need for clients to do an extra lookup.
151
+ - `installMode` is now optional at the top level (per-entry
152
+ `installMode` already exists inside each plugin entry).
153
+ - `IPluginManifest`
154
+ - `dataAccess` gained `ownedTables: string[]` and
155
+ `ownedDataTablePrefix?: string` so plugins can declare their owned
156
+ tables for the install-time validator and the purger.
157
+
158
+ ### Migration notes for plugin authors
159
+
160
+ ```ts
161
+ // before (1.0.3)
162
+ const registry: IPluginRegistry = {
163
+ schemaVersion: '1.0',
164
+ plugins: [],
165
+ };
166
+
167
+ // after (1.0.4)
168
+ const registry: IPluginRegistry = {
169
+ registryVersion: 1,
170
+ name: 'my-registry',
171
+ plugins: [],
172
+ };
173
+ ```
174
+
175
+ ```ts
176
+ // before (1.0.3)
177
+ const lock: IPluginLock = {
178
+ generatedAt: '...',
179
+ plugins: [],
180
+ installMode: 'managed',
181
+ };
182
+
183
+ // after (1.0.4)
184
+ const lock: IPluginLock = {
185
+ lockfileVersion: 1,
186
+ generatedAt: '...',
187
+ sdk: { version: '1.0.4', pluginApiVersion: '1.0' },
188
+ plugins: {},
189
+ };
190
+ ```
191
+
192
+ Run `npm run check:schemas` (from `sh-selfhelp_shared`) to verify your
193
+ TypeScript matches the canonical JSON schemas after the upgrade.
194
+
195
+ ## [1.0.3] - 2026-05-19
196
+
197
+ - Adjust types after the DB refactoring
198
+
199
+ ## [1.0.0] - 2026-05-08
200
+
201
+ First stable release of `@selfhelp/shared`.
202
+
203
+ ### Added
204
+
205
+ - Shared TypeScript contracts for pages, styles, auth models, and API payloads.
206
+ - A typed `STYLE_REGISTRY` for CMS-driven rendering.
207
+ - Common theme token exports and a shared Tailwind preset surface.
208
+ - Runtime helpers for:
209
+ - interpolation via `replaceCalcedValues()`
210
+ - condition evaluation via `evaluateCondition()`
211
+ - asset URL normalization via `resolveAssetUrl()`
212
+ - spacing parsing and page-data transformation utilities
213
+ - CMS class allow-listing, remapping, and classification helpers.
214
+ - Public npm packaging setup for reuse across multiple projects.
215
+
216
+ ### Included in this release
217
+
218
+ - Root package exports for the main shared API.
219
+ - Subpath exports for:
220
+ - `@selfhelp/shared/registry`
221
+ - `@selfhelp/shared/theme`
222
+ - `@selfhelp/shared/tailwind`
223
+ - Generated CJS, ESM, and TypeScript declaration output in `dist/`.
224
+ - README publishing instructions and package documentation.
225
+
226
+ ### Purpose of the 1.0.0 release
227
+
228
+ This release establishes `@selfhelp/shared` as the source of truth for shared
229
+ frontend and mobile contracts in the SelfHelp ecosystem. The goal of `1.0.0` is
230
+ to provide a stable base that other applications can install, build against, and
231
+ upgrade using normal npm versioning.