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