@selfhelp/shared 1.3.0 → 1.3.2

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +349 -341
  2. package/LICENSE +381 -381
  3. package/README.md +57 -57
  4. package/package.json +102 -102
  5. package/src/api/__tests__/endpoints.test.ts +45 -45
  6. package/src/api/index.ts +5 -5
  7. package/src/assets/__tests__/resolveAssetUrl.test.ts +61 -61
  8. package/src/assets/index.ts +5 -5
  9. package/src/assets/resolveAssetUrl.ts +44 -44
  10. package/src/cms-classes/__tests__/classify.test.ts +63 -63
  11. package/src/cms-classes/allow-list.ts +158 -158
  12. package/src/cms-classes/classify.ts +90 -90
  13. package/src/cms-classes/index.ts +7 -7
  14. package/src/cms-classes/remap.ts +44 -44
  15. package/src/condition/__tests__/evaluate.test.ts +54 -54
  16. package/src/condition/evaluate.ts +121 -121
  17. package/src/condition/index.ts +5 -5
  18. package/src/index.ts +25 -25
  19. package/src/interpolation/__tests__/replaceCalcedValues.test.ts +41 -41
  20. package/src/interpolation/index.ts +5 -5
  21. package/src/interpolation/replaceCalcedValues.ts +27 -27
  22. package/src/plugin-sdk/define.ts +89 -89
  23. package/src/plugin-sdk/index.ts +103 -103
  24. package/src/plugin-sdk/lock.ts +124 -124
  25. package/src/plugin-sdk/manifest.ts +307 -307
  26. package/src/plugin-sdk/realtime.ts +277 -277
  27. package/src/plugin-sdk/registry.ts +105 -105
  28. package/src/plugin-sdk/runtime-shim.ts +140 -140
  29. package/src/plugin-sdk/types.ts +315 -315
  30. package/src/plugin-sdk/version.ts +209 -209
  31. package/src/registry/__tests__/registry.test.ts +135 -135
  32. package/src/registry/index.ts +94 -94
  33. package/src/registry/styles.registry.ts +295 -295
  34. package/src/testing/__tests__/testing-kit.test.ts +228 -228
  35. package/src/testing/index.ts +483 -483
  36. package/src/theme/index.ts +6 -6
  37. package/src/theme/tailwind.ts +73 -73
  38. package/src/theme/tokens.ts +177 -177
  39. package/src/types/api/envelope.ts +34 -34
  40. package/src/types/api/forms.ts +76 -76
  41. package/src/types/api/index.ts +9 -9
  42. package/src/types/api/language.ts +12 -12
  43. package/src/types/api/page.ts +9 -9
  44. package/src/types/index.ts +17 -17
  45. package/src/types/mantine/common.ts +142 -142
  46. package/src/types/pages.ts +107 -107
  47. package/src/types/styles/auth.ts +184 -184
  48. package/src/types/styles/base.ts +72 -72
  49. package/src/types/styles/composite.ts +131 -131
  50. package/src/types/styles/forms.ts +439 -439
  51. package/src/types/styles/interactive.ts +165 -165
  52. package/src/types/styles/layout.ts +184 -184
  53. package/src/types/styles/media.ts +68 -68
  54. package/src/types/styles/typography.ts +118 -118
  55. package/src/types/styles/unknown.ts +220 -220
  56. package/src/utils/__tests__/transformPageData.test.ts +69 -69
  57. package/src/utils/spacing.ts +64 -64
  58. package/src/utils/transformPageData.ts +99 -99
