@selfhelp/shared 1.3.0 → 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 (58) hide show
  1. package/CHANGELOG.md +341 -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,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.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.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.