@selfhelp/shared 1.1.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,143 +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.1.0] - 2026-05-25
8
-
9
- ### Added
10
-
11
- - Plugin SDK field-renderer contracts:
12
- `IFieldRendererDefinition`, `IPluginFieldRendererProps`, and
13
- `fieldRenderers` on `IPluginRegistration`, so plugins can contribute
14
- custom CMS section-field editor controls for plugin-owned field types.
15
-
16
- ### Changed
17
-
18
- - Bumped `PLUGIN_API_VERSION` from `1.0` to `1.1` to reflect the new
19
- additive plugin SDK surface.
20
- - Re-exported the new field-renderer types from `@selfhelp/shared/plugin-sdk`.
21
-
22
- ## [1.0.4] - 2026-05-22
23
-
24
- ### Added
25
-
26
- - New `plugin-sdk` surface for the SelfHelp plugin ecosystem:
27
- - `definePlugin()` / `defineMobilePlugin()` helpers for typed plugin
28
- manifests.
29
- - `definePluginRealtimeTopic()` topic helpers with template expansion.
30
- - `usePluginRealtime()` React hook for Mercure topic subscription. The
31
- hook accepts a `transportFactory` so frontend hosts can inject
32
- `EventSource` and mobile hosts can inject `react-native-sse` without
33
- forcing the SDK to depend on either runtime.
34
- - TypeScript mirrors for `IPluginManifest`, `IPluginRegistry`, and
35
- `IPluginLock` plus the `scripts/check-schema-parity.mjs` script that
36
- verifies the JSON schemas stay in lockstep with the TS types.
37
- - React is now declared as an **optional peer dependency**
38
- (`react ^18 || ^19`). Non-React consumers can keep using the package
39
- without installing React; the `usePluginRealtime` hook is only required
40
- if you opt into realtime updates.
41
-
42
- ### Changed (breaking type contracts)
43
-
44
- These changes broaden the schema-mirroring types so they actually match
45
- the canonical JSON Schemas the backend publishes. Plugin authors
46
- upgrading from `1.0.3` need to update any code that constructed these
47
- shapes literally:
48
-
49
- - `IPluginRegistry`
50
- - Renamed `schemaVersion` (string `'1.0'`) to **`registryVersion`**
51
- (`number`, currently `1`).
52
- - Added required field `name: string`.
53
- - Added optional `homepage`, `publishedAt`, `trustKey`, and `channels`
54
- fields to align with `plugin-registry.schema.json`.
55
- - `IPluginLock`
56
- - Added required field **`lockfileVersion: number`** (currently `1`).
57
- - Added required nested object **`sdk: { version: string; pluginApiVersion: string }`**
58
- so lockfiles always advertise which SDK version they were generated
59
- against.
60
- - `plugins` is now `Record<string, IPluginLockEntry>` instead of an
61
- array — keyed by plugin id, which matches the schema and removes
62
- the need for clients to do an extra lookup.
63
- - `installMode` is now optional at the top level (per-entry
64
- `installMode` already exists inside each plugin entry).
65
- - `IPluginManifest`
66
- - `dataAccess` gained `ownedTables: string[]` and
67
- `ownedDataTablePrefix?: string` so plugins can declare their owned
68
- tables for the install-time validator and the purger.
69
-
70
- ### Migration notes for plugin authors
71
-
72
- ```ts
73
- // before (1.0.3)
74
- const registry: IPluginRegistry = {
75
- schemaVersion: '1.0',
76
- plugins: [],
77
- };
78
-
79
- // after (1.0.4)
80
- const registry: IPluginRegistry = {
81
- registryVersion: 1,
82
- name: 'my-registry',
83
- plugins: [],
84
- };
85
- ```
86
-
87
- ```ts
88
- // before (1.0.3)
89
- const lock: IPluginLock = {
90
- generatedAt: '...',
91
- plugins: [],
92
- installMode: 'managed',
93
- };
94
-
95
- // after (1.0.4)
96
- const lock: IPluginLock = {
97
- lockfileVersion: 1,
98
- generatedAt: '...',
99
- sdk: { version: '1.0.4', pluginApiVersion: '1.0' },
100
- plugins: {},
101
- };
102
- ```
103
-
104
- Run `npm run check:schemas` (from `sh-selfhelp_shared`) to verify your
105
- TypeScript matches the canonical JSON schemas after the upgrade.
106
-
107
- ## [1.0.3] - 2026-05-19
108
-
109
- - Adjust types after the DB refactoring
110
-
111
- ## [1.0.0] - 2026-05-08
112
-
113
- First stable release of `@selfhelp/shared`.
114
-
115
- ### Added
116
-
117
- - Shared TypeScript contracts for pages, styles, auth models, and API payloads.
118
- - A typed `STYLE_REGISTRY` for CMS-driven rendering.
119
- - Common theme token exports and a shared Tailwind preset surface.
120
- - Runtime helpers for:
121
- - interpolation via `replaceCalcedValues()`
122
- - condition evaluation via `evaluateCondition()`
123
- - asset URL normalization via `resolveAssetUrl()`
124
- - spacing parsing and page-data transformation utilities
125
- - CMS class allow-listing, remapping, and classification helpers.
126
- - Public npm packaging setup for reuse across multiple projects.
127
-
128
- ### Included in this release
129
-
130
- - Root package exports for the main shared API.
131
- - Subpath exports for:
132
- - `@selfhelp/shared/registry`
133
- - `@selfhelp/shared/theme`
134
- - `@selfhelp/shared/tailwind`
135
- - Generated CJS, ESM, and TypeScript declaration output in `dist/`.
136
- - README publishing instructions and package documentation.
137
-
138
- ### Purpose of the 1.0.0 release
139
-
140
- This release establishes `@selfhelp/shared` as the source of truth for shared
141
- frontend and mobile contracts in the SelfHelp ecosystem. The goal of `1.0.0` is
142
- to provide a stable base that other applications can install, build against, and
143
- 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.