package/CHANGELOG.md CHANGED
@@ -1,341 +1,349 @@
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.3.0]
13
-
14
- ### Added
15
-
16
- - `ENDPOINTS.AUTH.FORGOT_PASSWORD` (`/cms-api/v1/auth/forgot-password`) and
17
- `ENDPOINTS.AUTH.RESET_PASSWORD` (`/cms-api/v1/auth/reset-password`) so the
18
- password-recovery flow is part of the shared API contract (issue #31). The
19
- web frontend and the mobile app now build these requests from shared
20
- constants instead of local/ad-hoc paths.
21
- - Request DTOs `IForgotPasswordRequest` and `IResetPasswordRequest`, and
22
- response types `IForgotPasswordResponse` / `IResetPasswordResponse`,
23
- mirroring the backend `requests/auth/forgot_password.json` and
24
- `reset_password.json` schemas. `scripts/check-schema-parity.mjs` now covers
25
- these request schemas.
26
-
27
- ## [1.2.5]
28
-
29
- ### Changed
30
-
31
- - `IResetPasswordStyle` now models the full two-step reset flow instead of
32
- just the "request a recovery mail" screen. Added optional CMS fields for
33
- the set-password mode: `reset_title`, `reset_label_pw`,
34
- `reset_pw_placeholder`, `reset_label_pw_confirm`,
35
- `reset_pw_confirm_placeholder`, `reset_label_submit`,
36
- `reset_success_title`, `reset_alert_success`, `reset_redirect_text`,
37
- `reset_error_invalid_token`, `reset_error_pw_short`, and
38
- `reset_error_pw_mismatch`.
39
- - Removed the stale legacy `text_md` and `email_user` fields from
40
- `IResetPasswordStyle` so the shared contract matches the backend
41
- `resetPassword` style schema.
42
-
43
- ## [1.2.4] - 2026-06-05
44
-
45
- ### Added
46
-
47
- - Communication preferences support in profile section. `IUserData` gains
48
- `receives_notifications` and `receives_emails` boolean fields.
49
- - New CMS endpoint `UPDATE_COMMUNICATION_PREFERENCES` for updating user
50
- communication preferences.
51
- - Communication preferences CMS label fields on `IProfileStyle`:
52
- `profile_communication_preferences_title`,
53
- `profile_communication_preferences_description`,
54
- `profile_receive_notifications_label`,
55
- `profile_receive_notifications_description`,
56
- `profile_receive_emails_label`,
57
- `profile_receive_emails_description`,
58
- `profile_communication_preferences_button`,
59
- `profile_communication_preferences_success`, and
60
- `profile_communication_preferences_error_general`.
61
- - New permission `ADMIN_SCHEDULED_JOB_MANAGE` for scheduled job management.
62
-
63
- ## [1.2.3] - 2026-06-04
64
-
65
- ### Added
66
-
67
- - Registration-lifecycle CMS label fields on the auth styles so the
68
- previously hardcoded frontend UI text becomes admin-managed. All are
69
- optional `IContentField<string>` (additive, no consumer break):
70
- `IRegisterStyle` gains `label_code`, `code_placeholder`,
71
- `label_go_home`, `label_go_to_login`; `ILoginStyle` gains
72
- `label_register`; `IValidateStyle` gains the activation status text
73
- `loading_title`, `loading_text`, `error_title`, `error_heading`,
74
- `error_text`, `success_title`, and `redirect_text` (use `{seconds}`
75
- as the countdown placeholder). Defaults + en-GB/de-CH translations are
76
- seeded backend-side by `Version20260604111011`.
77
- - Blocking Vitest coverage gate (ecosystem testing strategy, Slice 10).
78
- Added `@vitest/coverage-istanbul`, a `vitest.config.ts` with a coverage
79
- threshold (>= 60% lines/functions/statements/branches) scoped to the
80
- framework-free runtime-helper bundle (interpolation, condition,
81
- asset-URL, CMS-class classifier, page transform), and a `test:coverage`
82
- script. `shared-tests.yml` now runs `npm run test:coverage`, so a
83
- coverage regression on those shared contracts fails CI (currently ~97%
84
- lines). Implements canonical Testing Rule 20 (warning -> blocking). The
85
- istanbul provider is used instead of v8 because v8 double-counts files on
86
- Windows (phantom 0% entries) and would fail the gate locally.
87
- - New public subpath export `@selfhelp/shared/testing` — the plugin
88
- certification kit (`CERTIFICATION_KIT_VERSION` `1.0.0`).
89
- `definePluginCertification(config).run(manifest)` now performs the real
90
- **static manifest certification** and returns a typed
91
- `IPluginCertificationReport`: ordered checks `manifest-valid`,
92
- `capabilities-vs-trust-level`, `compatibility-shape`,
93
- `lookup-ownership`, `db-naming` (also exported individually as
94
- `checkManifestValid`, `checkCapabilitiesVsTrustLevel`,
95
- `checkCompatibilityShape`, `checkLookupOwnership`, `checkDbNaming`, and
96
- `runCertificationChecks`). Built on the existing plugin SDK
97
- (`IPluginManifest` + semver helpers) so manifest typing/range parsing is
98
- not re-implemented. Runtime install/lifecycle remains the backend host
99
- certification's responsibility — the kit gates the manifest before
100
- publishing; the host gates the actual install. Also ships the
101
- fully-working in-memory `mockMercureHub` (Mercure recorder, no polling)
102
- and `seedFromLockFile`.
103
- - `IPluginManifestDataAccess` now mirrors the manifest schema's
104
- `ownedTables` and `ownedDataTablePrefix` fields (previously only
105
- `read`/`write`/`delete` were typed), so the `db-naming` certification
106
- check is fully typed against the real manifest.
107
- - Vitest unit tests for the runtime helpers (`replaceCalcedValues`,
108
- `evaluateCondition`/`buildConditionContext`, `resolveAssetUrl`/
109
- `resolveAssetSources`, `classifyClass`/`classifyClassString`,
110
- `transformPageData`/`transformPagesData`) and the testing kit.
111
-
112
- ### Changed
113
-
114
- - `scripts/check-schema-parity.mjs` now also checks API response
115
- contracts (`config/schemas/api/v1`: response envelope, auth login,
116
- form submit) against the shared TS types, not only the plugin SDK
117
- schemas. The form-submit data shape is flagged as a tracked
118
- `knownDrift` warning pending cross-repo reconciliation
119
- (`submitted_at` / `user_authenticated` are in the backend schema but
120
- not in `IFormSubmitData`).
121
-
122
- ## [1.2.1] - 2026-05-28
123
-
124
- ### Fixed
125
-
126
- - `IPluginRegistry` in `@selfhelp/shared/plugin-sdk` is now back in
127
- sync with the canonical `plugin-registry.schema.json` shipped by
128
- `sh-selfhelp_backend`. The root version field is the schema's
129
- `schemaVersion: '1.0'` again (the `registryVersion: number` rename
130
- introduced in `1.0.4` mis-described the wire format). Added the two
131
- other canonical root fields, `baseUrl` and `publisher`, as optional
132
- so the type matches what `scripts/publish-to-registry.mjs` actually
133
- emits. The pre-existing `name` / `homepage` / `trustKey` /
134
- `channels` properties are kept as optional legacy helpers and
135
- flagged in the JSDoc as not part of the canonical schema; they will
136
- be removed in the next major release once the deeper drift in
137
- `IPluginRegistryEntry` / `IPluginRegistryVersionEntry` is rewritten
138
- to match the canonical schema.
139
- - `npm run check:schemas` is green again — previously failed because
140
- `schemaVersion` was missing from the TS mirror after the `1.0.4`
141
- rename.
142
-
143
- ### Migration notes
144
-
145
- ```ts
146
- // before (1.2.0, broken)
147
- const registry: IPluginRegistry = {
148
- registryVersion: 1,
149
- name: 'my-registry',
150
- plugins: [],
151
- };
152
-
153
- // after (1.2.1, matches plugin-registry.schema.json)
154
- const registry: IPluginRegistry = {
155
- schemaVersion: '1.0',
156
- publisher: { name: 'my-registry' },
157
- plugins: [],
158
- };
159
- ```
160
-
161
- No runtime/installation behaviour changed — this only corrects the
162
- shape of the published TS contract that plugin authors compile
163
- against. The backend's `RegistryClient` already reads the canonical
164
- wire format, so installed registries keep working.
165
-
166
- ## [1.2.0] - 2026-05-28
167
-
168
- ### Added
169
-
170
- - Canonical plugin runtime-shim contract exported from
171
- `@selfhelp/shared/plugin-sdk`. This is the single source of truth
172
- every consumer (host import map, host `globalThis` stash, host
173
- `/api/plugins/runtime-shim/*` BFF route, plugin Vite build, plugin
174
- dev-runtime server) now reads from, so the three pieces cannot
175
- drift apart again:
176
- - `PLUGIN_RUNTIME_SHIM_SPECIFIERS` — readonly list of every bare
177
- specifier the host shims to plugins. Includes the previously
178
- missing `react/jsx-dev-runtime` (needed by Vite's React plugin in
179
- dev mode) and `@mantine/notifications` (consumed by plugins that
180
- show toast notifications), so dev-server bundles can resolve them
181
- instead of bundling a second copy of React or Mantine.
182
- - `PLUGIN_RUNTIME_SHIM_BASE_PATH` — `/api/plugins/runtime-shim/`
183
- constant; the host frontend owns this route.
184
- - `PLUGIN_RUNTIME_GLOBAL_KEY` — `__SELFHELP_RUNTIME__` constant.
185
- - `PLUGIN_RUNTIME_IMPORT_MAP` — frozen `Record` derived from the
186
- specifier list, ready to be `JSON.stringify`ed into the host's
187
- `<script type="importmap">` tag.
188
- - `buildPluginRuntimeShimPath(specifier)` — string builder for a
189
- single specifier.
190
- - `isPluginRuntimeShimSpecifier(value)` — runtime type guard.
191
- - `TPluginRuntimeShimSpecifier` — string-literal type union of the
192
- supported specifiers.
193
- - The plugin SDK contract version bumps from `1.1` to `1.2` to
194
- reflect the additive surface. Hosts on SDK `1.2+` still accept
195
- plugins declaring `pluginApiVersion: "1.1"`, so existing plugins
196
- remain compatible.
197
-
198
- ### Changed
199
-
200
- - `PLUGIN_API_VERSION` constant: `1.1` → `1.2`. No behavioural
201
- change for plugins that do not consume the runtime-shim contract
202
- directly; this only signals which optional SDK surface the host
203
- exposes.
204
-
205
- ## [1.1.0] - 2026-05-25
206
-
207
- ### Added
208
-
209
- - Plugin SDK field-renderer contracts:
210
- `IFieldRendererDefinition`, `IPluginFieldRendererProps`, and
211
- `fieldRenderers` on `IPluginRegistration`, so plugins can contribute
212
- custom CMS section-field editor controls for plugin-owned field types.
213
-
214
- ### Changed
215
-
216
- - Bumped `PLUGIN_API_VERSION` from `1.0` to `1.1` to reflect the new
217
- additive plugin SDK surface.
218
- - Re-exported the new field-renderer types from `@selfhelp/shared/plugin-sdk`.
219
-
220
- ## [1.0.4] - 2026-05-22
221
-
222
- ### Added
223
-
224
- - New `plugin-sdk` surface for the SelfHelp plugin ecosystem:
225
- - `definePlugin()` / `defineMobilePlugin()` helpers for typed plugin
226
- manifests.
227
- - `definePluginRealtimeTopic()` topic helpers with template expansion.
228
- - `usePluginRealtime()` React hook for Mercure topic subscription. The
229
- hook accepts a `transportFactory` so frontend hosts can inject
230
- `EventSource` and mobile hosts can inject `react-native-sse` without
231
- forcing the SDK to depend on either runtime.
232
- - TypeScript mirrors for `IPluginManifest`, `IPluginRegistry`, and
233
- `IPluginLock` plus the `scripts/check-schema-parity.mjs` script that
234
- verifies the JSON schemas stay in lockstep with the TS types.
235
- - React is now declared as an **optional peer dependency**
236
- (`react ^18 || ^19`). Non-React consumers can keep using the package
237
- without installing React; the `usePluginRealtime` hook is only required
238
- if you opt into realtime updates.
239
-
240
- ### Changed (breaking type contracts)
241
-
242
- These changes broaden the schema-mirroring types so they actually match
243
- the canonical JSON Schemas the backend publishes. Plugin authors
244
- upgrading from `1.0.3` need to update any code that constructed these
245
- shapes literally:
246
-
247
- - `IPluginRegistry`
248
- - Renamed `schemaVersion` (string `'1.0'`) to **`registryVersion`**
249
- (`number`, currently `1`).
250
- - Added required field `name: string`.
251
- - Added optional `homepage`, `publishedAt`, `trustKey`, and `channels`
252
- fields to align with `plugin-registry.schema.json`.
253
- - `IPluginLock`
254
- - Added required field **`lockfileVersion: number`** (currently `1`).
255
- - Added required nested object **`sdk: { version: string; pluginApiVersion: string }`**
256
- so lockfiles always advertise which SDK version they were generated
257
- against.
258
- - `plugins` is now `Record<string, IPluginLockEntry>` instead of an
259
- array — keyed by plugin id, which matches the schema and removes
260
- the need for clients to do an extra lookup.
261
- - `installMode` is now optional at the top level (per-entry
262
- `installMode` already exists inside each plugin entry).
263
- - `IPluginManifest`
264
- - `dataAccess` gained `ownedTables: string[]` and
265
- `ownedDataTablePrefix?: string` so plugins can declare their owned
266
- tables for the install-time validator and the purger.
267
-
268
- ### Migration notes for plugin authors
269
-
270
- ```ts
271
- // before (1.0.3)
272
- const registry: IPluginRegistry = {
273
- schemaVersion: '1.0',
274
- plugins: [],
275
- };
276
-
277
- // after (1.0.4)
278
- const registry: IPluginRegistry = {
279
- registryVersion: 1,
280
- name: 'my-registry',
281
- plugins: [],
282
- };
283
- ```
284
-
285
- ```ts
286
- // before (1.0.3)
287
- const lock: IPluginLock = {
288
- generatedAt: '...',
289
- plugins: [],
290
- installMode: 'managed',
291
- };
292
-
293
- // after (1.0.4)
294
- const lock: IPluginLock = {
295
- lockfileVersion: 1,
296
- generatedAt: '...',
297
- sdk: { version: '1.0.4', pluginApiVersion: '1.0' },
298
- plugins: {},
299
- };
300
- ```
301
-
302
- Run `npm run check:schemas` (from `sh-selfhelp_shared`) to verify your
303
- TypeScript matches the canonical JSON schemas after the upgrade.
304
-
305
- ## [1.0.3] - 2026-05-19
306
-
307
- - Adjust types after the DB refactoring
308
-
309
- ## [1.0.0] - 2026-05-08
310
-
311
- First stable release of `@selfhelp/shared`.
312
-
313
- ### Added
314
-
315
- - Shared TypeScript contracts for pages, styles, auth models, and API payloads.
316
- - A typed `STYLE_REGISTRY` for CMS-driven rendering.
317
- - Common theme token exports and a shared Tailwind preset surface.
318
- - Runtime helpers for:
319
- - interpolation via `replaceCalcedValues()`
320
- - condition evaluation via `evaluateCondition()`
321
- - asset URL normalization via `resolveAssetUrl()`
322
- - spacing parsing and page-data transformation utilities
323
- - CMS class allow-listing, remapping, and classification helpers.
324
- - Public npm packaging setup for reuse across multiple projects.
325
-
326
- ### Included in this release
327
-
328
- - Root package exports for the main shared API.
329
- - Subpath exports for:
330
- - `@selfhelp/shared/registry`
331
- - `@selfhelp/shared/theme`
332
- - `@selfhelp/shared/tailwind`
333
- - Generated CJS, ESM, and TypeScript declaration output in `dist/`.
334
- - README publishing instructions and package documentation.
335
-
336
- ### Purpose of the 1.0.0 release
337
-
338
- This release establishes `@selfhelp/shared` as the source of truth for shared
339
- frontend and mobile contracts in the SelfHelp ecosystem. The goal of `1.0.0` is
340
- to provide a stable base that other applications can install, build against, and
341
- 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.3.2]
13
+
14
+ ### Changed
15
+
16
+ - Maintenance release: cut a clean published version for consumers to pin.
17
+ Supersedes the `1.3.1` test publish; no functional or API changes since
18
+ `1.3.0`.
19
+
20
+ ## [1.3.0]
21
+
22
+ ### Added
23
+
24
+ - `ENDPOINTS.AUTH.FORGOT_PASSWORD` (`/cms-api/v1/auth/forgot-password`) and
25
+ `ENDPOINTS.AUTH.RESET_PASSWORD` (`/cms-api/v1/auth/reset-password`) so the
26
+ password-recovery flow is part of the shared API contract (issue #31). The
27
+ web frontend and the mobile app now build these requests from shared
28
+ constants instead of local/ad-hoc paths.
29
+ - Request DTOs `IForgotPasswordRequest` and `IResetPasswordRequest`, and
30
+ response types `IForgotPasswordResponse` / `IResetPasswordResponse`,
31
+ mirroring the backend `requests/auth/forgot_password.json` and
32
+ `reset_password.json` schemas. `scripts/check-schema-parity.mjs` now covers
33
+ these request schemas.
34
+
35
+ ## [1.2.5]
36
+
37
+ ### Changed
38
+
39
+ - `IResetPasswordStyle` now models the full two-step reset flow instead of
40
+ just the "request a recovery mail" screen. Added optional CMS fields for
41
+ the set-password mode: `reset_title`, `reset_label_pw`,
42
+ `reset_pw_placeholder`, `reset_label_pw_confirm`,
43
+ `reset_pw_confirm_placeholder`, `reset_label_submit`,
44
+ `reset_success_title`, `reset_alert_success`, `reset_redirect_text`,
45
+ `reset_error_invalid_token`, `reset_error_pw_short`, and
46
+ `reset_error_pw_mismatch`.
47
+ - Removed the stale legacy `text_md` and `email_user` fields from
48
+ `IResetPasswordStyle` so the shared contract matches the backend
49
+ `resetPassword` style schema.
50
+
51
+ ## [1.2.4] - 2026-06-05
52
+
53
+ ### Added
54
+
55
+ - Communication preferences support in profile section. `IUserData` gains
56
+ `receives_notifications` and `receives_emails` boolean fields.
57
+ - New CMS endpoint `UPDATE_COMMUNICATION_PREFERENCES` for updating user
58
+ communication preferences.
59
+ - Communication preferences CMS label fields on `IProfileStyle`:
60
+ `profile_communication_preferences_title`,
61
+ `profile_communication_preferences_description`,
62
+ `profile_receive_notifications_label`,
63
+ `profile_receive_notifications_description`,
64
+ `profile_receive_emails_label`,
65
+ `profile_receive_emails_description`,
66
+ `profile_communication_preferences_button`,
67
+ `profile_communication_preferences_success`, and
68
+ `profile_communication_preferences_error_general`.
69
+ - New permission `ADMIN_SCHEDULED_JOB_MANAGE` for scheduled job management.
70
+
71
+ ## [1.2.3] - 2026-06-04
72
+
73
+ ### Added
74
+
75
+ - Registration-lifecycle CMS label fields on the auth styles so the
76
+ previously hardcoded frontend UI text becomes admin-managed. All are
77
+ optional `IContentField<string>` (additive, no consumer break):
78
+ `IRegisterStyle` gains `label_code`, `code_placeholder`,
79
+ `label_go_home`, `label_go_to_login`; `ILoginStyle` gains
80
+ `label_register`; `IValidateStyle` gains the activation status text
81
+ `loading_title`, `loading_text`, `error_title`, `error_heading`,
82
+ `error_text`, `success_title`, and `redirect_text` (use `{seconds}`
83
+ as the countdown placeholder). Defaults + en-GB/de-CH translations are
84
+ seeded backend-side by `Version20260604111011`.
85
+ - Blocking Vitest coverage gate (ecosystem testing strategy, Slice 10).
86
+ Added `@vitest/coverage-istanbul`, a `vitest.config.ts` with a coverage
87
+ threshold (>= 60% lines/functions/statements/branches) scoped to the
88
+ framework-free runtime-helper bundle (interpolation, condition,
89
+ asset-URL, CMS-class classifier, page transform), and a `test:coverage`
90
+ script. `shared-tests.yml` now runs `npm run test:coverage`, so a
91
+ coverage regression on those shared contracts fails CI (currently ~97%
92
+ lines). Implements canonical Testing Rule 20 (warning -> blocking). The
93
+ istanbul provider is used instead of v8 because v8 double-counts files on
94
+ Windows (phantom 0% entries) and would fail the gate locally.
95
+ - New public subpath export `@selfhelp/shared/testing` — the plugin
96
+ certification kit (`CERTIFICATION_KIT_VERSION` `1.0.0`).
97
+ `definePluginCertification(config).run(manifest)` now performs the real
98
+ **static manifest certification** and returns a typed
99
+ `IPluginCertificationReport`: ordered checks `manifest-valid`,
100
+ `capabilities-vs-trust-level`, `compatibility-shape`,
101
+ `lookup-ownership`, `db-naming` (also exported individually as
102
+ `checkManifestValid`, `checkCapabilitiesVsTrustLevel`,
103
+ `checkCompatibilityShape`, `checkLookupOwnership`, `checkDbNaming`, and
104
+ `runCertificationChecks`). Built on the existing plugin SDK
105
+ (`IPluginManifest` + semver helpers) so manifest typing/range parsing is
106
+ not re-implemented. Runtime install/lifecycle remains the backend host
107
+ certification's responsibility — the kit gates the manifest before
108
+ publishing; the host gates the actual install. Also ships the
109
+ fully-working in-memory `mockMercureHub` (Mercure recorder, no polling)
110
+ and `seedFromLockFile`.
111
+ - `IPluginManifestDataAccess` now mirrors the manifest schema's
112
+ `ownedTables` and `ownedDataTablePrefix` fields (previously only
113
+ `read`/`write`/`delete` were typed), so the `db-naming` certification
114
+ check is fully typed against the real manifest.
115
+ - Vitest unit tests for the runtime helpers (`replaceCalcedValues`,
116
+ `evaluateCondition`/`buildConditionContext`, `resolveAssetUrl`/
117
+ `resolveAssetSources`, `classifyClass`/`classifyClassString`,
118
+ `transformPageData`/`transformPagesData`) and the testing kit.
119
+
120
+ ### Changed
121
+
122
+ - `scripts/check-schema-parity.mjs` now also checks API response
123
+ contracts (`config/schemas/api/v1`: response envelope, auth login,
124
+ form submit) against the shared TS types, not only the plugin SDK
125
+ schemas. The form-submit data shape is flagged as a tracked
126
+ `knownDrift` warning pending cross-repo reconciliation
127
+ (`submitted_at` / `user_authenticated` are in the backend schema but
128
+ not in `IFormSubmitData`).
129
+
130
+ ## [1.2.1] - 2026-05-28
131
+
132
+ ### Fixed
133
+
134
+ - `IPluginRegistry` in `@selfhelp/shared/plugin-sdk` is now back in
135
+ sync with the canonical `plugin-registry.schema.json` shipped by
136
+ `sh-selfhelp_backend`. The root version field is the schema's
137
+ `schemaVersion: '1.0'` again (the `registryVersion: number` rename
138
+ introduced in `1.0.4` mis-described the wire format). Added the two
139
+ other canonical root fields, `baseUrl` and `publisher`, as optional
140
+ so the type matches what `scripts/publish-to-registry.mjs` actually
141
+ emits. The pre-existing `name` / `homepage` / `trustKey` /
142
+ `channels` properties are kept as optional legacy helpers and
143
+ flagged in the JSDoc as not part of the canonical schema; they will
144
+ be removed in the next major release once the deeper drift in
145
+ `IPluginRegistryEntry` / `IPluginRegistryVersionEntry` is rewritten
146
+ to match the canonical schema.
147
+ - `npm run check:schemas` is green again — previously failed because
148
+ `schemaVersion` was missing from the TS mirror after the `1.0.4`
149
+ rename.
150
+
151
+ ### Migration notes
152
+
153
+ ```ts
154
+ // before (1.2.0, broken)
155
+ const registry: IPluginRegistry = {
156
+ registryVersion: 1,
157
+ name: 'my-registry',
158
+ plugins: [],
159
+ };
160
+
161
+ // after (1.2.1, matches plugin-registry.schema.json)
162
+ const registry: IPluginRegistry = {
163
+ schemaVersion: '1.0',
164
+ publisher: { name: 'my-registry' },
165
+ plugins: [],
166
+ };
167
+ ```
168
+
169
+ No runtime/installation behaviour changed — this only corrects the
170
+ shape of the published TS contract that plugin authors compile
171
+ against. The backend's `RegistryClient` already reads the canonical
172
+ wire format, so installed registries keep working.
173
+
174
+ ## [1.2.0] - 2026-05-28
175
+
176
+ ### Added
177
+
178
+ - Canonical plugin runtime-shim contract exported from
179
+ `@selfhelp/shared/plugin-sdk`. This is the single source of truth
180
+ every consumer (host import map, host `globalThis` stash, host
181
+ `/api/plugins/runtime-shim/*` BFF route, plugin Vite build, plugin
182
+ dev-runtime server) now reads from, so the three pieces cannot
183
+ drift apart again:
184
+ - `PLUGIN_RUNTIME_SHIM_SPECIFIERS` — readonly list of every bare
185
+ specifier the host shims to plugins. Includes the previously
186
+ missing `react/jsx-dev-runtime` (needed by Vite's React plugin in
187
+ dev mode) and `@mantine/notifications` (consumed by plugins that
188
+ show toast notifications), so dev-server bundles can resolve them
189
+ instead of bundling a second copy of React or Mantine.
190
+ - `PLUGIN_RUNTIME_SHIM_BASE_PATH` — `/api/plugins/runtime-shim/`
191
+ constant; the host frontend owns this route.
192
+ - `PLUGIN_RUNTIME_GLOBAL_KEY` — `__SELFHELP_RUNTIME__` constant.
193
+ - `PLUGIN_RUNTIME_IMPORT_MAP` — frozen `Record` derived from the
194
+ specifier list, ready to be `JSON.stringify`ed into the host's
195
+ `<script type="importmap">` tag.
196
+ - `buildPluginRuntimeShimPath(specifier)` — string builder for a
197
+ single specifier.
198
+ - `isPluginRuntimeShimSpecifier(value)` — runtime type guard.
199
+ - `TPluginRuntimeShimSpecifier` — string-literal type union of the
200
+ supported specifiers.
201
+ - The plugin SDK contract version bumps from `1.1` to `1.2` to
202
+ reflect the additive surface. Hosts on SDK `1.2+` still accept
203
+ plugins declaring `pluginApiVersion: "1.1"`, so existing plugins
204
+ remain compatible.
205
+
206
+ ### Changed
207
+
208
+ - `PLUGIN_API_VERSION` constant: `1.1` → `1.2`. No behavioural
209
+ change for plugins that do not consume the runtime-shim contract
210
+ directly; this only signals which optional SDK surface the host
211
+ exposes.
212
+
213
+ ## [1.1.0] - 2026-05-25
214
+
215
+ ### Added
216
+
217
+ - Plugin SDK field-renderer contracts:
218
+ `IFieldRendererDefinition`, `IPluginFieldRendererProps`, and
219
+ `fieldRenderers` on `IPluginRegistration`, so plugins can contribute
220
+ custom CMS section-field editor controls for plugin-owned field types.
221
+
222
+ ### Changed
223
+
224
+ - Bumped `PLUGIN_API_VERSION` from `1.0` to `1.1` to reflect the new
225
+ additive plugin SDK surface.
226
+ - Re-exported the new field-renderer types from `@selfhelp/shared/plugin-sdk`.
227
+
228
+ ## [1.0.4] - 2026-05-22
229
+
230
+ ### Added
231
+
232
+ - New `plugin-sdk` surface for the SelfHelp plugin ecosystem:
233
+ - `definePlugin()` / `defineMobilePlugin()` helpers for typed plugin
234
+ manifests.
235
+ - `definePluginRealtimeTopic()` topic helpers with template expansion.
236
+ - `usePluginRealtime()` React hook for Mercure topic subscription. The
237
+ hook accepts a `transportFactory` so frontend hosts can inject
238
+ `EventSource` and mobile hosts can inject `react-native-sse` without
239
+ forcing the SDK to depend on either runtime.
240
+ - TypeScript mirrors for `IPluginManifest`, `IPluginRegistry`, and
241
+ `IPluginLock` plus the `scripts/check-schema-parity.mjs` script that
242
+ verifies the JSON schemas stay in lockstep with the TS types.
243
+ - React is now declared as an **optional peer dependency**
244
+ (`react ^18 || ^19`). Non-React consumers can keep using the package
245
+ without installing React; the `usePluginRealtime` hook is only required
246
+ if you opt into realtime updates.
247
+
248
+ ### Changed (breaking type contracts)
249
+
250
+ These changes broaden the schema-mirroring types so they actually match
251
+ the canonical JSON Schemas the backend publishes. Plugin authors
252
+ upgrading from `1.0.3` need to update any code that constructed these
253
+ shapes literally:
254
+
255
+ - `IPluginRegistry`
256
+ - Renamed `schemaVersion` (string `'1.0'`) to **`registryVersion`**
257
+ (`number`, currently `1`).
258
+ - Added required field `name: string`.
259
+ - Added optional `homepage`, `publishedAt`, `trustKey`, and `channels`
260
+ fields to align with `plugin-registry.schema.json`.
261
+ - `IPluginLock`
262
+ - Added required field **`lockfileVersion: number`** (currently `1`).
263
+ - Added required nested object **`sdk: { version: string; pluginApiVersion: string }`**
264
+ so lockfiles always advertise which SDK version they were generated
265
+ against.
266
+ - `plugins` is now `Record<string, IPluginLockEntry>` instead of an
267
+ array — keyed by plugin id, which matches the schema and removes
268
+ the need for clients to do an extra lookup.
269
+ - `installMode` is now optional at the top level (per-entry
270
+ `installMode` already exists inside each plugin entry).
271
+ - `IPluginManifest`
272
+ - `dataAccess` gained `ownedTables: string[]` and
273
+ `ownedDataTablePrefix?: string` so plugins can declare their owned
274
+ tables for the install-time validator and the purger.
275
+
276
+ ### Migration notes for plugin authors
277
+
278
+ ```ts
279
+ // before (1.0.3)
280
+ const registry: IPluginRegistry = {
281
+ schemaVersion: '1.0',
282
+ plugins: [],
283
+ };
284
+
285
+ // after (1.0.4)
286
+ const registry: IPluginRegistry = {
287
+ registryVersion: 1,
288
+ name: 'my-registry',
289
+ plugins: [],
290
+ };
291
+ ```
292
+
293
+ ```ts
294
+ // before (1.0.3)
295
+ const lock: IPluginLock = {
296
+ generatedAt: '...',
297
+ plugins: [],
298
+ installMode: 'managed',
299
+ };
300
+
301
+ // after (1.0.4)
302
+ const lock: IPluginLock = {
303
+ lockfileVersion: 1,
304
+ generatedAt: '...',
305
+ sdk: { version: '1.0.4', pluginApiVersion: '1.0' },
306
+ plugins: {},
307
+ };
308
+ ```
309
+
310
+ Run `npm run check:schemas` (from `sh-selfhelp_shared`) to verify your
311
+ TypeScript matches the canonical JSON schemas after the upgrade.
312
+
313
+ ## [1.0.3] - 2026-05-19
314
+
315
+ - Adjust types after the DB refactoring
316
+
317
+ ## [1.0.0] - 2026-05-08
318
+
319
+ First stable release of `@selfhelp/shared`.
320
+
321
+ ### Added
322
+
323
+ - Shared TypeScript contracts for pages, styles, auth models, and API payloads.
324
+ - A typed `STYLE_REGISTRY` for CMS-driven rendering.
325
+ - Common theme token exports and a shared Tailwind preset surface.
326
+ - Runtime helpers for:
327
+ - interpolation via `replaceCalcedValues()`
328
+ - condition evaluation via `evaluateCondition()`
329
+ - asset URL normalization via `resolveAssetUrl()`
330
+ - spacing parsing and page-data transformation utilities
331
+ - CMS class allow-listing, remapping, and classification helpers.
332
+ - Public npm packaging setup for reuse across multiple projects.
333
+
334
+ ### Included in this release
335
+
336
+ - Root package exports for the main shared API.
337
+ - Subpath exports for:
338
+ - `@selfhelp/shared/registry`
339
+ - `@selfhelp/shared/theme`
340
+ - `@selfhelp/shared/tailwind`
341
+ - Generated CJS, ESM, and TypeScript declaration output in `dist/`.
342
+ - README publishing instructions and package documentation.
343
+
344
+ ### Purpose of the 1.0.0 release
345
+
346
+ This release establishes `@selfhelp/shared` as the source of truth for shared
347
+ frontend and mobile contracts in the SelfHelp ecosystem. The goal of `1.0.0` is
348
+ to provide a stable base that other applications can install, build against, and
349
+ upgrade using normal npm versioning.